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-50.1.orig/source/layout/LEFontInstance.cpp icu-50.1/source/layout/LEFontInstance.cpp
--- icu-50.1.orig/source/layout/LEFontInstance.cpp 2012-11-05 18:18:12.000000000 +0100
+++ icu-50.1/source/layout/LEFontInstance.cpp 2012-11-06 18:19:35.000000000 +0100
@@ -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-50.1.orig/source/layout/LEFontInstance.h icu-50.1/source/layout/LEFontInstance.h
--- icu-50.1.orig/source/layout/LEFontInstance.h 2012-11-06 18:18:07.000000000 +0100
+++ icu-50.1/source/layout/LEFontInstance.h 2012-11-06 18:19:35.000000000 +0100
@@ -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-50.1.orig/source/layout/LayoutEngine.cpp icu-50.1/source/layout/LayoutEngine.cpp
--- icu-50.1.orig/source/layout/LayoutEngine.cpp 2012-11-05 18:18:10.000000000 +0100
+++ icu-50.1/source/layout/LayoutEngine.cpp 2012-11-06 18:19:35.000000000 +0100
@@ -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
|