Re: Ligatures and Pango?



On Tue, 2005-11-29 at 02:20 +0100, Han-Wen Nienhuys wrote:
> Behdad Esfahbod wrote:
> >>I noticed that LilyPond doesn't do kerning automatically; for a
> >>PangoGlyphString,  we just do
> >>
> >>   PGIX PGIY rmoveto GLYPHNAME glyphshow
> >>
> >>for each glyph (PGIX = PangoGlyphInfo->PangoGlyphGeometry.x) I thought
> >>kerning would be put into PGIX. I tried doing
> > 
> >
> > Yeah, that's the plan.  The shaper adjusts PGIX to do kerning.
> > 
> 
> Then how come that Gedit does do kerning for the same text? Is it a 
> setting that I should switch on in Pango somewhere?

Actually the representation of the kerning is in the *width* field
of PangoGlyphGeometry, not the x_ofset/y_offset fields. 
The x_offset/y_offset fields are not cumulative, so wouldn't work for
kerning -- you'd need to add more and more adjustment to the x as you
went along in the string.

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

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. 

Regards,
						Owen
  




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