ICU-2252 add kerning, add 'typoFlags' to layout engine constructors

X-SVN-Rev: 17129
This commit is contained in:
Doug Felt 2005-01-14 19:22:53 +00:00
parent 4a800c38fa
commit 2b4337c536
19 changed files with 358 additions and 53 deletions

View File

@ -34,14 +34,15 @@ le_bool CharSubstitutionFilter::accept(LEGlyphID glyph) const
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ArabicOpenTypeLayoutEngine)
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable)
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
/**/ fFeatureOrder = ArabicShaping::getFeatureOrder();
}
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode)
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
// fFeatureOrder = ArabicShaping::getFeatureOrder();
}
@ -105,8 +106,8 @@ void ArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], l
}
}
UnicodeArabicOpenTypeLayoutEngine::UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode)
UnicodeArabicOpenTypeLayoutEngine::UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fGSUBTable = (const GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
fGDEFTable = (const GlyphDefinitionTableHeader *) CanonShaping::glyphDefinitionTable;

View File

@ -44,12 +44,12 @@ public:
*
* @see LayoutEngine::layoutEngineFactory
* @see OpenTypeLayoutEngine
* @see ScriptAndLangaugeTags.h for script and language codes
* @see ScriptAndLanguageTags.h for script and language codes
*
* @internal
*/
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable);
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
@ -60,11 +60,12 @@ public:
* @param langaugeCode - the language
*
* @see OpenTypeLayoutEngine
* @see ScriptAndLangaugeTags.h for script and language codes
* @see ScriptAndLanguageTags.h for script and language codes
*
* @internal
*/
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.
@ -164,7 +165,8 @@ public:
*
* @internal
*/
UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.

View File

@ -17,7 +17,7 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(GXLayoutEngine)
GXLayoutEngine::GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const MorphTableHeader *morphTable)
: LayoutEngine(fontInstance, scriptCode, languageCode), fMorphTable(morphTable)
: LayoutEngine(fontInstance, scriptCode, languageCode, 0), fMorphTable(morphTable)
{
// nothing else to do?
}

View File

@ -19,8 +19,8 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable)
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
// nothing else to do...
}

View File

@ -47,7 +47,7 @@ public:
* @internal
*/
HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable);
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**

View File

@ -25,14 +25,14 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicOpenTypeLayoutEngine)
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable), fMPreFixups(NULL)
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable), fMPreFixups(NULL)
{
fFeatureOrder = IndicReordering::getFeatureOrder();
}
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode), fMPreFixups(NULL)
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fMPreFixups(NULL)
{
fFeatureOrder = IndicReordering::getFeatureOrder();
}

View File

@ -55,7 +55,7 @@ public:
* @internal
*/
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable);
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
@ -70,7 +70,8 @@ public:
*
* @internal
*/
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.

View File

