/*
- * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved
+ * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
*/
#include "LETypes.h"
#include "LEScripts.h"
#include "LELanguages.h"
+#include "LESwaps.h"
#include "LayoutEngine.h"
#include "ArabicLayoutEngine.h"
#include "ThaiLayoutEngine.h"
#include "TibetanLayoutEngine.h"
#include "GXLayoutEngine.h"
+#include "GXLayoutEngine2.h"
+
#include "ScriptAndLanguageTags.h"
#include "CharSubstitutionFilter.h"
/* Leave this copyright notice here! It needs to go somewhere in this library. */
static const char copyright[] = U_COPYRIGHT_STRING;
-const le_int32 LayoutEngine::kTypoFlagKern = 0x1;
-const le_int32 LayoutEngine::kTypoFlagLiga = 0x2;
+/* TODO: remove these? */
+const le_int32 LayoutEngine::kTypoFlagKern = LE_Kerning_FEATURE_FLAG;
+const le_int32 LayoutEngine::kTypoFlagLiga = LE_Ligatures_FEATURE_FLAG;
const LEUnicode32 DefaultCharMapper::controlChars[] = {
0x0009, 0x000A, 0x000D,
static const le_int32 canonFeatureMapCount = LE_ARRAY_SIZE(canonFeatureMap);
-LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance,
- le_int32 scriptCode,
- le_int32 languageCode,
+LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance,
+ le_int32 scriptCode,
+ le_int32 languageCode,
le_int32 typoFlags,
LEErrorCode &success)
: fGlyphStorage(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode),
{
if (LE_FAILURE(success)) {
return;
- }
+ }
fGlyphStorage = new LEGlyphStorage();
if (fGlyphStorage == NULL) {
if (canonGSUBTable->coversScript(scriptTag)) {
CharSubstitutionFilter *substitutionFilter = new CharSubstitutionFilter(fFontInstance);
- if (substitutionFilter == NULL) {
+ if (substitutionFilter == NULL) {
success = LE_MEMORY_ALLOCATION_ERROR;
return 0;
}
for (p = 0; p < glyphCount; p += 1) {
float next, xAdvance;
-
+
glyphStorage.getGlyphPosition(p + 1, next, ignore, success);
xAdvance = next - prev;
for (p = 0; p < charCount; p += 1, c += direction) {
float next, xAdvance;
-
+
glyphStorage.getGlyphPosition(p + 1, next, ignore, success);
xAdvance = next - prev;
if (fGlyphStorage->getGlyphCount() > 0) {
fGlyphStorage->reset();
}
-
+
glyphCount = computeGlyphs(chars, offset, count, max, rightToLeft, *fGlyphStorage, success);
positionGlyphs(*fGlyphStorage, x, y, success);
adjustGlyphPositions(chars, offset, count, rightToLeft, *fGlyphStorage, success);
{
fGlyphStorage->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;
+ static const le_uint32 morxTableTag = LE_MORX_TABLE_TAG;
if (LE_FAILURE(success)) {
return NULL;
break;
}
} else {
- const MorphTableHeader *morphTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
-
- if (morphTable != NULL) {
- result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, morphTable, success);
+ MorphTableHeader2 *morxTable = (MorphTableHeader2 *)fontInstance->getFontTable(morxTableTag);
+ if (morxTable != NULL) {
+ result = new GXLayoutEngine2(fontInstance, scriptCode, languageCode, morxTable, typoFlags, success);
} else {
- switch (scriptCode) {
- case bengScriptCode:
- case devaScriptCode:
- case gujrScriptCode:
- case kndaScriptCode:
- case mlymScriptCode:
- case oryaScriptCode:
- case guruScriptCode:
- case tamlScriptCode:
- case teluScriptCode:
- case sinhScriptCode:
- {
- result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
- break;
- }
-
- case arabScriptCode:
- //case hebrScriptCode:
- result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
- break;
-
- //case hebrScriptCode:
- // return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
-
- case thaiScriptCode:
- result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
- break;
-
- case hangScriptCode:
- result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
- break;
-
- default:
- result = new LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
- break;
+ const MorphTableHeader *mortTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
+ if (mortTable != NULL) { // mort
+ result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, mortTable, success);
+ } else {
+ switch (scriptCode) {
+ case bengScriptCode:
+ case devaScriptCode:
+ case gujrScriptCode:
+ case kndaScriptCode:
+ case mlymScriptCode:
+ case oryaScriptCode:
+ case guruScriptCode:
+ case tamlScriptCode:
+ case teluScriptCode:
+ case sinhScriptCode:
+ {
+ result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
+ break;
+ }
+
+ case arabScriptCode:
+ //case hebrScriptCode:
+ result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
+ break;
+
+ //case hebrScriptCode:
+ // return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
+
+ case thaiScriptCode:
+ result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
+ break;
+
+ case hangScriptCode:
+ result = new HangulOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
+ break;
+
+ default:
+ result = new LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success);
+ break;
+ }
}
}
}