GD Library versionen+Richtige Fontdarstellung+imagecreatetruecolor

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • GD Library versionen+Richtige Fontdarstellung+imagecreatetruecolor

    Hallo,

    leider habe ich immer noch mit der richtigen Fontdarstellung zu kämpfen. Ich versuche mal zu schildern.

    Also ich habe GD 2.0+Freetype. Erstelle ich nun einen Button mittels Skript und benutze z.B. Verdana als Schriftart, welche auf meinem Server hinterlegt ist, in Schriftgröße 10 px so muss ich bei meiner GD Version noch px in pt umrechnen.

    Dies ist in meinem Skript so verankert:

    PHP-Code:
    $font_size 10/96*72
    Soweit so gut. Schaue ich mir nun den erstellten Button mit der 10 px Verdana an und stelle einen normalen Text, der in einer Tabelle steht und auch 10 px hat und auch Verdana ist, an so stelle ich fest das die Verdana vom erstellten Button total "verkrüppelt" aussieht. Gleiches habe ich mit Arial und Pixel-Fonts, Antialaias ture und false gemacht. Ohne Erfolg.

    Ich stelle jedoch fest das es geht, siehe
    http://www.dafont.com/en/bitmap.php?page=21&texte=test
    Font: Rix.
    Dort wird offensichtlich auch per Skript diese "Testschrift" erzeugt.
    Leider hat der Webmaster nicht auf meine Frage nach der Version der GD library geantwortet. Ich gehe davon aus das es dort eine andere GD Version ist als 2.0. Liege ich da richtig?

    Wenn ja, so habe ich gesehen das ich bei älteren GD versionen eventuell auf "imagecreatetrueclolor" verzichten muss, was wiederum nicht geht, da ich hires Bilder hochladen muss.

    Wie kann ich also dafür eine Lösung finden. Habe eventuell falsch gecoded? In diesem Fall habe ich unten nochmal das Skrip.

    Ich danke euch im vorraus für eure Antworten.

    PHP-Code:
    <?php
    Header 
    ("Content-type: image/png");

    $font_file="/home/www/htdocs/wmwa.de/html/font/bit.ttf";
    $font_size 10/96*72;
    $max_width 120;
    $angle 0;
    $y_start 12;


    // Create image and allocate colors 
    $im imagecreate(12318);
    $background imagecolorallocate($im115128148);
    $text_color imagecolorallocate($im000);

    // Draw the button 
    imagefilledrectangle($im1112316$background);

    // Position the text
    $line_width imagettfbbox($font_size0$font_file$text);
    $horz_pos = (($max_width $line_width[2] - $line_width[0]) / 1.08);

    // Write the text to the image 
    imagettftext($im$font_size$angle$horz_pos$y_start$text_color$font_file$text);
    imagepng($im);
    imagedestroy($im);
    ?>
    Zuletzt geändert von Hazzardous; 12.07.2004, 13:04.
    The Human Mirror - Mein Blog!
    www.sonicsense.de - The future of music!

  • #2
    Ich hab dein Skript mal mit GD 2.0.15 compatible unter Windows und Font Arial getestet. Sieht wunderbar aus. Auch unterschiedliche Font-Größen sind kein Problem!
    Ich denke, also bin ich.
    Manche sind trotzdem!

    Kommentar


    • #3
      ich habe auch schon die erfahrung gemacht, dass sich die ergebnisse beim einsatz der TTF-funktionen stark voneinander unterscheiden können, auch innerhalb der 2er-versionen der GD-lib.

      die genaue ursache konnte ich auch nicht herausfinden; ist auch schwer zu bestimmen, wo da im zusammenspiel von gd-lib version 2.x und freetype version yz der hase im pfeffer liegt :-/
      I don't believe in rebirth. Actually, I never did in my whole lives.

      Kommentar


      • #4
        Wenn ich mit phpinfo() mir mal alles ausgeben lasse steht bei mir

        GD Version bundled (2.0 compatible)

        steht bei dir 2.0.15?

        Wenn ja, gibt es in diesen beiden unterschiedlichen Versionen änderungen die das behebeben?

        Könntest du dir die Mühe machen und es nocheinmal mit Verdana ausprobieren?

        Das wäre super nett!
        The Human Mirror - Mein Blog!
        www.sonicsense.de - The future of music!

        Kommentar


        • #5
          Bei mir steht 2.0.15 compatible und mit Verdana ist auch wunderwunderschöööönnnn. No probs!
          Ich denke, also bin ich.
          Manche sind trotzdem!

          Kommentar


          • #6
            Hmm, ok... hast du freetype installiert?
            The Human Mirror - Mein Blog!
            www.sonicsense.de - The future of music!

            Kommentar


            • #7
              Original geschrieben von Hazzardous
              Hmm, ok... hast du freetype installiert?
              PHP 4.3.4 auf windows mit freetype!
              Ich denke, also bin ich.
              Manche sind trotzdem!

              Kommentar


              • #8
                Dann werde ich wohl versuchen müssen meinen Provider davon zu überzeugen seine PHP+GD Version mal auf einen neueren Stand zu bringen....
                The Human Mirror - Mein Blog!
                www.sonicsense.de - The future of music!

                Kommentar


                • #9
                  ich glaube kaum, dass dein problem so gelöst wird:
                  aus den usernotes php.net
                  GD 1.x used pixel sizes, GD 2 uses point sizes. Generally this makes people feel that the font is rendered too big.

                  The fact that GD changed from using pixel size to point size shouldn't matter a lot since we render mostly screen images at 72 dpi and there are 72 points in an inch (72,... but it's generally rounded to 72 per inch). This means that in fact we were used to having for example a 10 point size text rendered to 10 pixels.

                  Now in comes GD 2, there we have in gd.h
                  /* resolution affects ttf font rendering, particularly hinting */
                  #define GD_RESOLUTION 96 /* pixels per inch */

                  So this means that for font rendering in GD uses 96 dpi. This means that if you use this like we used to (1 point == 1 pixel) GD 2 will have 1 point == 1 pixel/72 * 96, giving 1,333 pixel per point, rendering our beautifull charts in GD 1.x into ugly ones because all the text is too large now...

                  It took me a while before I found this out (several months of passive searching and since I thought Freetype was at the cause I was looking in the wrong direction...)

                  Now The case is that this thing comes close to a religious thing (Windows PCs use 96 dpi screen resolution, Macs were like using the 72 dpi resolution), fact is that this is still very noticable in my enviroment. I received marked up email from PC/Windows users that is simply to small to read, Word (office in general) documents from a PC that are sent to me are at 75% zoom out, making the text illegible on the mac, so I need to change the zoom factor every time... Verry funny that in this day and age there is such a difference in the very hart of these systems, that they will never be the same )

                  Ok, now for the solution, either change the #define in gd.h or use font sizes of for example 10/96*72 (for a 10 pixel font size).
                  If you use a lot of small text on the images I recon changing the #define is better that entering fractional sizes....
                  ... mit anderen worten, dein provider müsste die gd mit anderen parametern kompilieren (nach meinem verständnis)
                  Kissolino.com

                  Kommentar

                  Lädt...
                  X