@ -0,0 +1,190 @@
/*
* @(#)KernTable.cpp 1.1 04/10/13
*
* (C) Copyright IBM Corp. 2004 - All Rights Reserved
*
*/
#include "KernTable.h"
#include "LESwaps.h"
#include <stdio.h>
#define DEBUG 0
struct PairInfo {
le_uint32 key; // sigh, MSVC compiler gags on union here
le_int16 value; // fword, kern value in funits
};
#define KERN_PAIRINFO_SIZE 6
struct Subtable_0 {
le_uint16 nPairs;
le_uint16 searchRange;
le_uint16 entrySelector;
le_uint16 rangeShift;
};
#define KERN_SUBTABLE_0_HEADER_SIZE 8
// Kern table version 0 only
struct SubtableHeader {
le_uint16 version;
le_uint16 length;
le_uint16 coverage;
};
#define KERN_SUBTABLE_HEADER_SIZE 6
// Version 0 only, version 1 has different layout
struct KernTableHeader {
le_uint16 version;
le_uint16 nTables;
};
#define KERN_TABLE_HEADER_SIZE 4
#define COVERAGE_HORIZONTAL 0x1
#define COVERAGE_MINIMUM 0x2
#define COVERAGE_CROSS 0x4
#define COVERAGE_OVERRIDE 0x8
KernTable::KernTable(const LEFontInstance* font, const void* tableData)
: pairs(0), font(font)
{
const KernTableHeader* header = (const KernTableHeader*)tableData;
if (header == 0) {
#if DEBUG
fprintf(stderr, "no kern data\n");
fflush(stderr);
#endif
return;
}
#if DEBUG
// dump first 32 bytes of header
for (int i = 0; i < 64; ++i) {
fprintf(stderr, "%0.2x ", ((const char*)tableData)[i]&0xff);
if (((i+1)&0xf) == 0) {
fprintf(stderr, "\n");
} else if (((i+1)&0x7) == 0) {
fprintf(stderr, " ");
}
}
fflush(stderr);
#endif
if (header->version == 0 && SWAPW(header->nTables) > 0) {
const SubtableHeader* subhead = (const SubtableHeader*)((char*)tableData + KERN_TABLE_HEADER_SIZE);
if (subhead->version == 0) {
coverage = SWAPW(subhead->coverage);
if (coverage & COVERAGE_HORIZONTAL) { // only handle horizontal kerning
const Subtable_0* table = (const Subtable_0*)((char*)subhead + KERN_SUBTABLE_HEADER_SIZE);
nPairs = SWAPW(table->nPairs);
searchRange = SWAPW(table->searchRange);
entrySelector = SWAPW(table->entrySelector);
rangeShift = SWAPW(table->rangeShift);
pairs = (const PairInfo*)((char*)table + KERN_SUBTABLE_0_HEADER_SIZE);
#if DEBUG
fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairs);
fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift);
fflush(stderr);
{
// dump part of the pair list
char ids[256];
for (int i = 256; --i >= 0;) {
LEGlyphID id = font->mapCharToGlyph(i);
if (id < 256) {
ids[id] = (char)i;
}
}
const PairInfo* p = pairs;
for (i = 0; i < nPairs; ++i, p = (const PairInfo*)((char*)p+KERN_PAIRINFO_SIZE)) {
le_uint32 k = SWAPL(p->key);
le_uint16 left = (k >> 16) & 0xffff;
le_uint16 right = k & 0xffff;
if (left < 256 && right < 256) {
char c = ids[left];
if (c > 0x20 && c < 0x7f) {
fprintf(stderr, "%c/", c & 0xff);
} else {
fprintf(stderr, "%0.2x/", c & 0xff);
}
c = ids[right];
if (c > 0x20 && c < 0x7f) {
fprintf(stderr, "%c ", c & 0xff);
} else {
fprintf(stderr, "%0.2x ", c & 0xff);
}
}
}
fflush(stderr);
}
#endif
}
}
}
}
/*
* Process the glyph positions. The positions array has two floats for each
* glyph, plus a trailing pair to mark the end of the last glyph.
*/
//void KernTable::process(const LEGlyphID glyphs[], float* positions, le_int32 glyphCount)
void KernTable::process(LEGlyphStorage& storage)
{
if (pairs) {
LEErrorCode success = LE_NO_ERROR;
le_uint32 key = storage[0]; // no need to mask off high bits
float adjust = 0;
for (int i = 1, e = storage.getGlyphCount(); i < e; ++i) {
key = key << 16 | (storage[i] & 0xffff);
// argh, to do a binary search, we need to have the pair list in sorted order
// but it is not in sorted order on win32 platforms because of the endianness difference
// so either I have to swap the element each time I examine it, or I have to swap
// all the elements ahead of time and store them in the font
const PairInfo* p = pairs;
const PairInfo* tp = (const PairInfo*)((char*)p + rangeShift);
if (key > SWAPL(tp->key)) {
p = tp;
}
#if DEBUG
fprintf(stderr, "binary search for %0.8x\n", key);
fflush(stderr);
#endif
le_uint32 probe = searchRange;
while (probe > KERN_PAIRINFO_SIZE) {
probe >>= 1;
tp = (const PairInfo*)((char*)p + probe);
le_uint32 tkey = SWAPL(tp->key);
#if DEBUG
fprintf(stdout, " %.3d (%0.8x)\n", ((char*)tp - (char*)pairs)/KERN_PAIRINFO_SIZE, tkey);
fflush(stdout);
#endif
if (tkey <= key) {
if (tkey == key) {
le_int16 value = SWAPW(tp->value);
#if DEBUG
fprintf(stdout, "binary found kerning pair %x:%x at %d, value: 0x%x (%g)\n",
storage[i-1], storage[i], i, value & 0xffff, font->xUnitsToPoints(value));
fflush(stdout);
#endif
adjust += font->xUnitsToPoints(value);
break;
}
p = tp;
}
}
storage.adjustPosition(i, adjust, 0, success);
}
storage.adjustPosition(storage.getGlyphCount(), adjust, 0, success);
}
}

