IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

ecrire avec ttf


Sujet :

Langage PHP

  1. #1
    Membre habitué Avatar de alexmorel
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    196
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2003
    Messages : 196
    Points : 157
    Points
    157
    Par défaut ecrire avec ttf
    Voilà je désire crée une image avec un texte et une police bien precis

    A cette adresse j'ai trouvé ce script
    http://fr.php.net/manual/en/function.imagettftext.php


    Met le problème vient des majuscules

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    <?php
    ### Declare this script will be displayed as a PNG image.
    header("Content-type: image/png");
     
    ####################### BEGIN USER EDITS #######################
    $imagewidth = 310;
    $imageheight = 70;
    $fontsize = "20";
    $fontangle = "0";
    $font = "police.ttf";
    $text = "Centre de Jeunesse Régional";
    $backgroundcolor = "003366";
    $textcolor = "FFCC66";
    ######################## END USER EDITS ########################
     
    ### Convert HTML backgound color to RGB
    if( eregi( "([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})", $backgroundcolor, $bgrgb ) )
    {$bgred = hexdec( $bgrgb[1] );  $bggreen = hexdec( $bgrgb[2] );  $bgblue = hexdec( $bgrgb[3] );}
     
    ### Convert HTML text color to RGB
    if( eregi( "([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})", $textcolor, $textrgb ) )
    {$textred = hexdec( $textrgb[1] );  $textgreen = hexdec( $textrgb[2] );  $textblue = hexdec( $textrgb[3] );}
     
    ### Create image
    $im = imagecreate( $imagewidth, $imageheight );
     
    ### Declare image's background color
    $bgcolor = imagecolorallocate($im, $bgred,$bggreen,$bgblue);
     
    ### Declare image's text color
    $fontcolor = imagecolorallocate($im, $textred,$textgreen,$textblue);
     
    ### Get exact dimensions of text string
    $box = @imageTTFBbox($fontsize,$fontangle,$font,$text);
     
    ### Get width of text from dimensions
    $textwidth = abs($box[4] - $box[0]);
     
    ### Get height of text from dimensions
    $textheight = abs($box[5] - $box[1]);
     
    ### Get x-coordinate of centered text horizontally using length of the image and length of the text
    $xcord = ($imagewidth/2)-($textwidth/2)-2;
     
    ### Get y-coordinate of centered text vertically using height of the image and height of the text
    $ycord = ($imageheight/2)+($textheight/2);
     
    ### Declare completed image with colors, font, text, and text location
    imagettftext ( $im, $fontsize, $fontangle, $xcord, $ycord, $fontcolor, $font, $text );
     
    ### Display completed image as PNG
    imagepng($im);
     
    ### Close the image
    imagedestroy($im);
    ?>
    Je n'arrive pas a mettre mes majuscule !

    Merci d'avance ...

  2. #2
    Membre habitué Avatar de alexmorel
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    196
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2003
    Messages : 196
    Points : 157
    Points
    157
    Par défaut
    je relance merci

  3. #3
    Membre actif Avatar de kevinf
    Profil pro
    Développeur informatique
    Inscrit en
    Juin 2005
    Messages
    863
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2005
    Messages : 863
    Points : 225
    Points
    225
    Par défaut
    C'est peut être que ta police n'a pas les majuscules.

  4. #4
    Membre habitué Avatar de alexmorel
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    196
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : Suisse

    Informations forums :
    Inscription : Septembre 2003
    Messages : 196
    Points : 157
    Points
    157
    Par défaut
    Si car si je l utilise sous word par exemple elle les as

Discussions similaires

  1. ecrire avec un font .ttf
    Par kha_yassine dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 01/09/2007, 20h56
  2. Ecrire avec TComPort
    Par coax81 dans le forum Composants VCL
    Réponses: 5
    Dernier message: 29/08/2007, 17h01
  3. Réponses: 3
    Dernier message: 23/03/2007, 16h23
  4. Ecrire avec une taille de police toute petite
    Par yobuntu dans le forum Mise en forme
    Réponses: 2
    Dernier message: 13/02/2007, 14h04
  5. Ecrire avec ofstream
    Par Happy dans le forum SL & STL
    Réponses: 2
    Dernier message: 19/01/2007, 16h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo