note 74206 deleted from function.imagefttext by bobby
| From: | bobby@php.net | Date: | Sun, 01 Apr 2007 20:15:00 +0000 |
| Subject: | note 74206 deleted from function.imagefttext by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125010@lists.php.net to get a copy of this message | ||
Note Submitter: darren
----
I had trouble working out how to accurately represent fonts in point sizes when constructing charts
that had a user-customisable output DPI (basically, the user could specify the size of the chart in
mm - or any other physical measure - and the DPI to create arbitrarily-sized charts to work properly
in real printed documents).
GD1 was OK as it used pixels for font rendering, but GD2 uses points, which only makes any sense if
you know the DPI that it assumes when rendering text on the image surface. I have not been able to
find this anywhere in this documentation but have examined the GD2 source code and it appears to
assume a DPI of 96 internally. However, this can easily be customised in the GD2 source so it cannot
be assumed that all PHP interpreters out there have a GD2 compiled using 96dpi internally.
If it does, and you are using it to construct images whose target DPI is not 96, you can calculate
the point size to supply to imageftbox() and imagefttext() like this:
<code>
$realFontSize = ($fontPt * $targetDPI) / 96;
</code>