[cairo] Two problems with Type 1 fonts

Adrian Johnson ajohnson at redneon.com
Sat Dec 1 03:18:12 PST 2007


Elmar Braun wrote:
> Hi,
> 
> I have two (possibly related) problems with Type 1 fonts. I'm using 
> Cairo 1.4.12 on Windows.
> 
> The first problem is that text output to any surface other than a Win32 
> surface is completely garbled. For example, when I use a Type 1 font to 
> write the string "Type" to a PDF-, SVG- or image surface, the surface 
> will show the string "5ZQF".
> 
> The second issue is that cairo_scaled_font_glyph_extents() doesn't seem 
> to work correctly with Type 1 fonts. When I rely on the results of that 
> function to draw glyphs with cairo_show_glyphs(), the glyph positions 
> are skewed. I think this may be related to the first problem, because 
> the glyph positions seem to be correct for the garbled glyphs that are 
> emitted on non-screen surfaces.

The problem is caused by the GLYPH_INDEX option used with ExtTextOut and
GetGlyphOutline to specify whether glyph indices or unicode is used. In
cairo this option has not been used consistently. The show glyphs function
in win32-surface.c always uses GLYPH_INDEX with the ExtTextOut function. In
win32-font.c the functions for obtaining the extents and glyph outlines (for
embedding in PDF) turns GLYPH_INDEX off for Type 1 fonts.

The text_to_glyphs function in win32-font (used by cairo_show_text()) calls
GetCharacterPlacementW to convert the unicode text to glyph values. When I
checked the glyph values returned by this function the values were the same
as the unicode values.

In my test code I used GetGlyphIndices to perform the conversion. The glyph
values returned by this function appeared to be glyph indices. For example
the glyph values of the text 'T', 'h', 'e', ' ' was 53, 73, 70, 1.

I have not been able to reproduce the exact same problems you are experiencing.
How are you obtaining the glyph indices? Do you have some simple test code
that you can provide?








More information about the cairo mailing list