View File

@ -0,0 +1,46 @@
/*
* @(#)KernTable.h 1.1 04/10/13
*
* (C) Copyright IBM Corp. 2004 - All Rights Reserved
*
*/
#ifndef __KERNTABLE_H
#define __KERNTABLE_H
#ifndef __LETYPES_H
#include "LETypes.h"
#endif
#include "LETypes.h"
#include "LEFontInstance.h"
#include "LEGlyphStorage.h"
#include <stdio.h>
struct PairInfo;
/**
* Windows type 0 kerning table support only for now.
*/
class U_LAYOUT_API KernTable
{
private:
le_uint16 coverage;
le_uint16 nPairs;
const PairInfo* pairs;
const LEFontInstance* font;
le_uint16 searchRange;
le_uint16 entrySelector;
le_uint16 rangeShift;
public:
KernTable(const LEFontInstance* font, const void* tableData);
/*
* Process the glyph positions.
*/
void process(LEGlyphStorage& storage);
};
#endif

View File

@ -19,14 +19,15 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable)
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
fFeatureOrder = KhmerReordering::getFeatureOrder();
}
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode)
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fFeatureOrder = KhmerReordering::getFeatureOrder();
}

View File

@ -57,7 +57,7 @@ public:
* @internal
*/
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable);
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
@ -72,7 +72,8 @@ public:
*
* @internal
*/
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.

View File

@ -28,6 +28,8 @@
#include "DefaultCharMapper.h"
#include "KernTable.h"
U_NAMESPACE_BEGIN
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
@ -114,8 +116,9 @@ static const LETag ccmpFeatureTag = LE_CCMP_FEATURE_TAG;
static const LETag canonFeatures[] = {ccmpFeatureTag, emptyTag};
LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: fGlyphStorage(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode)
LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: fGlyphStorage(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode),
fTypoFlags(typoFlags)
{
fGlyphStorage = new LEGlyphStorage();
}
@ -264,7 +267,7 @@ void LayoutEngine::positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y
}
void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool /*reverse*/,
LEGlyphStorage &/*glyphStorage*/, LEErrorCode &success)
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
@ -275,6 +278,13 @@ void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset
return;
}
if (fTypoFlags & 0x1) { /* kerning enabled */
static le_uint32 kernTableTag = LE_KERN_TABLE_TAG;
KernTable kt(fFontInstance, getFontTable(kernTableTag));
kt.process(glyphStorage);
}
// default is no adjustments
return;
}
@ -406,6 +416,12 @@ void LayoutEngine::reset()
}
LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success)
{
// 3 -> kerning and ligatures
return LayoutEngine::layoutEngineFactory(fontInstance, scriptCode, languageCode, 3, success);
}
LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success)
{
static const le_uint32 gsubTableTag = LE_GSUB_TABLE_TAG;
static const le_uint32 mortTableTag = LE_MORT_TABLE_TAG;
@ -430,11 +446,11 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case guruScriptCode:
case tamlScriptCode:
case teluScriptCode:
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
case arabScriptCode:
result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
case haniScriptCode:
@ -446,24 +462,24 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case zhtLanguageCode:
case zhsLanguageCode:
if (gsubTable->coversScriptAndLanguage(scriptTag, languageTag, TRUE)) {
result = new HanOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new HanOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
// note: falling through to default case.
default:
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
break;
case khmrScriptCode:
result = new KhmerOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new KhmerOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
default:
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
} else {
@ -483,24 +499,24 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case tamlScriptCode:
case teluScriptCode:
{
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
}
case arabScriptCode:
//case hebrScriptCode:
result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
//case hebrScriptCode:
// return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
// return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
case thaiScriptCode:
result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode);
result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
default:
result = new LayoutEngine(fontInstance, scriptCode, languageCode);
result = new LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
}
}

View File

