[HarfBuzz] patch for kerning problem

Simon Hausmann simon.hausmann at trolltech.com
Mon Apr 2 04:02:59 PDT 2007


Hi,

I have noticed one ugly problem when applying kerning through OpenType with 
Harfbuzz. For example when shaping the string "Tex" with DejaVu at say 12 
points the "T" and the "e" are nicely kerned together. However as soon as the 
string changes to for example "QTex" the kerning between the "T" and the "e" 
disappears for no apparent reason.

Well, I just dug into it and I think I've found the reason. It appears that 
the coverage table for the first glyph Pair Adjustment Positioning subtable 
has an entry for "Q" as well as for "T". So when we're at the "QT" pair we 
find "Q" in the coverage table, increment buffer->in_pos and check if we have 
a value record for the second glyph pointed at by buffer->in_pos. That is 
certainly the case for "Te", but it is not the case for "QT" and we return. 
However buffer->in_pos points at the second glyph now and the caller 
(Do_String_Lookup) advances buffer->in_pos once more if we return 
Not_Covered. Therefore we skip the lookup of "T" for the "Te" pair and thus 
never kern that pair.

The patch below tries to correct this in Lookup_PairPos. Anybody up for a 
patch review? :)


Simon

--- harfbuzz-gpos.c
+++ harfbuzz-gpos.c
@@ -1652,6 +1652,12 @@ static FT_Error  Lookup_PairPos( GPOS_Instance*    gpi,
     return HB_Err_Invalid_GPOS_SubTable_Format;
   }

+  /* if we don't have coverage for the second glyph don't skip it for
+     further lookups but reset in_pos back to the first_glyph and let
+     the caller in Do_String_Lookup increment in_pos */
+  if ( error == HB_Err_Not_Covered )
+      buffer->in_pos = first_pos;
+
   /* adjusting the `next' glyph */

   if ( pp->ValueFormat2 )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20070402/d51a6400/attachment.pgp>


More information about the HarfBuzz mailing list