[GD]Could not find/open font - font problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • carramba

    [GD]Could not find/open font - font problem

    I know this subjekt was up several times but Icant get it work
    use gd2 on win32
    [code=html]<?
    putenv('GDFONTP ATH=f:\swd\font ');
    $font = "f:/swd/font/arial.ttf";
    $im = imagecreate (250, 28);
    $black = ImageColorAlloc ate ($im, 0, 0, 0);
    $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
    ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font,
    "comming text or not?");
    ImagePNG($im,te st.png);

    ?>
    <img src="test.png" alt="image">[/code]

    but I allway get error about not finding font ..

    what should I do?
    Last edited by pbmods; Feb 25 '09, 08:11 PM. Reason: Added CODE tags.
  • CountScubula

    #2
    Re: [GD]Could not find/open font - font problem

    Not sure, becouse it looks right, but what about the forward slash?

    I take it this is a windows install? try: $font =
    "f:\\swd\\font\ \arial.ttf";
    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools
    "carramba" <carramba@bootr e.com> wrote in message
    news:a4e7fbcf.0 403091200.11414 3c@posting.goog le.com...[color=blue]
    > I know this subjekt was up several times but Icant get it work
    > use gd2 on win32
    > <?
    > putenv('GDFONTP ATH=f:\swd\font ');
    > $font = "f:/swd/font/arial.ttf";
    > $im = imagecreate (250, 28);
    > $black = ImageColorAlloc ate ($im, 0, 0, 0);
    > $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
    > ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font,
    > "comming text or not?");
    > ImagePNG($im,te st.png);
    >
    > ?>
    > <img src="test.png" alt="image">
    >
    > but I allway get error about not finding font ..
    >
    > what should I do?[/color]


    Comment

    • jn

      #3
      Re: [GD]Could not find/open font - font problem

      "carramba" <carramba@bootr e.com> wrote in message
      news:a4e7fbcf.0 403091200.11414 3c@posting.goog le.com...[color=blue]
      > I know this subjekt was up several times but Icant get it work
      > use gd2 on win32
      > <?
      > putenv('GDFONTP ATH=f:\swd\font ');
      > $font = "f:/swd/font/arial.ttf";
      > $im = imagecreate (250, 28);
      > $black = ImageColorAlloc ate ($im, 0, 0, 0);
      > $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
      > ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font,
      > "comming text or not?");
      > ImagePNG($im,te st.png);
      >
      > ?>
      > <img src="test.png" alt="image">
      >
      > but I allway get error about not finding font ..
      >
      > what should I do?
      >[/color]

      I hate that bug. I got mine to work on Windows and Linux by only giving it
      the font name (it adds .ttf by itself) and by using realpath().

      Create a folder called "font" where your script is, and put your font there.

      <?

      $fontpath = realpath('./font/');
      putenv('GDFONTP ATH='.$fontpath );
      $font = "arial";
      $im = imagecreate (250, 28);
      $black = ImageColorAlloc ate ($im, 0, 0, 0);
      $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
      ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font, "comming text or not?");
      ImagePNG($im,te st.png);
      ?>

      <img src="test.png" alt="image">

      I hope this works for you...


      Comment

      • carramba

        #4
        Re: [GD]Could not find/open font - font problem

        "jn" <usenet*spamist ehsuckremovetor eply*@jasonnorr is.net> wrote in message news:<7ht3c.225 682$jH.2546473@ twister.tampaba y.rr.com>...[color=blue]
        > "carramba" <carramba@bootr e.com> wrote in message
        > news:a4e7fbcf.0 403091200.11414 3c@posting.goog le.com...[color=green]
        > > I know this subjekt was up several times but Icant get it work
        > > use gd2 on win32
        > > <?
        > > putenv('GDFONTP ATH=f:\swd\font ');
        > > $font = "f:/swd/font/arial.ttf";
        > > $im = imagecreate (250, 28);
        > > $black = ImageColorAlloc ate ($im, 0, 0, 0);
        > > $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
        > > ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font,
        > > "comming text or not?");
        > > ImagePNG($im,te st.png);
        > >
        > > ?>
        > > <img src="test.png" alt="image">
        > >
        > > but I allway get error about not finding font ..
        > >
        > > what should I do?
        > >[/color]
        >
        > I hate that bug. I got mine to work on Windows and Linux by only giving it
        > the font name (it adds .ttf by itself) and by using realpath().
        >
        > Create a folder called "font" where your script is, and put your font there.
        >
        > <?
        >
        > $fontpath = realpath('./font/');
        > putenv('GDFONTP ATH='.$fontpath );
        > $font = "arial";[/color]


        Thanx you very mutch! it worked like a rolex! hehe
        that was a nasty bug... and with bad documentation, according php.net
        it should by enought to point with absolut path..

        enyway, thank you!




        [color=blue]
        > $im = imagecreate (250, 28);
        > $black = ImageColorAlloc ate ($im, 0, 0, 0);
        > $yellow = ImageColorAlloc ate ($im, 235, 235, 51);
        > ImageTTFText ($im, 20, 0, 10, 20, $yellow, $font, "comming text or not?");
        > ImagePNG($im,te st.png);
        > ?>
        >
        > <img src="test.png" alt="image">
        >
        > I hope this works for you...[/color]

        Comment

        Working...