Re: Ligatures and Pango?



Owen Taylor wrote:
The correct positioning algorithm for Pango is

 int x = 0;
for (i = 0; i < glyph_string->num_glyphs; i++) {
      PangoGlyph *glyph = &glyph_string->glyphs[i];
      show_glyph(glyph->glyph, x + glyph->geometry.x, glyph->geometry.y);
x += glyph->geometry.width;
   }

So, there are two problems with your code
 A) You are taking the x_offset/y_offset as cumulative, which they aren't.
 B) By using the implicit advance of the current point from glyph_show,
    you are using the natural width of the character instead of the
    kerned width in glyph->geometry.width

This is essentially the same as the other code snippet I posted, which is

  gsave <id> glyphshow grestore <width> 0 rmoveto

Since this doesn't quite work, I must have a scaling error somewhere. I'll investigate.

You could convert a PangoGlyphString to postscript using a separate
moveto for each character, but to make it efficient, you generally want
use xshow or xyshow.

I agree that xshow is better, however using glyphshow frees me of dealing with all the bizarre ways of (re)encoding fonts in PostScript. When libgnomeprint (or its successor) becomes suitable for inclusion in a non-GUI tool, we'll switch to that.

--
 Han-Wen Nienhuys - hanwen xs4all nl - http://www.xs4all.nl/~hanwen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]