[cairo] [cairo-commit] 8 commits - src/cairo-fixed-private.h src/cairo-paginated-surface.c src/cairo-quartz-surface.c src/cairo-win32-font.c src/cairo-win32-printing-surface.c

Vladimir Vukicevic vladimir at pobox.com
Tue Nov 27 12:43:44 PST 2007


On Nov 20, 2007, at 4:36 PM, Adrian Johnson wrote:

>> commit 0901b83ca56e197d5c96d71ab8cfe53f21b4c8bb
>> Author: Vladimir Vukicevic <vladimir at pobox.com>
>> Date:   Tue Nov 6 15:49:57 2007 -0800
>>
>>    [win32] Don't use GetGlyphOutline on non-TrueType fonts
>>
>>    win32-glyph-metrics.patch: GetGlyphOutline only works on  
>> Truetype fonts,
>>    so for non-Truetype fonts, assume no left or right bearing and  
>> use the
>>    font ascent and descent for the glyph extents.
>>
>> diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
>> index dbabbef..7d4a10c 100644
>> --- a/src/cairo-win32-font.c
>> +++ b/src/cairo-win32-font.c
>> @@ -99,6 +99,7 @@ typedef struct {
>>     HFONT scaled_hfont;
>>     HFONT unscaled_hfont;
>>
>> +    cairo_bool_t is_truetype;
>>     cairo_bool_t glyph_indexing;
>>
>>     cairo_bool_t delete_scaled_hfont;
>> @@ -741,11 +742,11 @@ _cairo_win32_scaled_font_set_metrics  
>> (cairo_win32_scaled_font_t *scaled_font)
>>
>>     }
>>
>> -    if ((metrics.tmPitchAndFamily & TMPF_TRUETYPE) ||
>> -        (GetFontData (hdc, OPENTYPE_CFF_TAG, 0, NULL, 0) !=  
>> GDI_ERROR))
>> -        scaled_font->glyph_indexing = TRUE;
>> -    else
>> -        scaled_font->glyph_indexing = FALSE;
>> +    scaled_font->is_truetype = (metrics.tmPitchAndFamily &  
>> TMPF_TRUETYPE) != 0;
>> +    scaled_font->glyph_indexing = scaled_font->is_truetype ||
>> +	(GetFontData (hdc, OPENTYPE_CFF_TAG, 0, NULL, 0) != GDI_ERROR);
>> +    // XXX in what situations does this OPENTYPE_CFF thing not  
>> have the
>> +    // TMPF_TRUETYPE flag? GetFontData says it only works on  
>> Truetype fonts...
>
> GetFontData also works with OpenType and Type 1 fonts. I have found  
> that in general
> any win32 function that says TrueType only means TrueType/OpenType/ 
> Type 1. The one
> difference is that only TrueType and OpenType fonts use glyph  
> indexing while Type 1
> fonts do not.
>
> The original code above is testing to see if the font is a TrueType  
> or OpenType to
> ensure that glyph indexing is used with functions like  
> GetGlyphOutline. Testing
> tmPitchAndFamily for the presence of the TMPF_TRUETYPE flag is an  
> easy way to test
> for TrueType fonts. However this flag is not set for OpenType fonts  
> with PostScript
> outlines. GetFontData() is called to check for the presence of the  
> CFF table which
> is unique to OpenType fonts with PostScript outlines.
>
> When I originally wrote that code I first tried using just a call to
> GetFontData(hdc, 0, 0, NULL, 0) to test for both TrueType and  
> OpenType fonts however
> this was succeeding for Type 1 fonts as well because calling  
> GetFontData() with the
> table set to zero is an undocumented way to retrieve a Type 1 font.
>
> What font types was the code failing on? OpenType, Type 1, bitmap?   
> If it is bitmap
> fonts that are failing you can test tmPitchAndFamily for TMPF_VECTOR  
> to determine
> whether the font is bitmap or vector.

I'm pretty sure the issue was bitmap fonts -- the original patch came  
from Robert O'Callahan, so he should be able to confirm that.  (Looks  
like I screwed up the GIT commit env vars and didn't get his name on  
the commit).  I'm not sure what the end result is supposed to be; is  
the following correct?

Bitmap Fonts - no glyph indexing, no outlines available
TrueType, OpenType (Both TT and PS outlines) - glyph indexing, outlines
Type 1 - outlines, not sure about glyph indexing? (I think no glyph  
indexing?)

     - Vlad



More information about the cairo mailing list