summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/layout/LayoutEngine.cpp
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2006-09-07 09:39:18 +0000
committerJonathan Kew <jfkthame@googlemail.com>2006-09-07 09:39:18 +0000
commit9a4cd922ac26125fc6de1f680a8ffca74af04956 (patch)
tree380a5d80d3a0bd7a47b230c040cb3de48fd6189c /Build/source/libs/icu-xetex/layout/LayoutEngine.cpp
parent266d6522d7a65d5ae045b9b1bdc126fc58a2ecfd (diff)
ICU layout patches for xetex: support non-OpenType kerning, enable localized forms by default
git-svn-id: svn://tug.org/texlive/trunk@2092 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu-xetex/layout/LayoutEngine.cpp')
-rw-r--r--Build/source/libs/icu-xetex/layout/LayoutEngine.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/Build/source/libs/icu-xetex/layout/LayoutEngine.cpp b/Build/source/libs/icu-xetex/layout/LayoutEngine.cpp
index 4cd18710d02..eff598cf280 100644
--- a/Build/source/libs/icu-xetex/layout/LayoutEngine.cpp
+++ b/Build/source/libs/icu-xetex/layout/LayoutEngine.cpp
@@ -301,9 +301,25 @@ void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset
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, getFontTable(kernTableTag));
+ 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