summaryrefslogtreecommitdiff
path: root/Build
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
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')
-rw-r--r--Build/source/libs/icu-xetex/layout/LEFontInstance.cpp6
-rw-r--r--Build/source/libs/icu-xetex/layout/LEFontInstance.h5
-rw-r--r--Build/source/libs/icu-xetex/layout/LayoutEngine.cpp22
-rw-r--r--Build/source/libs/icu-xetex/layout/OpenTypeLayoutEngine.cpp17
4 files changed, 42 insertions, 8 deletions
diff --git a/Build/source/libs/icu-xetex/layout/LEFontInstance.cpp b/Build/source/libs/icu-xetex/layout/LEFontInstance.cpp
index 0bbb627946f..e36c2a0fc68 100644
--- a/Build/source/libs/icu-xetex/layout/LEFontInstance.cpp
+++ b/Build/source/libs/icu-xetex/layout/LEFontInstance.cpp
@@ -81,5 +81,11 @@ LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *map
return mapCharToGlyph(mappedChar);
}
+
+void LEFontInstance::getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const
+{
+ kern.fX = kern.fY = 0;
+}
+
U_NAMESPACE_END
diff --git a/Build/source/libs/icu-xetex/layout/LEFontInstance.h b/Build/source/libs/icu-xetex/layout/LEFontInstance.h
index d1b4d77e57c..37a6c98cabc 100644
--- a/Build/source/libs/icu-xetex/layout/LEFontInstance.h
+++ b/Build/source/libs/icu-xetex/layout/LEFontInstance.h
@@ -495,6 +495,11 @@ public:
* Returns true if writing direction is vertical.
*/
virtual inline bool getLayoutDirVertical() const;
+
+ /**
+ * 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;
};
inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
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
diff --git a/Build/source/libs/icu-xetex/layout/OpenTypeLayoutEngine.cpp b/Build/source/libs/icu-xetex/layout/OpenTypeLayoutEngine.cpp
index e87afd98ef9..6df05c19312 100644
--- a/Build/source/libs/icu-xetex/layout/OpenTypeLayoutEngine.cpp
+++ b/Build/source/libs/icu-xetex/layout/OpenTypeLayoutEngine.cpp
@@ -29,6 +29,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(OpenTypeLayoutEngine)
static const LETag emptyTag = 0x00000000;
static const LETag ccmpFeatureTag = LE_CCMP_FEATURE_TAG;
+static const LETag loclFeatureTag = LE_LOCL_FEATURE_TAG;
static const LETag ligaFeatureTag = LE_LIGA_FEATURE_TAG;
static const LETag cligFeatureTag = LE_CLIG_FEATURE_TAG;
static const LETag kernFeatureTag = LE_KERN_FEATURE_TAG;
@@ -39,18 +40,18 @@ static const LETag dligFeatureTag = 0x646C6967; // 'dlig' not used at the moment
static const LETag paltFeatureTag = 0x70616C74; // 'palt'
// default has no ligatures, that's what java does. this is the minimal set.
-static const LETag minimalFeatures[] = {ccmpFeatureTag, markFeatureTag, mkmkFeatureTag, emptyTag};
+static const LETag minimalFeatures[] = {ccmpFeatureTag, loclFeatureTag, markFeatureTag, mkmkFeatureTag, emptyTag};
// kerning (kern, palt following adobe recommendation for cjk 'kerning') but no ligatures.
-static const LETag kernFeatures[] = {ccmpFeatureTag, kernFeatureTag, paltFeatureTag,
+static const LETag kernFeatures[] = {ccmpFeatureTag, loclFeatureTag, kernFeatureTag, paltFeatureTag,
markFeatureTag, mkmkFeatureTag, emptyTag};
// ligatures (liga, clig) but no kerning. omit dlig for now.
-static const LETag ligaFeatures[] = {ccmpFeatureTag, ligaFeatureTag, cligFeatureTag, markFeatureTag,
+static const LETag ligaFeatures[] = {ccmpFeatureTag, loclFeatureTag, ligaFeatureTag, cligFeatureTag, markFeatureTag,
mkmkFeatureTag, emptyTag};
// kerning and ligatures.
-static const LETag kernAndLigaFeatures[] = {ccmpFeatureTag, ligaFeatureTag, cligFeatureTag,
+static const LETag kernAndLigaFeatures[] = {ccmpFeatureTag, loclFeatureTag, ligaFeatureTag, cligFeatureTag,
kernFeatureTag, paltFeatureTag, markFeatureTag, mkmkFeatureTag, emptyTag};
@@ -241,8 +242,10 @@ void OpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int3
}
le_int32 glyphCount = glyphStorage.getGlyphCount();
+ if (glyphCount == 0)
+ return;
- if (glyphCount > 0 && fGPOSTable != NULL) {
+ if (fGPOSTable != NULL) {
GlyphPositionAdjustments *adjustments = new GlyphPositionAdjustments(glyphCount);
le_int32 i;
@@ -300,6 +303,10 @@ void OpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int3
delete adjustments;
}
+ else {
+ // if there was no GPOS table, maybe there's non-OpenType kerning we can use
+ LayoutEngine::adjustGlyphPositions(chars, offset, count, reverse, glyphStorage, success);
+ }
#if 0
// Don't know why this is here...