note 74206 added to function.imagefttext

From: Date: Thu, 29 Mar 2007 21:51:50 +0000
Subject: note 74206 added to function.imagefttext
Groups: php.notes 
Request: Send a blank email to php-notes+get-124932@lists.php.net to get a copy of this message
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> ---- Server IP: 194.145.210.4 Probable Submitter: 80.5.160.8 (proxied: 82.12.151.83) ---- Manual Page -- http://www.php.net/manual/en/function.imagefttext.php Edit -- https://master.php.net/note/edit/74206 Del: integrated -- https://master.php.net/note/delete/74206/integrated Del: useless -- https://master.php.net/note/delete/74206/useless Del: bad code -- https://master.php.net/note/delete/74206/bad+code Del: spam -- https://master.php.net/note/delete/74206/spam Del: non-english -- https://master.php.net/note/delete/74206/non-english Del: in docs -- https://master.php.net/note/delete/74206/in+docs Del: other reasons-- https://master.php.net/note/delete/74206 Reject -- https://master.php.net/note/reject/74206 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124932) next »