jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp
changeset 7486 6a36b1ebc620
parent 5506 202f599c92aa
child 16891 91e99bed64ae
--- a/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp	Sun Dec 05 15:51:31 2010 +0300
+++ b/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp	Mon Dec 06 16:10:01 2010 -0800
@@ -101,7 +101,10 @@
             valueRecord2->adjustPosition(SWAPW(valueFormat2), (char *) this, *glyphIterator, fontInstance);
         }
 
-        return 2;
+        // back up glyphIterator so second glyph can be
+        // first glyph in the next pair
+        glyphIterator->prev();
+        return 1;
     }
 
     return 0;
@@ -137,7 +140,10 @@
             valueRecord2->adjustPosition(SWAPW(valueFormat2), (const char *) this, *glyphIterator, fontInstance);
         }
 
-        return 2;
+        // back up glyphIterator so second glyph can be
+        // first glyph in the next pair
+        glyphIterator->prev();
+        return 1;
     }
 
     return 0;
@@ -145,6 +151,20 @@
 
 const PairValueRecord *PairPositioningFormat1Subtable::findPairValueRecord(TTGlyphID glyphID, const PairValueRecord *records, le_uint16 recordCount, le_uint16 recordSize) const
 {
+#if 1
+        // The OpenType spec. says that the ValueRecord table is
+        // sorted by secondGlyph. Unfortunately, there are fonts
+        // around that have an unsorted ValueRecord table.
+        const PairValueRecord *record = records;
+
+        for(le_int32 r = 0; r < recordCount; r += 1) {
+                if (SWAPW(record->secondGlyph) == glyphID) {
+                        return record;
+                }
+
+                record = (const PairValueRecord *) ((char *) record + recordSize);
+        }
+#else
     le_uint8 bit = OpenTypeUtilities::highBit(recordCount);
     le_uint16 power = 1 << bit;
     le_uint16 extra = (recordCount - power) * recordSize;
@@ -168,6 +188,7 @@
     if (SWAPW(record->secondGlyph) == glyphID) {
         return record;
     }
+#endif
 
     return NULL;
 }