[cairo] Scaled fixed size fonts

Fred Kiefer fredkiefer at gmx.de
Tue Jan 14 00:25:04 PST 2014


Hi Behdad,

I hope to find time to write a full example later today. Here a simple way to reproduce the issue. Create a font face for one of the Adobe fixed fonts. Create a scaled font with 12 pixel size. Next create another scaled font from the font face with 24 pixel size use that for drawing. The 12 pixel font will get used, but scaled to 24 pixel.

Fred

On the road

Am 14.01.2014 um 09:12 schrieb Behdad Esfahbod <behdad at behdad.org>:

> Hi,
> 
> Your message is a bit vague in details.  Do you have a simple test case?
> 
> behdad
> 
>> On 14-01-06 03:48 AM, Fred Kiefer wrote:
>> In the GNUstep project we use cairo as our default drawing backend. One
>> user complained that with cairo some fonts get displayed worse than with
>> the direct xlib based backend. It turns out that on this computer only
>> the Adobe fonts are installed and this are fixed size fonts.
>> I investigated a bit in our code and later in the cairo code and this
>> burns down to the function cairo_scaled_font_create() returning not the
>> best suited fixed size font, but a scaled version of the standard 12
>> point font.
>> 
>> The reason is that _cairo_ft_font_face_get_implementation() in
>> cairo-ft-font.c reuses the same resolved font even when the font isn't
>> scalable and the matrix did change. My suggestion now is to extend the
>> tests in this function to first inspect the pattern whether it is
>> scalable. If it isn't, compare the pixel size of the cached resolved
>> font with the new pixel size (This code needs to be extracted from
>> _cairo_ft_resolve_pattern) and if that doesn't match within certain
>> limits (which might be the hard bit to define) the old resolved font
>> gets thrown away and replaced by a newly created one. Or we leave the
>> cached one alone and just create a new one?
>> 
>> This solution will use up more resource than the current one and if
>> there is no better matching fixed pixel font it will result in the same
>> display with a lot more overhead. Still for some cases it will result in
>> better drawn fonts. And for the most common case where scalable fonts
>> get used it will be almost no overhead.
>> 
>> Would cairo be willing to accept a patch in this direction? I am willing
>> to write on, but only if this effort isn't completely wasted.
>> 
>> Fred
> 
> -- 
> behdad
> http://behdad.org/


More information about the cairo mailing list