2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* %W% %E%
|
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-11-14 21:22:14 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
2003-04-12 00:37:12 +00:00
|
|
|
#include "LEScripts.h"
|
|
|
|
#include "LELanguages.h"
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
#include "LayoutEngine.h"
|
|
|
|
#include "ArabicLayoutEngine.h"
|
2003-04-12 00:37:12 +00:00
|
|
|
#include "HanLayoutEngine.h"
|
2000-11-14 21:22:14 +00:00
|
|
|
#include "IndicLayoutEngine.h"
|
|
|
|
#include "ThaiLayoutEngine.h"
|
|
|
|
#include "GXLayoutEngine.h"
|
|
|
|
#include "ScriptAndLanguageTags.h"
|
|
|
|
|
|
|
|
#include "OpenTypeUtilities.h"
|
|
|
|
#include "GlyphSubstitutionTables.h"
|
|
|
|
#include "MorphTables.h"
|
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
#include "DefaultCharMapper.h"
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
const LEUnicode32 DefaultCharMapper::controlChars[] = {
|
2000-11-14 21:22:14 +00:00
|
|
|
0x0009, 0x000A, 0x000D,
|
|
|
|
/*0x200C, 0x200D,*/ 0x200E, 0x200F,
|
|
|
|
0x2028, 0x2029, 0x202A, 0x202B, 0x202C, 0x202D, 0x202E,
|
|
|
|
0x206A, 0x206B, 0x206C, 0x206D, 0x206E, 0x206F
|
|
|
|
};
|
|
|
|
|
|
|
|
const le_int32 DefaultCharMapper::controlCharsCount = ARRAY_SIZE(controlChars);
|
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
const LEUnicode32 DefaultCharMapper::mirroredChars[] = {
|
2000-11-14 21:22:14 +00:00
|
|
|
0x0028, 0x0029, // ascii paired punctuation
|
|
|
|
0x003c, 0x003e,
|
|
|
|
0x005b, 0x005d,
|
|
|
|
0x007b, 0x007d,
|
|
|
|
0x2045, 0x2046, // math symbols (not complete)
|
|
|
|
0x207d, 0x207e,
|
|
|
|
0x208d, 0x208e,
|
|
|
|
0x2264, 0x2265,
|
|
|
|
0x3008, 0x3009, // chinese paired punctuation
|
|
|
|
0x300a, 0x300b,
|
|
|
|
0x300c, 0x300d,
|
|
|
|
0x300e, 0x300f,
|
|
|
|
0x3010, 0x3011,
|
|
|
|
0x3014, 0x3015,
|
|
|
|
0x3016, 0x3017,
|
|
|
|
0x3018, 0x3019,
|
|
|
|
0x301a, 0x301b
|
|
|
|
};
|
|
|
|
|
|
|
|
const le_int32 DefaultCharMapper::mirroredCharsCount = ARRAY_SIZE(mirroredChars);
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
LEUnicode32 DefaultCharMapper::mapChar(LEUnicode32 ch) const
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
|
|
|
if (fFilterControls) {
|
2000-12-21 01:18:44 +00:00
|
|
|
le_int32 index = OpenTypeUtilities::search((le_uint32)ch, (le_uint32 *)controlChars, controlCharsCount);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
if (controlChars[index] == ch) {
|
|
|
|
return 0xFFFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fMirror) {
|
2000-12-21 01:18:44 +00:00
|
|
|
le_int32 index = OpenTypeUtilities::search((le_uint32) ch, (le_uint32 *)mirroredChars, mirroredCharsCount);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
if (mirroredChars[index] == ch) {
|
|
|
|
le_int32 mirrorOffset = ((index & 1) == 0) ? 1 : -1;
|
|
|
|
|
|
|
|
return mirroredChars[index + mirrorOffset];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ch;
|
|
|
|
}
|
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
const char LayoutEngine::fgClassID=0;
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode)
|
2000-11-14 21:22:14 +00:00
|
|
|
: fGlyphCount(0), fGlyphs(NULL), fCharIndices(NULL), fPositions(NULL),
|
|
|
|
fFontInstance(fontInstance), fScriptCode(scriptCode), fLanguageCode(languageCode)
|
|
|
|
{
|
|
|
|
// nothing else to do?
|
|
|
|
}
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
void LayoutEngine::getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
le_int32 i;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if LE_FAILURE(success) {
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (charIndices == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (fCharIndices == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
for (i = 0; i < fGlyphCount; i += 1) {
|
|
|
|
charIndices[i] = fCharIndices[i] + indexBase;
|
|
|
|
}
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
2003-06-04 22:39:17 +00:00
|
|
|
void LayoutEngine::getCharIndices(le_int32 charIndices[], LEErrorCode &success) const
|
|
|
|
{
|
|
|
|
if LE_FAILURE(success) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (charIndices == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fCharIndices == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LE_ARRAY_COPY(charIndices, fCharIndices, fGlyphCount);
|
|
|
|
}
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
// Copy the glyphs into caller's (32-bit) glyph array, OR in extraBits
|
2000-12-21 01:18:44 +00:00
|
|
|
void LayoutEngine::getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
|
|
|
le_int32 i;
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (glyphs == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fGlyphs == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
for (i = 0; i < fGlyphCount; i += 1) {
|
|
|
|
glyphs[i] = fGlyphs[i] | extraBits;
|
|
|
|
}
|
2003-06-04 22:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutEngine::getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const
|
|
|
|
{
|
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glyphs == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fGlyphs == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
LE_ARRAY_COPY(glyphs, fGlyphs, fGlyphCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LayoutEngine::getGlyphPositions(float positions[], LEErrorCode &success) const
|
|
|
|
{
|
|
|
|
if LE_FAILURE(success) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (positions == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fPositions == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LE_ARRAY_COPY(positions, fPositions, fGlyphCount * 2 + 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutEngine::getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
|
|
|
|
{
|
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (glyphIndex > fGlyphCount) {
|
|
|
|
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fPositions == NULL) {
|
|
|
|
success = LE_NO_LAYOUT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = fPositions[glyphIndex * 2];
|
|
|
|
y = fPositions[glyphIndex * 2 + 1];
|
|
|
|
}
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
le_int32 LayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
2000-12-21 01:18:44 +00:00
|
|
|
LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
|
|
|
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphs, charIndices, success);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input: glyphs
|
|
|
|
// Output: positions
|
2000-12-21 01:18:44 +00:00
|
|
|
void LayoutEngine::positionGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, float x, float y, float *&positions, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (glyphCount < 0) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
if (positions == NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
positions = LE_NEW_ARRAY(float, 2 * (glyphCount + 1));
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (positions == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
le_int32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < glyphCount; i += 1) {
|
|
|
|
LEPoint advance;
|
|
|
|
|
|
|
|
positions[i * 2] = x;
|
|
|
|
positions[i * 2 + 1] = y;
|
|
|
|
|
|
|
|
fFontInstance->getGlyphAdvance(glyphs[i], advance);
|
|
|
|
x += advance.fX;
|
|
|
|
y += advance.fY;
|
|
|
|
}
|
|
|
|
|
|
|
|
positions[glyphCount * 2] = x;
|
|
|
|
positions[glyphCount * 2 + 1] = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutEngine::adjustMarkGlyphs(const LEGlyphID glyphs[], le_int32 glyphCount, le_bool reverse, LEGlyphFilter *markFilter,
|
2000-12-21 01:18:44 +00:00
|
|
|
float positions[], LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
|
|
|
float xAdjust = 0;
|
|
|
|
le_int32 g = 0, direction = 1;
|
|
|
|
le_int32 p;
|
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (positions == NULL || markFilter == NULL) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
if (reverse) {
|
|
|
|
g = glyphCount - 1;
|
|
|
|
direction = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (p = 0; p < glyphCount; p += 1, g += direction) {
|
|
|
|
float xAdvance = positions[(p + 1) * 2] - positions[p * 2];
|
|
|
|
|
|
|
|
positions[p * 2] += xAdjust;
|
|
|
|
|
|
|
|
if (markFilter->accept(glyphs[g])) {
|
|
|
|
xAdjust -= xAdvance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
positions[glyphCount * 2] += xAdjust;
|
|
|
|
}
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
const void *LayoutEngine::getFontTable(LETag tableTag) const
|
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
return fFontInstance->getFontTable(tableTag);
|
2000-12-21 01:18:44 +00:00
|
|
|
}
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
|
2000-12-21 01:18:44 +00:00
|
|
|
LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (chars == NULL || offset < 0 || count < 0) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
if (glyphs == NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
glyphs = LE_NEW_ARRAY(LEGlyphID, count);
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (glyphs == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (charIndices == NULL) {
|
|
|
|
le_int32 i, dir = 1, out = 0;
|
|
|
|
|
|
|
|
if (reverse) {
|
|
|
|
out = count - 1;
|
|
|
|
dir = -1;
|
|
|
|
}
|
|
|
|
|
2003-01-07 22:47:19 +00:00
|
|
|
charIndices = LE_NEW_ARRAY(le_int32, count);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (charIndices == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
for (i = 0; i < count; i += 1, out += dir) {
|
|
|
|
charIndices[out] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DefaultCharMapper charMapper(true, mirror);
|
|
|
|
|
|
|
|
fFontInstance->mapCharsToGlyphs(chars, offset, count, reverse, &charMapper, glyphs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Input: characters, font?
|
|
|
|
// Output: glyphs, positions, char indices
|
|
|
|
// Returns: number of glyphs
|
|
|
|
le_int32 LayoutEngine::layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
2000-12-21 01:18:44 +00:00
|
|
|
float x, float y, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
|
|
|
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
|
|
|
fGlyphCount = computeGlyphs(chars, offset, count, max, rightToLeft, fGlyphs, fCharIndices, success);
|
|
|
|
positionGlyphs(fGlyphs, fGlyphCount, x, y, fPositions, success);
|
|
|
|
adjustGlyphPositions(chars, offset, count, rightToLeft, fGlyphs, fGlyphCount, fPositions, success);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
return fGlyphCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LayoutEngine::reset()
|
|
|
|
{
|
|
|
|
fGlyphCount = 0;
|
|
|
|
|
|
|
|
if (fGlyphs != NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
LE_DELETE_ARRAY(fGlyphs);
|
2000-11-14 21:22:14 +00:00
|
|
|
fGlyphs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fCharIndices != NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
LE_DELETE_ARRAY(fCharIndices);
|
2000-11-14 21:22:14 +00:00
|
|
|
fCharIndices = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fPositions != NULL) {
|
2003-01-07 22:47:19 +00:00
|
|
|
LE_DELETE_ARRAY(fPositions);
|
2000-11-14 21:22:14 +00:00
|
|
|
fPositions = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-21 01:18:44 +00:00
|
|
|
LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success)
|
2000-11-14 21:22:14 +00:00
|
|
|
{
|
2003-05-20 23:39:30 +00:00
|
|
|
static le_uint32 gsubTableTag = LE_GSUB_TABLE_TAG;
|
|
|
|
static le_uint32 mortTableTag = LE_MORT_TABLE_TAG;
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
const GlyphSubstitutionTableHeader *gsubTable = (const GlyphSubstitutionTableHeader *) fontInstance->getFontTable(gsubTableTag);
|
2002-03-27 00:34:56 +00:00
|
|
|
LayoutEngine *result = NULL;
|
2003-04-12 00:37:12 +00:00
|
|
|
LETag scriptTag = 0x00000000;
|
|
|
|
LETag languageTag = 0x00000000;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2003-04-12 00:37:12 +00:00
|
|
|
if (gsubTable != NULL && gsubTable->coversScript(scriptTag = OpenTypeLayoutEngine::getScriptTag(scriptCode))) {
|
2000-11-14 21:22:14 +00:00
|
|
|
switch (scriptCode) {
|
|
|
|
case bengScriptCode:
|
|
|
|
case devaScriptCode:
|
|
|
|
case gujrScriptCode:
|
|
|
|
case kndaScriptCode:
|
|
|
|
case mlymScriptCode:
|
|
|
|
case oryaScriptCode:
|
2001-09-20 00:37:55 +00:00
|
|
|
case guruScriptCode:
|
2000-11-14 21:22:14 +00:00
|
|
|
case tamlScriptCode:
|
|
|
|
case teluScriptCode:
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
|
2002-03-27 00:34:56 +00:00
|
|
|
break;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
case arabScriptCode:
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
|
2002-03-27 00:34:56 +00:00
|
|
|
break;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2003-04-12 00:37:12 +00:00
|
|
|
case haniScriptCode:
|
|
|
|
languageTag = OpenTypeLayoutEngine::getLangSysTag(languageCode);
|
|
|
|
|
|
|
|
switch (languageCode) {
|
|
|
|
case korLanguageCode:
|
|
|
|
case janLanguageCode:
|
|
|
|
case zhtLanguageCode:
|
|
|
|
case zhsLanguageCode:
|
|
|
|
if (gsubTable->coversScriptAndLanguage(scriptTag, languageTag)) {
|
|
|
|
result = new HanOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// note: falling through to default case.
|
|
|
|
default:
|
|
|
|
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2000-11-14 21:22:14 +00:00
|
|
|
default:
|
2002-03-27 00:34:56 +00:00
|
|
|
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable);
|
2000-11-14 21:22:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2001-01-19 00:30:17 +00:00
|
|
|
const MorphTableHeader *morphTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
if (morphTable != NULL) {
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, morphTable);
|
2000-11-14 21:22:14 +00:00
|
|
|
} else {
|
|
|
|
switch (scriptCode) {
|
|
|
|
case bengScriptCode:
|
|
|
|
case devaScriptCode:
|
|
|
|
case gujrScriptCode:
|
|
|
|
case kndaScriptCode:
|
|
|
|
case mlymScriptCode:
|
|
|
|
case oryaScriptCode:
|
2001-09-20 00:37:55 +00:00
|
|
|
case guruScriptCode:
|
2000-11-14 21:22:14 +00:00
|
|
|
case tamlScriptCode:
|
|
|
|
case teluScriptCode:
|
|
|
|
{
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
|
2002-03-27 00:34:56 +00:00
|
|
|
break;
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case arabScriptCode:
|
2002-03-27 00:34:56 +00:00
|
|
|
case hebrScriptCode:
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
|
2002-03-27 00:34:56 +00:00
|
|
|
break;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
//case hebrScriptCode:
|
|
|
|
// return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode);
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
case thaiScriptCode:
|
2000-12-21 01:18:44 +00:00
|
|
|
result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode);
|
2002-03-27 00:34:56 +00:00
|
|
|
break;
|
2000-11-14 21:22:14 +00:00
|
|
|
|
|
|
|
default:
|
2002-03-27 00:34:56 +00:00
|
|
|
result = new LayoutEngine(fontInstance, scriptCode, languageCode);
|
2000-11-14 21:22:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-27 00:34:56 +00:00
|
|
|
if (result == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
}
|
2000-12-21 01:18:44 +00:00
|
|
|
|
|
|
|
return result;
|
2000-11-14 21:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LayoutEngine::~LayoutEngine() {
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|