[cairo] Text scaling and hinting

Bill Spitzak spitzak at d2.com
Wed May 4 12:15:58 PDT 2005


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.

Robert O'Callahan wrote:
> I'm currently working on having Mozilla draw text through the new Cairo 
> font APIs (the text in my blog screenshot was a hack based on Xft). The 
> new Cairo font APIs have all metrics depending on the current 
> transformation matrix because of hinting effects. That's fine, but we 
> also need the ability to get a cairo_scaled_font_t and render those 
> exact outlines under other transformation matrices.
> 
> One obvious use case is animated rotation/scaling of a multi-line text 
> object. If we allow the metrics to change during the animation, lines 
> might break in different places during the animation, which is probably 
> not what the author wants. Performance would also suffer because we'd 
> have to run our layout algorithm at each and every step of the 
> animation. Alternatively, we could just cross our fingers, hope that the 
> metrics don't change much, and don't rerun the layout algorithm --- but 
> that will lead to glyphs overlapping at the boundaries of text runs, and 
> other ugliness.



More information about the cairo mailing list