List Info

Thread: note 74207 added to function.imagefttext




note 74207 added to function.imagefttext
user name
2007-03-29 16:58:18
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:

<?php
/* 100mm x 100mm image */
$imageWidth = 100;
$imageHeight = 100;

/* 300 dpi image, therefore image is 1181 x 1181 pixels */
$imageDPI = 300;

/* unless we do this, text will be about 3 times too small
*/
$realFontSize = ($fontPt * $targetDPI) / 96;
?>
----
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/74207
Del: integrated  -- h
ttps://master.php.net/note/delete/74207/integrated
Del: useless     -- http
s://master.php.net/note/delete/74207/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/74207/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/74207/spam
Del: non-english -- 
https://master.php.net/note/delete/74207/non-english
Del: in docs     -- http
s://master.php.net/note/delete/74207/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74207
Reject      -- https://mast
er.php.net/note/reject/74207
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )