freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] Caching glyph metrics


From: David Turner
Subject: Re: [Freetype] Caching glyph metrics
Date: Thu, 18 Apr 2002 12:24:36 +0200

Hello Michael,

Michael Day a écrit :
> 
> 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 :)
>
Yes :o)


> >     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
>
Yes, it's the linearly scaled advance width, according to the current
character pixel size, without any hinting. It's also expressed in 16.16
fixed point pixels for greater accuracy (than the default 26.6)

Note that if you want ultra-high accuracy, you should perform the
computation yourself with doubles:

  linear_width = design_width * character_pixel_size / units_per_EM
 
>  - on a screen at 96dpi, the width may be different, as hinting may make
> an 'm' wider to fit all three stems, for example
>
Definitely..
 
>  - 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
>
Yes.. if these glyph images are themselves hinted.
 
>  - but if you use only the hinted glyph metrics for layout, you will get
> different results for different output resolutions (like Word).
>
Definitely !! You'll lose any chance of performing device-independent
layout..
 
>  - 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 :)
>
It is right. If there are no spaces available, you can still resort to
auxiliary tricks like:

  - placing gaps or spaces at critical offsets of the text line (e.g.
    using a binary partition 0.5, 0.25, 0.75, 0.125, 0.375, etc..)

  - using the linear glyph positions directly

  - ignore the issue and display the hinted line anyway (it will
    overlap or miss your margin but one could consider this unimportant
    for such rare cases..)

in all cases, you're going to see something nasty. You just need to
choose the "ugliness" you prefer.
 
> One last question: if you are performing layout for a PDF file, you would
> use the unhinted glyph metrics exclusively?
>
You bet I would :-)


Regards,

- David Turner
- The FreeType Project  (www.freetype.org)



reply via email to

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