summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-4.2.1-PATCHES/patch-60-KernPair
blob: 983f0d685cf4586ef84fc905c28b13207cad6b57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff -ur icu-4.2.1.orig/source/layout/LEFontInstance.cpp icu-4.2.1/source/layout/LEFontInstance.cpp
--- icu-4.2.1.orig/source/layout/LEFontInstance.cpp	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/LEFontInstance.cpp	2009-10-23 00:16:48.000000000 +0200
@@ -145,5 +145,10 @@
     return getAscent() + getDescent() + getLeading();
 }
 
+void LEFontInstance::getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const
+{
+    kern.fX = kern.fY = 0;
+}
+
 U_NAMESPACE_END
 
diff -ur icu-4.2.1.orig/source/layout/LEFontInstance.h icu-4.2.1/source/layout/LEFontInstance.h
--- icu-4.2.1.orig/source/layout/LEFontInstance.h	2009-10-23 00:14:44.000000000 +0200
+++ icu-4.2.1/source/layout/LEFontInstance.h	2009-10-23 00:16:48.000000000 +0200
@@ -510,6 +510,11 @@
     static UClassID getStaticClassID();
 
     /**
+     * Returns kern value for a glyph pair, if the font has a kern pair list.
+     */
+    virtual void getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const;
+
+    /**
      * Returns true if writing direction is vertical.
      */
     virtual inline bool getLayoutDirVertical() const;
diff -ur icu-4.2.1.orig/source/layout/LayoutEngine.cpp icu-4.2.1/source/layout/LayoutEngine.cpp
--- icu-4.2.1.orig/source/layout/LayoutEngine.cpp	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/LayoutEngine.cpp	2009-10-23 00:16:48.000000000 +0200
@@ -369,9 +369,25 @@
 
     if (fTypoFlags & 0x1) { /* kerning enabled */
       static const le_uint32 kernTableTag = LE_KERN_TABLE_TAG;
-
-      KernTable kt(fFontInstance, getFontTable(kernTableTag));
-      kt.process(glyphStorage);
+      const void* kernTableData = getFontTable(kernTableTag);
+      if (kernTableData != NULL) {
+        KernTable kt(fFontInstance, kernTableData);
+        kt.process(glyphStorage);
+      }
+      else { /* no 'kern' table, but the font might know kern pairs from an AFM file, for instance */
+        float xAdjust = 0.0, yAdjust = 0.0;
+        LEGlyphID leftGlyph = glyphStorage.getGlyphID(0, success);
+        for (le_int32 i = 1; i < glyphStorage.getGlyphCount(); ++i) {
+          LEGlyphID rightGlyph = glyphStorage.getGlyphID(i, success);
+          LEPoint   kern;
+          fFontInstance->getKernPair(leftGlyph, rightGlyph, kern);
+          xAdjust += fFontInstance->xUnitsToPoints(kern.fX);
+          yAdjust += fFontInstance->yUnitsToPoints(kern.fY);
+          glyphStorage.adjustPosition(i, xAdjust, yAdjust, success);
+          leftGlyph = rightGlyph;
+        }
+        glyphStorage.adjustPosition(glyphStorage.getGlyphCount(), xAdjust, yAdjust, success);
+      }
     }
 
     // default is no adjustments