FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Using imagettfbbox with Arial Bold
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Using imagettfbbox with Arial Bold [message #173255 is a reply to message #173254] Thu, 31 March 2011 11:26 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 31/03/2011 9:47, jwcarlton escribió/wrote:
> Technically, it's being set via CSS in a<div>. When it renders on the
> screen, it's actually more like:
>
> <div style="font-family: Arial, Tahoma, Helvetica; font-size: 9pt">
> $variable
> </div>
>
> * Not a copy& paste, so please ignore any typos
>
>
>> The way TTF fonts get rendered is not unique and universal. It depends
>> on the renderer and its settings. What GD2 can tell you (and should be
>> telling you) is the size of the font as rendered by GD2 in that
>> computer. If you want to establish a correct comparison you need to
>> actually draw the font from PHP and grab a screenshot.
>
> I'm not sure that I follow. This is my first attempt with
> imagettfbbox() (and I've only barely used GD, mostly with Perl), so I
> could be wrong, but I thought that this was what the above script did?
>
> Is there a reason that it would be correct with arial.ttf, but not
> arialbd.tff?

I'll try to explain myself better. A font file is basically a collection
of mathematical primitives: a line here, a circle there, that stuff.

If you want to display a letter on a printed document you need a program
that takes those primitives and converts them into instructions for the
printer on how to drop ink on the sheet. If you want to display a letter
on a computer screen you need a program that converts the primitives
into coloured pixels. And there are many possible ways to do that
because random geometrical shapes do not normally map uniquely to pixel
grids. Even in your own PC you'll see that fonts look completely
different if you disable anti-aliasing, or if you optimise it for LCD
panels or CRT monitors.

Your CSS rules are rendered by the browser in the local PC and the
browser can choose to handle the task to the operating system font
libraries or use its own library. GD2 uses whatever version of the
FreeType library is installed on the server.

Why can't you compare GD2 with CSS? Because they use different programs
to render the font, programs that do not even run on the same computer.
Furthermore, you have certain amount control about the server (until you
host upgrades PHP) but zero control about the browser.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Firefox PHP error report
Next Topic: OpenSSL support => disabled (install ext/openssl)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 08:30:56 GMT 2024

Total time taken to generate the page: 0.04739 seconds