Einzelnen Beitrag anzeigen

Reinhard Kern

Registriert seit: 22. Okt 2006
772 Beiträge
 
#3

Re: [PHP] Schriften bändigen

  Alt 13. Jul 2007, 18:34
Zitat von Nuclear-Ping:
Ok, gelöst.

http://forum.de.selfhtml.org/archiv/2006/9/t136870/

Code:
                 $Char = chr ($a);
      $Box = ImageTTFBBox ($Size, 0, $FontPath . $Font, $Char);

      $yvar1 = $Box[5] > $Box[7] ? $Box[5] : $Box[7];
      $yvar2 = $Box[1] < $Box[3] ? $Box[1] : $Box[3];

      // Höhe und Breite des Schriftzeichens berechnen
      $szheight = abs($yvar1 - $yvar2);
      $szwidth = abs($Box[4] - $Box[0]);

                 $pos_x = round ($tmp_x + ($szwidth / 2) - $Box[6], 0);
                 $pos_y = round ($tmp_y - ($szheight / 2) - $Box[5], 0) - round ($szheight / 2);
Hallo,

es ist garnicht nötig, das selbst auszurechnen: die Win32-Funktion SetTextAlign weist Windows an, den Text bzw. Buchstaben mittig zur angegebenen Position zu setzen, wenn für den horizontalen Modus TA_CENTER gewählt wird. So ist die beigefügte Font-Tabelle gedruckt: H = TA_CENTER, V = TA_BASE.

Gruss Reinhard
Angehängte Dateien
Dateityp: pdf ttman_print_test_194.pdf (59,7 KB, 3x aufgerufen)
  Mit Zitat antworten Zitat