freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Freetype] Caching glyph metrics


From: Mark Storer
Subject: RE: [Freetype] Caching glyph metrics
Date: Wed, 17 Apr 2002 16:27:21 -0700

I'm not sure about most of that sutff, but LinearHoriAdvance width I have
some experience with...

Advance width is expressed in font space, which is the same regardless of
point size.  It IS, however, different based on the type of font you're
dealing with.  This difference is stored in FT_Face_Rec's "units_per_EM",
and is either 1000 (for T1) or 2048 (for TT and OT).  To calculate the
advance width of a given character in points, you use the equation:

points_advance = linearHoriAdvance * point_size / units_per_EM

So if a t1 character had a linearAdvance of 500, then at 12 points, that
character would advance the text origin by 6 points.

PS: The Acrobat SDK presents all widths in terms of 1000 units per EM... so
moving from that to FT was a little confusing (though I've since gone back
to the Acrobat SDK for various reasons).  And PDF's expect all entries in
the widths array to be integers in "1000 units per EM", so you may have to
do some converting, depending on the font.

--Mark Storer
  Software Engineer
  Cardiff Software

#include <disclaimer>
typedef std::disclaimer<Cardiff> Discard;


-----Original Message-----
From: Michael Day [mailto:address@hidden
Sent: Wednesday, April 17, 2002 4:16 PM
To: address@hidden
Subject: Re: [Freetype] Caching glyph metrics



Hi David,

> Yes. There are several reasons:

...

>   - to encourage application developers to realize that they
>     should not use it to perform text layout naively.

Ah. I think this is what I am doing :)

>     and if you want to be WYSIWYG, you should only use them
>     to compute line lengths, use the hinted metrics to
>     compute glyph placement on the line, while adjusting
>     inter-word or even inter-letter spacing to correct for
>     any difference between the hinted and linear line width..

Hmm. So, please correct me if I'm wrong:

 - linearHoriAdvance is the advance width of the glyph if rendered on a 
very very very high (infinite?) resolution device

 - on a screen at 96dpi, the width may be different, as hinting may make
an 'm' wider to fit all three stems, for example

 - so using linearHoriAdvance to calculate glyph placement on a 96dpi 
screen (particularly for small text?) could result in glyphs partially 
overlapping or spaced too far apart

 - but if you use only the hinted glyph metrics for layout, you will get
different results for different output resolutions (like Word).

 - as the only glyph that can be transparently stretched is space, your 
solution is to use the hinted glyph metrics for layout, but stretch or 
shrink spaces to compensate for the difference between the hinted metrics 
and linearHoriAdvance. This way the text should look good even at low 
resolutions, but still have the same layout regardless of the resolution

Is that right? It sounds pretty clever, although I can't help wondering
what happens if-there-is-a-big-string-of-words-with-no-spaces :)

One last question: if you are performing layout for a PDF file, you would
use the unhinted glyph metrics exclusively?

Michael


_______________________________________________
Freetype mailing list
address@hidden
http://www.freetype.org/mailman/listinfo/freetype



reply via email to

[Prev in Thread] Current Thread [Next in Thread]