[cairo] Text scaling and hinting

Bill Spitzak spitzak at d2.com
Wed May 4 20:27:36 PDT 2005


I think there is some confusion about my proposal. I don't want to turn 
off hinting. What I am proposing is that all hinting (at least the parts 
that affect letter width and positioning) is done as though 1 unit in 
the CTM is one pixel.

You would "turn off hinting" by selecting a very large font transform 
and a scaled down CTM, thus making the "pixels" that control the hinting 
too small to have any effect.

You can also get interesting and funky output by making a very tiny font 
and blowing it up with the CTM. At least with FreeType this lets you see 
the resulting hinted shapes.

The idea is that when animating, there probably is a particular size 
that the text will be at most of the time, and you want to draw it best 
at that size, and use the same dimensions for all other frames. This 
means hinting must be left on while animating but should not change.

Owen Taylor wrote:
> On Wed, 2005-05-04 at 12:15 -0700, Bill Spitzak wrote:
> 
>>I know there is some disagreement, but I still think the font metricies 
>>should *only* depend on the font transformation matrix. The CTM has 
>>absolutely zero effect. This also means that font metricies are by 
>>definition in the current coordinate space.
>>
>>This would solve your rotated example as you would only rotate by using 
>>the CTM and thus the font metricies would never change.
>>
>>The font metricies should be designed to be correct if the CTM is the 
>>identity. It is ok if the actual rendering leaks outside the bounding 
>>box somewhat if the CTM is rotated, scaled, or translated to a 
>>non-integer. Any hinting should be calculated as though 1 unit is a 
>>pixel. Any other distortions (ie changing the shape of letters depending 
>>on the size) should be calculated as though 1 unit is 1/96 of an inch.
>>
>>I have done some work with using FreeType to produce animated lettering 
>>and it is absolutely vital to have the no-change-of-metricies effect he 
>>is requesting, not just for rotations, but also for scaling. Without 
>>this it is impossible to achieve an attractive animation. In our 
>>software if you set the font size very small and set the transformation 
>>to scale up a lot, you get funky shaped letters, because  you are 
>>scaling up the hinting. But this is actually the effect we want.
> 
> 
> If you are happy with ugly spacing, then sure, using unhinted
> metrics can work. (Especially with a monospace font, what you'll see is
> that some sizes have OK spacing, and other sizes have horrible spacing)
> 
> It's not the right approach for static text display, however. To
> dig out the example I always use, compare Figure 6 in 
> 
>  http://people.redhat.com/otaylor/grid-fitting/ 
> 
> with Figure 4 or Figure 7.
> 
> The relative utility of the 4 elements of the 
>  {glyph-hinting, no-glyph-hinting} x {metric-hinting, no-metric-hinting}
> matrix is something that can be debated at some length. if you really
> want good animation however, then you want no-glyph-hinting, no-metric-
> hinting *and* subpixel glyph positioning. Without the last, you'll see
> substantial jitter of individual characters as you animate.
> 
> Regards,
> 						Owen



More information about the cairo mailing list