@ -95,6 +95,13 @@ protected:
*/
le_int32 fLanguageCode;
/**
* The typographic control flags
*
* @internal
*/
le_int32 fTypoFlags;
/**
* This constructs an instance for a given font, script and language. Subclass constructors
* must call this constructor.
@ -108,7 +115,7 @@ protected:
*
* @internal
*/
LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
/**
* This overrides the default no argument constructor to make it
@ -438,6 +445,12 @@ public:
*/
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success);
/**
* Override of existing call that provides flags to control typography.
* @draft ICU 3.4
*/
static LayoutEngine *layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typo_flags, LEErrorCode &success);
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*

View File

@ -115,7 +115,8 @@ SingleSubstitutionSubtables.o \
SubstitutionLookups.o \
ValueRecords.o \
KhmerLayoutEngine.o \
KhmerReordering.o
KhmerReordering.o \
KernTable.o
STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O))

View File

@ -35,18 +35,43 @@ static const LETag kernFeatureTag = LE_KERN_FEATURE_TAG;
static const LETag markFeatureTag = LE_MARK_FEATURE_TAG;
static const LETag mkmkFeatureTag = LE_MKMK_FEATURE_TAG;
static const LETag defaultFeatures[] = {ccmpFeatureTag, ligaFeatureTag, cligFeatureTag, kernFeatureTag, markFeatureTag, mkmkFeatureTag, emptyTag};
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};
// kerning (kern, palt following adobe recommendation for cjk 'kerning') but no ligatures.
static const LETag kernFeatures[] = {ccmpFeatureTag, kernFeatureTag, paltFeatureTag,
markFeatureTag, mkmkFeatureTag, emptyTag};
// ligatures (liga, clig) but no kerning. omit dlig for now.
static const LETag ligaFeatures[] = {ccmpFeatureTag, ligaFeatureTag, cligFeatureTag, markFeatureTag,
mkmkFeatureTag, emptyTag};
// kerning and ligatures.
static const LETag kernAndLigaFeatures[] = {ccmpFeatureTag, ligaFeatureTag, cligFeatureTag,
kernFeatureTag, paltFeatureTag, markFeatureTag, mkmkFeatureTag, emptyTag};
OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable)
: LayoutEngine(fontInstance, scriptCode, languageCode), fFeatureList(defaultFeatures), fFeatureOrder(NULL),
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fFeatureList(minimalFeatures), fFeatureOrder(NULL),
fGSUBTable(gsubTable), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL)
{
static const le_uint32 gdefTableTag = LE_GDEF_TABLE_TAG;
static const le_uint32 gposTableTag = LE_GPOS_TABLE_TAG;
const GlyphPositioningTableHeader *gposTable = (const GlyphPositioningTableHeader *) getFontTable(gposTableTag);
// todo: switch to more flags and bitfield rather than list of feature tags?
switch (typoFlags) {
case 0: break; // default
case 1: fFeatureList = kernFeatures; break;
case 2: fFeatureList = ligaFeatures; break;
case 3: fFeatureList = kernAndLigaFeatures; break;
default: break;
}
setScriptAndLanguageTags();
fGDEFTable = (const GlyphDefinitionTableHeader *) getFontTable(gdefTableTag);
@ -65,8 +90,9 @@ void OpenTypeLayoutEngine::reset()
LayoutEngine::reset();
}
OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: LayoutEngine(fontInstance, scriptCode, languageCode), fFeatureOrder(NULL),
OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fFeatureOrder(NULL),
fGSUBTable(NULL), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL)
{
setScriptAndLanguageTags();

View File

@ -65,7 +65,7 @@ public:
* @internal
*/
OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
const GlyphSubstitutionTableHeader *gsubTable);
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
@ -77,7 +77,8 @@ public:
*
* @internal
*/
OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.

View File

@ -17,8 +17,8 @@ U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ThaiLayoutEngine)
ThaiLayoutEngine::ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
: LayoutEngine(fontInstance, scriptCode, languageCode)
ThaiLayoutEngine::ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fErrorChar = 0x25CC;

View File

@ -43,7 +43,7 @@ public:
*
* @internal
*/
ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode);
ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.

View File

@ -232,6 +232,9 @@
<File
RelativePath=".\IndicReordering.cpp">
</File>
<File
RelativePath=".\KernTable.cpp">
</File>
<File
RelativePath=".\KhmerLayoutEngine.cpp">
</File>
@ -452,6 +455,9 @@
<File
RelativePath=".\IndicReordering.h">
</File>
<File
RelativePath=".\KernTable.h">
</File>
<File
RelativePath=".\KhmerLayoutEngine.h">
</File>