提交 c84f9e1f 编写于 作者: S srl

6501644: sync LayoutEngine *code* structure to match ICU

Reviewed-by: prr
上级 7a5b86c0
......@@ -199,3 +199,7 @@ ifeq ($(PLATFORM), windows)
CPPFLAGS += -I$(PLATFORM_SRC)/native/sun/windows
endif
# Make the Layout Engine build standalone
CPPFLAGS += -DLE_STANDALONE
......@@ -37,6 +37,8 @@
#include "GlyphIterator.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_uint32 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
{
// NOTE: For now, we'll just pick the first alternative...
......@@ -64,3 +66,5 @@ le_uint32 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, c
return 0;
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __ALTERNATESUBSTITUTIONSUBTABLES_H
#define __ALTERNATESUBSTITUTIONSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "OpenTypeTables.h"
#include "GlyphSubstitutionTables.h"
#include "GlyphIterator.h"
U_NAMESPACE_BEGIN
struct AlternateSetTable
{
le_uint16 glyphCount;
......@@ -52,4 +59,5 @@ struct AlternateSubstitutionSubtable : GlyphSubstitutionSubtable
le_uint32 process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter = NULL) const;
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "AnchorTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
void AnchorTable::getAnchor(LEGlyphID glyphID, const LEFontInstance *fontInstance,
LEPoint &anchor) const
{
......@@ -124,3 +126,6 @@ void Format3AnchorTable::getAnchor(const LEFontInstance *fontInstance, LEPoint &
fontInstance->pixelsToUnits(pixels, anchor);
}
U_NAMESPACE_END
......@@ -32,10 +32,17 @@
#ifndef __ANCHORTABLES_H
#define __ANCHORTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct AnchorTable
{
le_uint16 anchorFormat;
......@@ -66,5 +73,7 @@ struct Format3AnchorTable : AnchorTable
void getAnchor(const LEFontInstance *fontInstance, LEPoint &anchor) const;
};
U_NAMESPACE_END
#endif
......@@ -49,23 +49,25 @@
#include "ArabicShaping.h"
#include "CanonShaping.h"
U_NAMESPACE_BEGIN
le_bool CharSubstitutionFilter::accept(LEGlyphID glyph) const
{
return fFontInstance->canDisplay((LEUnicode) glyph);
}
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(
const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ArabicOpenTypeLayoutEngine)
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
fFeatureMap = ArabicShaping::getFeatureMap(fFeatureMapCount);
fFeatureOrder = TRUE;
}
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(
const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fFeatureMap = ArabicShaping::getFeatureMap(fFeatureMapCount);
......@@ -86,9 +88,8 @@ ArabicOpenTypeLayoutEngine::~ArabicOpenTypeLayoutEngine()
// Input: characters
// Output: characters, char indices, tags
// Returns: output character count
le_int32 ArabicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 ArabicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -124,8 +125,8 @@ le_int32 ArabicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[]
return count;
}
void ArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success)
void ArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -137,24 +138,20 @@ void ArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], l
}
if (fGPOSTable != NULL) {
OpenTypeLayoutEngine::adjustGlyphPositions(chars, offset, count,
reverse, glyphStorage, success);
OpenTypeLayoutEngine::adjustGlyphPositions(chars, offset, count, reverse, glyphStorage, success);
} else if (fGDEFTable != NULL) {
GDEFMarkFilter filter(fGDEFTable);
adjustMarkGlyphs(glyphStorage, &filter, success);
} else {
GlyphDefinitionTableHeader *gdefTable =
(GlyphDefinitionTableHeader *) CanonShaping::glyphDefinitionTable;
GlyphDefinitionTableHeader *gdefTable = (GlyphDefinitionTableHeader *) CanonShaping::glyphDefinitionTable;
GDEFMarkFilter filter(gdefTable);
adjustMarkGlyphs(&chars[offset], count, reverse, glyphStorage, &filter, success);
}
}
UnicodeArabicOpenTypeLayoutEngine::UnicodeArabicOpenTypeLayoutEngine(
const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
UnicodeArabicOpenTypeLayoutEngine::UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fGSUBTable = (const GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
......@@ -169,8 +166,7 @@ UnicodeArabicOpenTypeLayoutEngine::~UnicodeArabicOpenTypeLayoutEngine()
}
// "glyphs", "indices" -> glyphs, indices
le_int32 UnicodeArabicOpenTypeLayoutEngine::glyphPostProcessing(
LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 UnicodeArabicOpenTypeLayoutEngine::glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -193,17 +189,14 @@ le_int32 UnicodeArabicOpenTypeLayoutEngine::glyphPostProcessing(
glyphStorage.adoptCharIndicesArray(tempGlyphStorage);
ArabicOpenTypeLayoutEngine::mapCharsToGlyphs(tempChars, 0, tempGlyphCount, FALSE,
TRUE, glyphStorage, success);
ArabicOpenTypeLayoutEngine::mapCharsToGlyphs(tempChars, 0, tempGlyphCount, FALSE, TRUE, glyphStorage, success);
LE_DELETE_ARRAY(tempChars);
return tempGlyphCount;
}
void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_bool reverse, le_bool /*mirror*/,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool /*mirror*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -228,9 +221,8 @@ void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[]
}
}
void UnicodeArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
void UnicodeArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -245,3 +237,6 @@ void UnicodeArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode cha
adjustMarkGlyphs(&chars[offset], count, reverse, glyphStorage, &filter, success);
}
U_NAMESPACE_END
......@@ -43,6 +43,8 @@
#include "GlyphDefinitionTables.h"
#include "GlyphPositioningTables.h"
U_NAMESPACE_BEGIN
/**
* This class implements OpenType layout for Arabic fonts. It overrides
* the characerProcessing method to assign the correct OpenType feature
......@@ -71,8 +73,8 @@ public:
*
* @internal
*/
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode, le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
......@@ -87,8 +89,8 @@ public:
*
* @internal
*/
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode, le_int32 typoFlags);
ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.
......@@ -97,6 +99,20 @@ public:
*/
virtual ~ArabicOpenTypeLayoutEngine();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
/**
......@@ -108,8 +124,7 @@ protected:
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the characters are in a
* right to left directional run
* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
*
* Output parameters:
* @param outChars - the output character arrayt
......@@ -121,9 +136,8 @@ protected:
*
* @internal
*/
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method applies the GPOS table if it is present, otherwise it ensures that all vowel
......@@ -142,11 +156,9 @@ protected:
*
* @internal
*/
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
// static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
// le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
// static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
};
......@@ -178,8 +190,8 @@ public:
*
* @internal
*/
UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.
......@@ -208,8 +220,7 @@ protected:
*
* @internal
*/
virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method copies the input characters into the output glyph index array,
......@@ -227,8 +238,7 @@ protected:
*
* @internal
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, le_bool mirror,
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
......@@ -245,8 +255,9 @@ protected:
*
* @internal
*/
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "LEGlyphStorage.h"
#include "ClassDefinitionTables.h"
U_NAMESPACE_BEGIN
// This table maps Unicode joining types to
// ShapeTypes.
const ArabicShaping::ShapeType ArabicShaping::shapeTypes[] =
......@@ -102,9 +104,7 @@ ArabicShaping::ShapeType ArabicShaping::getShapeType(LEUnicode c)
#define markFeatureMask 0x00040000UL
#define mkmkFeatureMask 0x00020000UL
#define ISOL_FEATURES (isolFeatureMask | ligaFeatureMask | msetFeatureMask | \
markFeatureMask | ccmpFeatureMask | rligFeatureMask | caltFeatureMask | \
dligFeatureMask | cswhFeatureMask | cursFeatureMask | kernFeatureMask | mkmkFeatureMask)
#define ISOL_FEATURES (isolFeatureMask | ligaFeatureMask | msetFeatureMask | markFeatureMask | ccmpFeatureMask | rligFeatureMask | caltFeatureMask | dligFeatureMask | cswhFeatureMask | cursFeatureMask | kernFeatureMask | mkmkFeatureMask)
#define SHAPE_MASK 0xF0000000UL
......@@ -226,3 +226,5 @@ void ArabicShaping::shape(const LEUnicode *chars, le_int32 offset, le_int32 char
adjustTags(erout, 2, glyphStorage);
}
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __ARABICSHAPING_H
#define __ARABICSHAPING_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class ArabicShaping {
class ArabicShaping /* not : public UObject because all methods are static */ {
public:
// Joining types
enum JoiningTypes
......@@ -74,8 +81,8 @@ public:
typedef le_int32 ShapeType;
static void shape(const LEUnicode *chars, le_int32 offset, le_int32 charCount,
le_int32 charMax, le_bool rightToLeft, LEGlyphStorage &glyphStorage);
static void shape(const LEUnicode *chars, le_int32 offset, le_int32 charCount, le_int32 charMax,
le_bool rightToLeft, LEGlyphStorage &glyphStorage);
static const FeatureMap *getFeatureMap(le_int32 &count);
......@@ -88,8 +95,8 @@ private:
static const le_uint8 shapingTypeTable[];
static const ShapeType shapeTypes[];
static void adjustTags(le_int32 outIndex, le_int32 shapeOffset,
LEGlyphStorage &glyphStorage);
static void adjustTags(le_int32 outIndex, le_int32 shapeOffset, LEGlyphStorage &glyphStorage);
};
U_NAMESPACE_END
#endif
......@@ -32,12 +32,19 @@
#ifndef __ATTACHMENTPOSITIONINGSUBTABLES_H
#define __ATTACHMENTPOSITIONINGSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "GlyphPositioningTables.h"
#include "ValueRecords.h"
#include "GlyphIterator.h"
U_NAMESPACE_BEGIN
struct AttachmentPositioningSubtable : GlyphPositioningSubtable
{
Offset baseCoverageTableOffset;
......@@ -55,4 +62,6 @@ inline le_int32 AttachmentPositioningSubtable::getBaseCoverage(LEGlyphID baseGly
return getGlyphCoverage(baseCoverageTableOffset, baseGlyphID);
}
U_NAMESPACE_END
#endif
......@@ -36,6 +36,8 @@
#include "LETypes.h"
#include "CanonShaping.h"
U_NAMESPACE_BEGIN
const le_uint8 CanonShaping::glyphSubstitutionTable[] = {
0x00, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x01, 0x58, 0x02, 0x86, 0x00, 0x12, 0x61, 0x72, 0x61, 0x62,
0x00, 0x6E, 0x62, 0x65, 0x6E, 0x67, 0x00, 0x82, 0x63, 0x79, 0x72, 0x6C, 0x00, 0x8E, 0x64, 0x65,
......@@ -3773,3 +3775,5 @@ const le_uint8 CanonShaping::glyphDefinitionTable[] = {
0x00, 0xDC, 0xD1, 0x85, 0xD1, 0x89, 0x00, 0xE6, 0xD1, 0x8A, 0xD1, 0x8B, 0x00, 0xDC, 0xD1, 0xAA,
0xD1, 0xAD, 0x00, 0xE6, 0xD2, 0x42, 0xD2, 0x44, 0x00, 0xE6
};
U_NAMESPACE_END
......@@ -35,8 +35,9 @@
#include "GlyphDefinitionTables.h"
#include "ClassDefinitionTables.h"
void CanonShaping::sortMarks(le_int32 *indices,
const le_int32 *combiningClasses, le_int32 index, le_int32 limit)
U_NAMESPACE_BEGIN
void CanonShaping::sortMarks(le_int32 *indices, const le_int32 *combiningClasses, le_int32 index, le_int32 limit)
{
for (le_int32 j = index + 1; j < limit; j += 1) {
le_int32 i;
......@@ -55,13 +56,11 @@ void CanonShaping::sortMarks(le_int32 *indices,
}
}
void CanonShaping::reorderMarks(const LEUnicode *inChars, le_int32 charCount,
le_bool rightToLeft, LEUnicode *outChars, LEGlyphStorage &glyphStorage)
void CanonShaping::reorderMarks(const LEUnicode *inChars, le_int32 charCount, le_bool rightToLeft,
LEUnicode *outChars, LEGlyphStorage &glyphStorage)
{
const GlyphDefinitionTableHeader *gdefTable =
(const GlyphDefinitionTableHeader *) glyphDefinitionTable;
const ClassDefinitionTable *classTable =
gdefTable->getMarkAttachClassDefinitionTable();
const GlyphDefinitionTableHeader *gdefTable = (const GlyphDefinitionTableHeader *) glyphDefinitionTable;
const ClassDefinitionTable *classTable = gdefTable->getMarkAttachClassDefinitionTable();
le_int32 *combiningClasses = LE_NEW_ARRAY(le_int32, charCount);
le_int32 *indices = LE_NEW_ARRAY(le_int32, charCount);
LEErrorCode status = LE_NO_ERROR;
......@@ -103,3 +102,5 @@ void CanonShaping::reorderMarks(const LEUnicode *inChars, le_int32 charCount,
LE_DELETE_ARRAY(indices);
LE_DELETE_ARRAY(combiningClasses);
}
U_NAMESPACE_END
......@@ -34,20 +34,22 @@
#include "LETypes.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class CanonShaping
class CanonShaping /* not : public UObject because all members are static */
{
public:
static const le_uint8 glyphSubstitutionTable[];
static const le_uint8 glyphDefinitionTable[];
static void reorderMarks(const LEUnicode *inChars, le_int32 charCount,
le_bool rightToLeft, LEUnicode *outChars, LEGlyphStorage &glyphStorage);
static void reorderMarks(const LEUnicode *inChars, le_int32 charCount, le_bool rightToLeft,
LEUnicode *outChars, LEGlyphStorage &glyphStorage);
private:
static void sortMarks(le_int32 *indices, const le_int32 *combiningClasses,
le_int32 index, le_int32 limit);
static void sortMarks(le_int32 *indices, const le_int32 *combiningClasses, le_int32 index, le_int32 limit);
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "LETypes.h"
#include "LEGlyphFilter.h"
U_NAMESPACE_BEGIN
class LEFontInstance;
/**
......@@ -43,7 +45,7 @@ class LEFontInstance;
*
* @internal
*/
class CharSubstitutionFilter : public LEGlyphFilter
class CharSubstitutionFilter : public UMemory, public LEGlyphFilter
{
private:
/**
......@@ -98,4 +100,7 @@ public:
le_bool accept(LEGlyphID glyph) const;
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "ClassDefinitionTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_int32 ClassDefinitionTable::getGlyphClass(LEGlyphID glyphID) const
{
switch(SWAPW(classFormat)) {
......@@ -139,3 +141,5 @@ le_bool ClassDefFormat2Table::hasGlyphClass(le_int32 glyphClass) const
return FALSE;
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __CLASSDEFINITIONTABLES_H
#define __CLASSDEFINITIONTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct ClassDefinitionTable
{
le_uint16 classFormat;
......@@ -69,4 +76,5 @@ struct ClassDefFormat2Table : ClassDefinitionTable
le_bool hasGlyphClass(le_int32 glyphClass) const;
};
U_NAMESPACE_END
#endif
......@@ -32,12 +32,19 @@
#ifndef __CONTEXTUALGLYPHINSERTION_H
#define __CONTEXTUALGLYPHINSERTION_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LayoutTables.h"
#include "StateTables.h"
#include "MorphTables.h"
#include "MorphStateTables.h"
U_NAMESPACE_BEGIN
struct ContextualGlyphInsertionHeader : MorphStateTableHeader
{
};
......@@ -60,4 +67,5 @@ struct LigatureSubstitutionStateEntry : StateEntry
ByteOffset markedInsertionListOffset;
};
U_NAMESPACE_END
#endif
......@@ -39,6 +39,10 @@
#include "LEGlyphStorage.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor)
ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader)
: StateTableProcessor(morphSubtableHeader)
{
......@@ -57,8 +61,7 @@ void ContextualGlyphSubstitutionProcessor::beginStateTable()
markGlyph = 0;
}
ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage,
le_int32 &currGlyph, EntryTableIndex index)
ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
{
const ContextualGlyphSubstitutionStateEntry *entry = &entryTable[index];
ByteOffset newState = SWAPW(entry->newStateOffset);
......@@ -97,3 +100,5 @@ ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorag
void ContextualGlyphSubstitutionProcessor::endStateTable()
{
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __CONTEXTUALGLYPHSUBSTITUTIONPROCESSOR_H
#define __CONTEXTUALGLYPHSUBSTITUTIONPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "MorphTables.h"
#include "SubtableProcessor.h"
#include "StateTableProcessor.h"
#include "ContextualGlyphSubstitution.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class ContextualGlyphSubstitutionProcessor : public StateTableProcessor
......@@ -52,6 +59,20 @@ public:
ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader);
virtual ~ContextualGlyphSubstitutionProcessor();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
private:
ContextualGlyphSubstitutionProcessor();
......@@ -62,6 +83,8 @@ protected:
le_int32 markGlyph;
const ContextualGlyphSubstitutionHeader *contextualGlyphSubstitutionHeader;
};
U_NAMESPACE_END
#endif
......@@ -32,11 +32,18 @@
#ifndef __CONTEXTUALGLYPHSUBSTITUTION_H
#define __CONTEXTUALGLYPHSUBSTITUTION_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LayoutTables.h"
#include "StateTables.h"
#include "MorphTables.h"
U_NAMESPACE_BEGIN
struct ContextualGlyphSubstitutionHeader : MorphStateTableHeader
{
ByteOffset substitutionTableOffset;
......@@ -55,4 +62,5 @@ struct ContextualGlyphSubstitutionStateEntry : StateEntry
WordOffset currOffset;
};
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -39,6 +38,8 @@
#include "CoverageTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
/*
NOTE: This could be optimized somewhat by keeping track
of the previous sequenceIndex in the loop and doing next()
......@@ -350,7 +351,7 @@ le_uint32 ChainingContextualSubstitutionSubtable::process(const LookupProcessor
// NOTE: This could be a #define, but that seems to confuse
// the Visual Studio .NET 2003 compiler on the calls to the
// GlyphIterator constructor. It somehow can't decide if
// GlyphIterator constructor. It somehow can't decide if
// emptyFeatureList matches an le_uint32 or an le_uint16...
static const FeatureMask emptyFeatureList = 0x00000000UL;
......@@ -542,3 +543,5 @@ le_uint32 ChainingContextualSubstitutionFormat3Subtable::process(const LookupPro
return 0;
}
U_NAMESPACE_END
......@@ -32,6 +32,11 @@
#ifndef __CONTEXTUALSUBSTITUTIONSUBTABLES_H
#define __CONTEXTUALSUBSTITUTIONSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
......@@ -39,6 +44,8 @@
#include "GlyphIterator.h"
#include "LookupProcessor.h"
U_NAMESPACE_BEGIN
struct SubstitutionLookupRecord
{
le_uint16 sequenceIndex;
......@@ -218,4 +225,5 @@ struct ChainingContextualSubstitutionFormat3Subtable
le_uint32 process(const LookupProcessor *lookupProcessor, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const;
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "CoverageTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_int32 CoverageTable::getGlyphCoverage(LEGlyphID glyphID) const
{
switch(SWAPW(coverageFormat))
......@@ -106,3 +108,5 @@ le_int32 CoverageFormat2Table::getGlyphCoverage(LEGlyphID glyphID) const
return startCoverageIndex + (ttGlyphID - firstInRange);
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __COVERAGETABLES_H
#define __COVERAGETABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct CoverageTable
{
le_uint16 coverageFormat;
......@@ -58,5 +65,5 @@ struct CoverageFormat2Table : CoverageTable
le_int32 getGlyphCoverage(LEGlyphID glyphID) const;
};
U_NAMESPACE_END
#endif
......@@ -37,6 +37,8 @@
#include "OpenTypeUtilities.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_uint32 CursiveAttachmentSubtable::process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const
{
LEGlyphID glyphID = glyphIterator->getCurrGlyphID();
......@@ -68,3 +70,5 @@ le_uint32 CursiveAttachmentSubtable::process(GlyphIterator *glyphIterator, const
return 1;
}
U_NAMESPACE_END
......@@ -32,10 +32,17 @@
#ifndef __CURSIVEATTACHMENTSUBTABLES_H
#define __CURSIVEATTACHMENTSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "GlyphPositioningTables.h"
U_NAMESPACE_BEGIN
class LEFontInstance;
class GlyphIterator;
......@@ -53,4 +60,7 @@ struct CursiveAttachmentSubtable : GlyphPositioningSubtable
le_uint32 process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const;
};
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -32,9 +31,16 @@
#ifndef __DEFAULTCHARMAPPER_H
#define __DEFAULTCHARMAPPER_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
U_NAMESPACE_BEGIN
/**
* This class is an instance of LECharMapper which
* implements control character filtering and bidi
......@@ -42,7 +48,7 @@
*
* @see LECharMapper
*/
class DefaultCharMapper : public LECharMapper
class DefaultCharMapper : public UMemory, public LECharMapper
{
private:
le_bool fFilterControls;
......@@ -77,4 +83,5 @@ public:
LEUnicode32 mapChar(LEUnicode32 ch) const;
};
U_NAMESPACE_END
#endif
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved
*
......@@ -34,6 +35,8 @@
#include "DeviceTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
const le_uint16 DeviceTable::fieldMasks[] = {0x0003, 0x000F, 0x00FF};
const le_uint16 DeviceTable::fieldSignBits[] = {0x0002, 0x0008, 0x0080};
const le_uint16 DeviceTable::fieldBits[] = { 2, 4, 8};
......@@ -62,3 +65,5 @@ le_int16 DeviceTable::getAdjustment(le_uint16 ppem) const
return result;
}
U_NAMESPACE_END
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
......@@ -32,10 +33,15 @@
#ifndef __DEVICETABLES_H
#define __DEVICETABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "GlyphIterator.h"
#include "GlyphPositionAdjustments.h"
U_NAMESPACE_BEGIN
struct DeviceTable
{
......@@ -52,5 +58,7 @@ private:
static const le_uint16 fieldBits[];
};
U_NAMESPACE_END
#endif
......@@ -25,7 +25,8 @@
/*
*
* (C) Copyright IBM Corp. 2003 - All Rights Reserved
*
* (C) Copyright IBM Corp. 2002 - All Rights Reserved
*
*/
......@@ -37,6 +38,9 @@
#include "GlyphIterator.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
// FIXME: should look at the format too... maybe have a sub-class for it?
le_uint32 ExtensionSubtable::process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const
......@@ -52,3 +56,5 @@ le_uint32 ExtensionSubtable::process(const LookupProcessor *lookupProcessor, le_
return 0;
}
U_NAMESPACE_END
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 2002-2003 - All Rights Reserved
*
......@@ -32,12 +33,19 @@
#ifndef __EXTENSIONSUBTABLES_H
#define __EXTENSIONSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "GlyphSubstitutionTables.h"
#include "LookupProcessor.h"
#include "GlyphIterator.h"
U_NAMESPACE_BEGIN
struct ExtensionSubtable //: GlyphSubstitutionSubtable
{
le_uint16 substFormat;
......@@ -48,4 +56,5 @@ struct ExtensionSubtable //: GlyphSubstitutionSubtable
GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const;
};
U_NAMESPACE_END
#endif
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
*
......@@ -35,6 +36,8 @@
#include "Features.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
const FeatureTable *FeatureListTable::getFeatureTable(le_uint16 featureIndex, LETag *featureTag) const
{
if (featureIndex >= SWAPW(featureCount)) {
......@@ -79,3 +82,5 @@ const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const
return 0;
#endif
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __FEATURES_H
#define __FEATURES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct FeatureRecord
{
ATag featureTag;
......@@ -53,9 +60,10 @@ struct FeatureListTable
le_uint16 featureCount;
FeatureRecord featureRecordArray[ANY_NUMBER];
const FeatureTable *getFeatureTable(le_uint16 featureIndex, LETag *featureTag) const;
const FeatureTable *getFeatureTable(le_uint16 featureIndex, LETag *featureTag) const;
const FeatureTable *getFeatureTable(LETag featureTag) const;
};
U_NAMESPACE_END
#endif
......@@ -34,6 +34,8 @@
#include "GDEFMarkFilter.h"
#include "GlyphDefinitionTables.h"
U_NAMESPACE_BEGIN
GDEFMarkFilter::GDEFMarkFilter(const GlyphDefinitionTableHeader *gdefTable)
{
classDefTable = gdefTable->getGlyphClassDefinitionTable();
......@@ -50,3 +52,5 @@ le_bool GDEFMarkFilter::accept(LEGlyphID glyph) const
return glyphClass == gcdMarkGlyph;
}
U_NAMESPACE_END
......@@ -32,11 +32,18 @@
#ifndef __GDEFMARKFILTER__H
#define __GDEFMARKFILTER__H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "GlyphDefinitionTables.h"
class GDEFMarkFilter : public LEGlyphFilter
U_NAMESPACE_BEGIN
class GDEFMarkFilter : public UMemory, public LEGlyphFilter
{
private:
const GlyphClassDefinitionTable *classDefTable;
......@@ -51,5 +58,5 @@ public:
virtual le_bool accept(LEGlyphID glyph) const;
};
U_NAMESPACE_END
#endif
......@@ -23,6 +23,7 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
......@@ -36,8 +37,11 @@
#include "MorphTables.h"
GXLayoutEngine::GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode, const MorphTableHeader *morphTable)
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, 0), fMorphTable(morphTable)
{
// nothing else to do?
......@@ -49,9 +53,7 @@ GXLayoutEngine::~GXLayoutEngine()
}
// apply 'mort' table
le_int32 GXLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage,
LEErrorCode &success)
le_int32 GXLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -74,9 +76,8 @@ le_int32 GXLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset,
}
// apply positional tables
void GXLayoutEngine::adjustGlyphPositions(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_bool /*reverse*/,
LEGlyphStorage &/*glyphStorage*/, LEErrorCode &success)
void GXLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool /*reverse*/,
LEGlyphStorage &/*glyphStorage*/, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -89,3 +90,5 @@ void GXLayoutEngine::adjustGlyphPositions(const LEUnicode chars[],
// FIXME: no positional processing yet...
}
U_NAMESPACE_END
......@@ -23,6 +23,7 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
......@@ -37,6 +38,8 @@
#include "MorphTables.h"
U_NAMESPACE_BEGIN
class LEFontInstance;
class LEGlyphStorage;
......@@ -70,8 +73,7 @@ public:
*
* @internal
*/
GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode, const MorphTableHeader *morphTable);
GXLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const MorphTableHeader *morphTable);
/**
* The destructor, virtual for correct polymorphic invocation.
......@@ -80,6 +82,20 @@ public:
*/
virtual ~GXLayoutEngine();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
/**
......@@ -99,10 +115,8 @@ protected:
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the text is in a
* right to left directional run
* @param glyphStorage - the glyph storage object. The glyph
* and char index arrays will be set.
* @param rightToLeft - <code>TRUE</code> if the text is in a right to left directional run
* @param glyphStorage - the glyph storage object. The glyph and char index arrays will be set.
*
* Output parameters:
* @param success - set to an error code if the operation fails
......@@ -111,8 +125,7 @@ protected:
*
* @internal
*/
virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
......@@ -120,16 +133,18 @@ protected:
* 'kern', 'trak', 'bsln', 'opbd' and 'just' tables.
*
* Input parameters:
* @param glyphStorage - the object holding the glyph storage.
* The positions will be updated as needed.
* @param glyphStorage - the object holding the glyph storage. The positions will be updated as needed.
*
* Output parameters:
* @param success - set to an error code if the operation fails
*
* @internal
*/
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
};
U_NAMESPACE_END
#endif
......@@ -34,6 +34,8 @@
#include "GlyphDefinitionTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
const GlyphClassDefinitionTable *GlyphDefinitionTableHeader::getGlyphClassDefinitionTable() const
{
return (const GlyphClassDefinitionTable *) ((char *) this + SWAPW(glyphClassDefOffset));
......@@ -53,3 +55,5 @@ const MarkAttachClassDefinitionTable *GlyphDefinitionTableHeader::getMarkAttachC
{
return (const MarkAttachClassDefinitionTable *) ((char *) this + SWAPW(MarkAttachClassDefOffset));
}
U_NAMESPACE_END
......@@ -32,10 +32,17 @@
#ifndef __GLYPHDEFINITIONTABLES_H
#define __GLYPHDEFINITIONTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "ClassDefinitionTables.h"
U_NAMESPACE_BEGIN
typedef ClassDefinitionTable GlyphClassDefinitionTable;
enum GlyphClassDefinitions
......@@ -110,4 +117,5 @@ struct GlyphDefinitionTableHeader
const MarkAttachClassDefinitionTable *getMarkAttachClassDefinitionTable() const;
};
U_NAMESPACE_END
#endif
......@@ -38,11 +38,10 @@
#include "Lookups.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage,
GlyphPositionAdjustments *theGlyphPositionAdjustments,
le_bool rightToLeft, le_uint16 theLookupFlags, FeatureMask theFeatureMask,
const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader)
GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags,
FeatureMask theFeatureMask, const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader)
: direction(1), position(-1), nextLimit(-1), prevLimit(-1),
glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments),
srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask),
......@@ -262,8 +261,8 @@ void GlyphIterator::setCurrGlyphBaseOffset(le_int32 baseOffset)
glyphPositionAdjustments->setBaseOffset(position, baseOffset);
}
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust,
float yPlacementAdjust, float xAdvanceAdjust, float yAdvanceAdjust)
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
float xAdvanceAdjust, float yAdvanceAdjust)
{
if (direction < 0) {
if (position <= nextLimit || position >= prevLimit) {
......@@ -281,8 +280,8 @@ void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust,
glyphPositionAdjustments->adjustYAdvance(position, yAdvanceAdjust);
}
void GlyphIterator::setCurrGlyphPositionAdjustment(float xPlacementAdjust,
float yPlacementAdjust, float xAdvanceAdjust, float yAdvanceAdjust)
void GlyphIterator::setCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
float xAdvanceAdjust, float yAdvanceAdjust)
{
if (direction < 0) {
if (position <= nextLimit || position >= prevLimit) {
......@@ -484,10 +483,11 @@ le_bool GlyphIterator::findMark2Glyph()
do {
newPosition -= direction;
} while (newPosition != prevLimit && glyphStorage[newPosition] != 0xFFFE &&
filterGlyph(newPosition));
} while (newPosition != prevLimit && glyphStorage[newPosition] != 0xFFFE && filterGlyph(newPosition));
position = newPosition;
return position != prevLimit;
}
U_NAMESPACE_END
......@@ -32,26 +32,24 @@
#ifndef __GLYPHITERATOR_H
#define __GLYPHITERATOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "GlyphDefinitionTables.h"
struct InsertionRecord
{
InsertionRecord *next;
le_int32 position;
le_int32 count;
LEGlyphID glyphs[ANY_NUMBER];
};
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class GlyphPositionAdjustments;
class GlyphIterator {
class GlyphIterator : public UMemory {
public:
GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments,
le_bool rightToLeft, le_uint16 theLookupFlags, FeatureMask theFeatureMask,
const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader);
GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags,
FeatureMask theFeatureMask, const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader);
GlyphIterator(GlyphIterator &that);
......@@ -122,4 +120,5 @@ private:
GlyphIterator &operator=(const GlyphIterator &other); // forbid copying of this class
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "GlyphLookupTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_bool GlyphLookupTableHeader::coversScript(LETag scriptTag) const
{
const ScriptListTable *scriptListTable = (const ScriptListTable *) ((char *)this + SWAPW(scriptListOffset));
......@@ -51,3 +53,5 @@ le_bool GlyphLookupTableHeader::coversScriptAndLanguage(LETag scriptTag, LETag l
// Note: don't have to SWAPW langSysTable->featureCount to check for non-zero.
return langSysTable != NULL && langSysTable->featureCount != 0;
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __GLYPHLOOKUPTABLES_H
#define __GLYPHLOOKUPTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct GlyphLookupTableHeader
{
fixed32 version;
......@@ -46,4 +53,7 @@ struct GlyphLookupTableHeader
le_bool coversScriptAndLanguage(LETag scriptTag, LETag languageTag, le_bool exactMatch = FALSE) const;
};
U_NAMESPACE_END
#endif
......@@ -34,6 +34,8 @@
#include "LEGlyphStorage.h"
#include "LEFontInstance.h"
U_NAMESPACE_BEGIN
#define CHECK_ALLOCATE_ARRAY(array, type, size) \
if (array == NULL) { \
array = (type *) new type[size]; \
......@@ -185,3 +187,5 @@ LEPoint *GlyphPositionAdjustments::EntryExitPoint::getExitPoint(LEPoint &exitPoi
return NULL;
}
U_NAMESPACE_END
......@@ -32,16 +32,23 @@
#ifndef __GLYPHPOSITIONADJUSTMENTS_H
#define __GLYPHPOSITIONADJUSTMENTS_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class LEFontInstance;
class GlyphPositionAdjustments
class GlyphPositionAdjustments : public UMemory
{
private:
class Adjustment {
class Adjustment : public UMemory {
public:
inline Adjustment();
......@@ -78,7 +85,7 @@ private:
// allow copying of this class because all of its fields are simple types
};
class EntryExitPoint
class EntryExitPoint : public UMemory
{
public:
inline EntryExitPoint();
......@@ -144,14 +151,11 @@ public:
inline void adjustXAdvance(le_int32 index, float xAdjustment);
inline void adjustYAdvance(le_int32 index, float yAdjustment);
void setEntryPoint(le_int32 index, LEPoint &newEntryPoint,
le_bool baselineIsLogicalEnd);
void setExitPoint(le_int32 index, LEPoint &newExitPoint,
le_bool baselineIsLogicalEnd);
void setEntryPoint(le_int32 index, LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd);
void setExitPoint(le_int32 index, LEPoint &newExitPoint, le_bool baselineIsLogicalEnd);
void setCursiveGlyph(le_int32 index, le_bool baselineIsLogicalEnd);
void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft,
const LEFontInstance *fontInstance);
void applyCursiveAdjustments(LEGlyphStorage &glyphStorage, le_bool rightToLeft, const LEFontInstance *fontInstance);
};
inline GlyphPositionAdjustments::Adjustment::Adjustment()
......@@ -160,10 +164,8 @@ inline GlyphPositionAdjustments::Adjustment::Adjustment()
// nothing else to do!
}
inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace,
float xAdv, float yAdv, le_int32 baseOff)
: xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv),
baseOffset(baseOff)
inline GlyphPositionAdjustments::Adjustment::Adjustment(float xPlace, float yPlace, float xAdv, float yAdv, le_int32 baseOff)
: xPlacement(xPlace), yPlacement(yPlace), xAdvance(xAdv), yAdvance(yAdv), baseOffset(baseOff)
{
// nothing else to do!
}
......@@ -246,7 +248,7 @@ inline void GlyphPositionAdjustments::Adjustment::adjustYAdvance(float yAdjustme
inline GlyphPositionAdjustments::EntryExitPoint::EntryExitPoint()
: fFlags(0)
{
fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fEntryPoint.fY = 0;
fEntryPoint.fX = fEntryPoint.fY = fExitPoint.fX = fExitPoint.fY = 0;
}
inline GlyphPositionAdjustments::EntryExitPoint::~EntryExitPoint()
......@@ -264,12 +266,10 @@ inline le_bool GlyphPositionAdjustments::EntryExitPoint::baselineIsLogicalEnd()
return (fFlags & EEF_BASELINE_IS_LOGICAL_END) != 0;
}
inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(
LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(LEPoint &newEntryPoint, le_bool baselineIsLogicalEnd)
{
if (baselineIsLogicalEnd) {
fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH |
EEF_BASELINE_IS_LOGICAL_END);
fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
} else {
fFlags |= (EEF_HAS_ENTRY_POINT | EEF_IS_CURSIVE_GLYPH);
}
......@@ -277,12 +277,10 @@ inline void GlyphPositionAdjustments::EntryExitPoint::setEntryPoint(
fEntryPoint = newEntryPoint;
}
inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(
LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(LEPoint &newExitPoint, le_bool baselineIsLogicalEnd)
{
if (baselineIsLogicalEnd) {
fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH |
EEF_BASELINE_IS_LOGICAL_END);
fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
} else {
fFlags |= (EEF_HAS_EXIT_POINT | EEF_IS_CURSIVE_GLYPH);
}
......@@ -290,8 +288,7 @@ inline void GlyphPositionAdjustments::EntryExitPoint::setExitPoint(
fExitPoint = newExitPoint;
}
inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(
le_bool baselineIsLogicalEnd)
inline void GlyphPositionAdjustments::EntryExitPoint::setCursiveGlyph(le_bool baselineIsLogicalEnd)
{
if (baselineIsLogicalEnd) {
fFlags |= (EEF_IS_CURSIVE_GLYPH | EEF_BASELINE_IS_LOGICAL_END);
......@@ -386,4 +383,5 @@ inline le_bool GlyphPositionAdjustments::hasCursiveGlyphs() const
return fEntryExitPoints != NULL;
}
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -40,18 +39,18 @@
#include "LEGlyphStorage.h"
#include "GlyphPositionAdjustments.h"
void GlyphPositioningTableHeader::process(LEGlyphStorage &glyphStorage,
GlyphPositionAdjustments *glyphPositionAdjustments, le_bool rightToLeft,
LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const
U_NAMESPACE_BEGIN
void GlyphPositioningTableHeader::process(LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments, le_bool rightToLeft,
LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const
{
GlyphPositioningLookupProcessor processor(this, scriptTag, languageTag, featureMap,
featureMapCount, featureOrder);
GlyphPositioningLookupProcessor processor(this, scriptTag, languageTag, featureMap, featureMapCount, featureOrder);
processor.process(glyphStorage, glyphPositionAdjustments, rightToLeft,
glyphDefinitionTableHeader, fontInstance);
processor.process(glyphStorage, glyphPositionAdjustments, rightToLeft, glyphDefinitionTableHeader, fontInstance);
glyphPositionAdjustments->applyCursiveAdjustments(glyphStorage, rightToLeft, fontInstance);
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -32,11 +31,18 @@
#ifndef __GLYPHPOSITIONINGTABLES_H
#define __GLYPHPOSITIONINGTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "Lookups.h"
#include "GlyphLookupTables.h"
U_NAMESPACE_BEGIN
class LEFontInstance;
class LEGlyphStorage;
class LEGlyphFilter;
......@@ -45,12 +51,10 @@ struct GlyphDefinitionTableHeader;
struct GlyphPositioningTableHeader : public GlyphLookupTableHeader
{
void process(LEGlyphStorage &glyphStorage,
GlyphPositionAdjustments *glyphPositionAdjustments,
void process(LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments,
le_bool rightToLeft, LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const;
const LEFontInstance *fontInstance, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const;
};
enum GlyphPositioningSubtableTypes
......@@ -68,4 +72,5 @@ enum GlyphPositioningSubtableTypes
typedef LookupSubtable GlyphPositioningSubtable;
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved
*
*/
......@@ -50,6 +49,8 @@
#include "GlyphPosnLookupProc.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
// Aside from the names, the contextual positioning subtables are
// the same as the contextual substitution subtables.
typedef ContextualSubstitutionSubtable ContextualPositioningSubtable;
......@@ -57,8 +58,7 @@ typedef ChainingContextualSubstitutionSubtable ChainingContextualPositioningSubt
GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor(
const GlyphPositioningTableHeader *glyphPositioningTableHeader,
LETag scriptTag, LETag languageTag,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
: LookupProcessor(
(char *) glyphPositioningTableHeader,
SWAPW(glyphPositioningTableHeader->scriptListOffset),
......@@ -166,3 +166,5 @@ le_uint32 GlyphPositioningLookupProcessor::applySubtable(const LookupSubtable *l
GlyphPositioningLookupProcessor::~GlyphPositioningLookupProcessor()
{
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -32,6 +31,11 @@
#ifndef __GLYPHPOSITIONINGLOOKUPPROCESSOR_H
#define __GLYPHPOSITIONINGLOOKUPPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
......@@ -42,12 +46,13 @@
#include "GlyphIterator.h"
#include "LookupProcessor.h"
U_NAMESPACE_BEGIN
class GlyphPositioningLookupProcessor : public LookupProcessor
{
public:
GlyphPositioningLookupProcessor(const GlyphPositioningTableHeader *glyphPositioningTableHeader,
LETag scriptTag, LETag languageTag,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder);
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder);
virtual ~GlyphPositioningLookupProcessor();
......@@ -63,4 +68,5 @@ private:
GlyphPositioningLookupProcessor &operator=(const GlyphPositioningLookupProcessor &other); // forbid copying of this class
};
U_NAMESPACE_END
#endif
......@@ -48,17 +48,17 @@
#include "GlyphSubstLookupProc.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
const GlyphSubstitutionTableHeader *glyphSubstitutionTableHeader,
LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
: LookupProcessor(
(char *) glyphSubstitutionTableHeader,
SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
SWAPW(glyphSubstitutionTableHeader->featureListOffset),
SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
scriptTag, languageTag, featureMap, featureMapCount, featureOrder)
, fFilter(filter)
scriptTag, languageTag, featureMap, featureMapCount, featureOrder), fFilter(filter)
{
// anything?
}
......@@ -143,3 +143,5 @@ le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LookupSubtable *
GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
{
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -32,6 +31,11 @@
#ifndef __GLYPHSUBSTITUTIONLOOKUPPROCESSOR_H
#define __GLYPHSUBSTITUTIONLOOKUPPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "LEFontInstance.h"
......@@ -43,12 +47,13 @@
#include "GlyphIterator.h"
#include "LookupProcessor.h"
U_NAMESPACE_BEGIN
class GlyphSubstitutionLookupProcessor : public LookupProcessor
{
public:
GlyphSubstitutionLookupProcessor(const GlyphSubstitutionTableHeader *glyphSubstitutionTableHeader,
LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder);
LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder);
virtual ~GlyphSubstitutionLookupProcessor();
......@@ -65,4 +70,5 @@ private:
GlyphSubstitutionLookupProcessor &operator=(const GlyphSubstitutionLookupProcessor &other); // forbid copying of this class
};
U_NAMESPACE_END
#endif
......@@ -40,14 +40,15 @@
#include "LEGlyphStorage.h"
#include "LESwaps.h"
le_int32 GlyphSubstitutionTableHeader::process(LEGlyphStorage &glyphStorage,
le_bool rightToLeft, LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEGlyphFilter *filter, const FeatureMap *featureMap,
le_int32 featureMapCount, le_bool featureOrder) const
U_NAMESPACE_BEGIN
le_int32 GlyphSubstitutionTableHeader::process(LEGlyphStorage &glyphStorage, le_bool rightToLeft, LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEGlyphFilter *filter, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const
{
GlyphSubstitutionLookupProcessor processor(this, scriptTag, languageTag, filter, featureMap,
featureMapCount, featureOrder);
GlyphSubstitutionLookupProcessor processor(this, scriptTag, languageTag, filter, featureMap, featureMapCount, featureOrder);
return processor.process(glyphStorage, NULL, rightToLeft, glyphDefinitionTableHeader, NULL);
}
U_NAMESPACE_END
......@@ -32,22 +32,27 @@
#ifndef __GLYPHSUBSTITUTIONTABLES_H
#define __GLYPHSUBSTITUTIONTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
#include "Lookups.h"
#include "GlyphLookupTables.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class LEGlyphFilter;
struct GlyphDefinitionTableHeader;
struct GlyphSubstitutionTableHeader : public GlyphLookupTableHeader
{
le_int32 process(LEGlyphStorage &glyphStorage,
le_bool rightToLeft, LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEGlyphFilter *filter, const FeatureMap *featureMap,
le_int32 featureMapCount, le_bool featureOrder) const;
le_int32 process(LEGlyphStorage &glyphStorage, le_bool rightToLeft, LETag scriptTag, LETag languageTag,
const GlyphDefinitionTableHeader *glyphDefinitionTableHeader, const LEGlyphFilter *filter,
const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder) const;
};
enum GlyphSubstitutionSubtableTypes
......@@ -64,4 +69,5 @@ enum GlyphSubstitutionSubtableTypes
typedef LookupSubtable GlyphSubstitutionSubtable;
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
* HanLayoutEngine.cpp: OpenType processing for Han fonts.
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved.
......@@ -41,6 +40,10 @@
#include "LEGlyphStorage.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
#define loclFeatureTag LE_LOCL_FEATURE_TAG
#define smplFeatureTag LE_SMPL_FEATURE_TAG
#define tradFeatureTag LE_TRAD_FEATURE_TAG
......@@ -60,9 +63,8 @@ static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
#define features (loclFeatureMask)
HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags,
const GlyphSubstitutionTableHeader *gsubTable)
HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
fFeatureMap = featureMap;
......@@ -74,9 +76,8 @@ HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
// nothing to do
}
le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -104,3 +105,5 @@ le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
return count;
}
U_NAMESPACE_END
......@@ -23,8 +23,8 @@
*
*/
/*
*
* HanLayoutEngine.h: OpenType processing for Han fonts.
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved.
......@@ -40,6 +40,8 @@
#include "GlyphSubstitutionTables.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
/**
......@@ -69,9 +71,8 @@ public:
*
* @internal
*/
HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
......@@ -81,6 +82,20 @@ public:
*/
virtual ~HanOpenTypeLayoutEngine();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
/**
......@@ -92,10 +107,8 @@ protected:
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the characters are in a
* right to left directional run
* @param glyphStorage - the object holding the glyph storage. The char
* index and auxillary data arrays will be set.
* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
* @param glyphStorage - the object holding the glyph storage. The char index and auxillary data arrays will be set.
*
* Output parameters:
* @param outChars - the output character arrayt
......@@ -107,9 +120,10 @@ protected:
*
* @internal
*/
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "OpenTypeUtilities.h"
#include "IndicReordering.h"
U_NAMESPACE_BEGIN
// Split matra table indices
#define _x1 (1 << CF_INDEX_SHIFT)
#define _x2 (2 << CF_INDEX_SHIFT)
......@@ -385,3 +387,5 @@ le_int32 IndicReordering::getWorstCaseExpansion(le_int32 scriptCode)
return classTable->getWorstCaseExpansion();
}
U_NAMESPACE_END
......@@ -45,20 +45,20 @@
#include "IndicReordering.h"
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags,
const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable),
fMPreFixups(NULL)
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicOpenTypeLayoutEngine)
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable), fMPreFixups(NULL)
{
fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount);
fFeatureOrder = TRUE;
}
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags),
fMPreFixups(NULL)
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fMPreFixups(NULL)
{
fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount);
fFeatureOrder = TRUE;
......@@ -71,9 +71,8 @@ IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine()
// Input: characters, tags
// Output: glyphs, char indices
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -84,8 +83,7 @@ le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[],
return 0;
}
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max,
rightToLeft, glyphStorage, success);
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, glyphStorage, success);
if (LE_FAILURE(success)) {
return 0;
......@@ -99,9 +97,8 @@ le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[],
// Input: characters
// Output: characters, char indices, tags
// Returns: output character count
le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -131,9 +128,10 @@ le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
// NOTE: assumes this allocates featureTags...
// (probably better than doing the worst case stuff here...)
le_int32 outCharCount = IndicReordering::reorder(&chars[offset], count, fScriptCode,
outChars, glyphStorage, &fMPreFixups);
glyphStorage.adoptGlyphCount(outCharCount);
le_int32 outCharCount = IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage, &fMPreFixups);
glyphStorage.adoptGlyphCount(outCharCount);
return outCharCount;
}
U_NAMESPACE_END
......@@ -43,6 +43,8 @@
#include "GlyphDefinitionTables.h"
#include "GlyphPositioningTables.h"
U_NAMESPACE_BEGIN
class MPreFixups;
class LEGlyphStorage;
......@@ -77,9 +79,8 @@ public:
*
* @internal
*/
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB table which can't be known
......@@ -94,8 +95,8 @@ public:
*
* @internal
*/
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.
......@@ -104,6 +105,20 @@ public:
*/
virtual ~IndicOpenTypeLayoutEngine();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
/**
......@@ -117,10 +132,9 @@ protected:
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the characters are in a
* right to left directional run
* @param glyphStorage - the glyph storage object. The glyph and character
* index arrays will be set. The auxillary data array will be set to the feature tags.
* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
* @param glyphStorage - the glyph storage object. The glyph and character index arrays will be set.
* the auxillary data array will be set to the feature tags.
*
* Output parameters:
* @param success - set to an error code if the operation fails
......@@ -129,9 +143,8 @@ protected:
*
* @internal
*/
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
/**
* This method does character to glyph mapping, applies the GSUB table and applies
......@@ -147,11 +160,9 @@ protected:
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the characters are in a
* right to left directional run
* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
* @param featureTags - the feature tag array
* @param glyphStorage - the glyph storage object. The glyph and char
* index arrays will be set.
* @param glyphStorage - the glyph storage object. The glyph and char index arrays will be set.
*
* Output parameters:
* @param success - set to an error code if the operation fails
......@@ -163,12 +174,14 @@ protected:
*
* @internal
*/
virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage,
LEErrorCode &success);
virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success);
private:
MPreFixups *fMPreFixups;
};
U_NAMESPACE_END
#endif
......@@ -32,12 +32,19 @@
#ifndef __INDICREARRANGEMENT_H
#define __INDICREARRANGEMENT_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LayoutTables.h"
#include "StateTables.h"
#include "MorphTables.h"
#include "MorphStateTables.h"
U_NAMESPACE_BEGIN
struct IndicRearrangementSubtableHeader : MorphStateTableHeader
{
};
......@@ -78,4 +85,6 @@ struct IndicRearrangementStateEntry : StateEntry
{
};
U_NAMESPACE_END
#endif
......@@ -39,6 +39,10 @@
#include "LEGlyphStorage.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicRearrangementProcessor)
IndicRearrangementProcessor::IndicRearrangementProcessor(const MorphSubtableHeader *morphSubtableHeader)
: StateTableProcessor(morphSubtableHeader)
{
......@@ -56,8 +60,7 @@ void IndicRearrangementProcessor::beginStateTable()
lastGlyph = 0;
}
ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage,
le_int32 &currGlyph, EntryTableIndex index)
ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
{
const IndicRearrangementStateEntry *entry = &entryTable[index];
ByteOffset newState = SWAPW(entry->newStateOffset);
......@@ -416,3 +419,5 @@ void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphSto
break;
}
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __INDICREARRANGEMENTPROCESSOR_H
#define __INDICREARRANGEMENTPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "MorphTables.h"
#include "SubtableProcessor.h"
#include "StateTableProcessor.h"
#include "IndicRearrangement.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
class IndicRearrangementProcessor : public StateTableProcessor
......@@ -54,12 +61,28 @@ public:
IndicRearrangementProcessor(const MorphSubtableHeader *morphSubtableHeader);
virtual ~IndicRearrangementProcessor();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
le_int32 firstGlyph;
le_int32 lastGlyph;
const IndicRearrangementStateEntry *entryTable;
const IndicRearrangementSubtableHeader *indicRearrangementSubtableHeader;
};
U_NAMESPACE_END
#endif
......@@ -36,6 +36,8 @@
#include "LEGlyphStorage.h"
#include "MPreFixups.h"
U_NAMESPACE_BEGIN
#define initFeatureTag LE_INIT_FEATURE_TAG
#define nuktFeatureTag LE_NUKT_FEATURE_TAG
#define akhnFeatureTag LE_AKHN_FEATURE_TAG
......@@ -71,7 +73,7 @@
#define distFeatureMask 0x00020000UL
#define initFeatureMask 0x00010000UL
class ReorderingOutput {
class ReorderingOutput : public UMemory {
private:
le_int32 fOutIndex;
LEUnicode *fOutChars;
......@@ -187,8 +189,7 @@ public:
fOutIndex += 1;
}
le_bool noteMatra(const IndicClassTable *classTable, LEUnicode matra, le_uint32 matraIndex,
FeatureMask matraFeatures, le_bool wordStart)
le_bool noteMatra(const IndicClassTable *classTable, LEUnicode matra, le_uint32 matraIndex, FeatureMask matraFeatures, le_bool wordStart)
{
IndicClassTable::CharClass matraClass = classTable->getCharClass(matra);
......@@ -219,13 +220,12 @@ public:
return FALSE;
}
void noteVowelModifier(const IndicClassTable *classTable, LEUnicode vowelModifier,
le_uint32 vowelModifierIndex, FeatureMask vowelModifierFeatures)
void noteVowelModifier(const IndicClassTable *classTable, LEUnicode vowelModifier, le_uint32 vowelModifierIndex, FeatureMask vowelModifierFeatures)
{
IndicClassTable::CharClass vmClass = classTable->getCharClass(vowelModifier);
fVMIndex = vowelModifierIndex;
fVMFeatures = vowelModifierFeatures;
fVMFeatures = vowelModifierFeatures;
if (IndicClassTable::isVowelModifier(vmClass)) {
switch (vmClass & CF_POS_MASK) {
......@@ -244,13 +244,12 @@ public:
}
}
void noteStressMark(const IndicClassTable *classTable, LEUnicode stressMark,
le_uint32 stressMarkIndex, FeatureMask stressMarkFeatures)
void noteStressMark(const IndicClassTable *classTable, LEUnicode stressMark, le_uint32 stressMarkIndex, FeatureMask stressMarkFeatures)
{
IndicClassTable::CharClass smClass = classTable->getCharClass(stressMark);
fSMIndex = stressMarkIndex;
fSMFeatures = stressMarkFeatures;
fSMFeatures = stressMarkFeatures;
if (IndicClassTable::isStressMark(smClass)) {
switch (smClass & CF_POS_MASK) {
......@@ -360,9 +359,7 @@ enum
};
// TODO: Find better names for these!
#define tagArray4 (nuktFeatureMask | akhnFeatureMask | vatuFeatureMask | presFeatureMask | \
blwsFeatureMask | abvsFeatureMask | pstsFeatureMask | halnFeatureMask | \
blwmFeatureMask | abvmFeatureMask | distFeatureMask)
#define tagArray4 (nuktFeatureMask | akhnFeatureMask | vatuFeatureMask | presFeatureMask | blwsFeatureMask | abvsFeatureMask | pstsFeatureMask | halnFeatureMask | blwmFeatureMask | abvmFeatureMask | distFeatureMask)
#define tagArray3 (pstfFeatureMask | tagArray4)
#define tagArray2 (halfFeatureMask | tagArray3)
#define tagArray1 (blwfFeatureMask | tagArray2)
......@@ -415,8 +412,7 @@ const FeatureMap *IndicReordering::getFeatureMap(le_int32 &count)
return featureMap;
}
le_int32 IndicReordering::findSyllable(const IndicClassTable *classTable,
const LEUnicode *chars, le_int32 prev, le_int32 charCount)
le_int32 IndicReordering::findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
{
le_int32 cursor = prev;
le_int8 state = 0;
......@@ -752,3 +748,5 @@ void IndicReordering::adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphS
delete mpreFixups;
}
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __INDICREORDERING_H
#define __INDICREORDERING_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
// Characters that get refered to by name...
#define C_SIGN_ZWNJ 0x200C
#define C_SIGN_ZWJ 0x200D
......@@ -140,7 +147,7 @@ struct IndicClassTable
static const IndicClassTable *getScriptClassTable(le_int32 scriptCode);
};
class IndicReordering {
class IndicReordering /* not : public UObject because all methods are static */ {
public:
static le_int32 getWorstCaseExpansion(le_int32 scriptCode);
......@@ -156,8 +163,7 @@ private:
// do not instantiate
IndicReordering();
static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars,
le_int32 prev, le_int32 charCount);
static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount);
};
......@@ -305,4 +311,5 @@ inline le_bool IndicClassTable::hasBelowBaseForm(LEUnicode ch) const
return hasBelowBaseForm(getCharClass(ch));
}
U_NAMESPACE_END
#endif
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 2004-2005 - All Rights Reserved
*
......@@ -39,6 +40,8 @@
#define DEBUG 0
U_NAMESPACE_BEGIN
struct PairInfo {
le_uint32 key; // sigh, MSVC compiler gags on union here
le_int16 value; // fword, kern value in funits
......@@ -191,6 +194,12 @@ void KernTable::process(LEGlyphStorage& storage)
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*)(p + rangeShift);
if (key > tp->key) {
......@@ -238,3 +247,6 @@ void KernTable::process(LEGlyphStorage& storage)
storage.adjustPosition(storage.getGlyphCount(), adjust, 0, success);
}
}
U_NAMESPACE_END
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 2004-2005 - All Rights Reserved
*
......@@ -37,9 +38,12 @@
#endif
#include "LETypes.h"
//#include "LEFontInstance.h"
//#include "LEGlyphStorage.h"
#include <stdio.h>
U_NAMESPACE_BEGIN
struct PairInfo;
class LEFontInstance;
class LEGlyphStorage;
......@@ -67,4 +71,6 @@ class U_LAYOUT_API KernTable
void process(LEGlyphStorage& storage);
};
U_NAMESPACE_END
#endif
......@@ -23,8 +23,8 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
* This file is a modification of the ICU file IndicLayoutEngine.cpp
......@@ -38,17 +38,20 @@
#include "LEGlyphStorage.h"
#include "KhmerReordering.h"
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags,
const GlyphSubstitutionTableHeader *gsubTable)
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
{
fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
fFeatureOrder = TRUE;
}
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags)
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
{
fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
......@@ -63,16 +66,14 @@ KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
// Input: characters
// Output: characters, char indices, tags
// Returns: output character count
le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 ||
offset >= max || offset + count > max) {
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
......@@ -96,9 +97,10 @@ le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
// NOTE: assumes this allocates featureTags...
// (probably better than doing the worst case stuff here...)
le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count,
fScriptCode, outChars, glyphStorage);
le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
glyphStorage.adoptGlyphCount(outCharCount);
return outCharCount;
}
U_NAMESPACE_END
......@@ -23,6 +23,7 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
......@@ -45,19 +46,18 @@
// #include "GlyphDefinitionTables.h"
// #include "GlyphPositioningTables.h"
U_NAMESPACE_BEGIN
// class MPreFixups;
// class LEGlyphStorage;
/**
* This class implements OpenType layout for Khmer OpenType fonts, as
* specified by Microsoft in "Creating and Supporting OpenType Fonts
* for Khmer Scripts"
* (http://www.microsoft.com/typography/otspec/indicot/default.htm)
* TODO: change url
* specified by Microsoft in "Creating and Supporting OpenType Fonts for
* Khmer Scripts" (http://www.microsoft.com/typography/otspec/indicot/default.htm) TODO: change url
*
* This class overrides the characterProcessing method to do Khmer
* character processing and reordering (See the MS spec. for more
* details)
* This class overrides the characterProcessing method to do Khmer character processing
* and reordering (See the MS spec. for more details)
*
* @internal
*/
......@@ -65,11 +65,10 @@ class KhmerOpenTypeLayoutEngine : public OpenTypeLayoutEngine
{
public:
/**
* This is the main constructor. It constructs an instance of
* KhmerOpenTypeLayoutEngine for a particular font, script and
* language. It takes the GSUB table as a parameter since
* LayoutEngine::layoutEngineFactory has to read the GSUB table to
* know that it has an Khmer OpenType font.
* This is the main constructor. It constructs an instance of KhmerOpenTypeLayoutEngine for
* a particular font, script and language. It takes the GSUB table as a parameter since
* LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
* Khmer OpenType font.
*
* @param fontInstance - the font
* @param scriptCode - the script
......@@ -82,14 +81,12 @@ public:
*
* @internal
*/
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags,
const GlyphSubstitutionTableHeader *gsubTable);
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
/**
* This constructor is used when the font requires a "canned" GSUB
* table which can't be known until after this constructor has
* been invoked.
* This constructor is used when the font requires a "canned" GSUB table which can't be known
* until after this constructor has been invoked.
*
* @param fontInstance - the font
* @param scriptCode - the script
......@@ -100,8 +97,8 @@ public:
*
* @internal
*/
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
le_int32 typoFlags);
/**
* The destructor, virtual for correct polymorphic invocation.
......@@ -110,25 +107,35 @@ public:
*/
virtual ~KhmerOpenTypeLayoutEngine();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
protected:
/**
* This method does Khmer OpenType character processing. It
* assigns the OpenType feature tags to the characters, and may
* generate output characters which have been reordered. It may
* also split some vowels, resulting in more output characters
* than input characters.
* This method does Khmer OpenType character processing. It assigns the OpenType feature
* tags to the characters, and may generate output characters which have been reordered.
* It may also split some vowels, resulting in more output characters than input characters.
*
* Input parameters:
* @param chars - the input character context
* @param offset - the index of the first character to process
* @param count - the number of characters to process
* @param max - the number of characters in the input context
* @param rightToLeft - <code>TRUE</code> if the characters are in
* a right to left directional run
* @param glyphStorage - the glyph storage object. The glyph and
* character index arrays will be set. the auxillary data array
* will be set to the feature tags.
* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
* @param glyphStorage - the glyph storage object. The glyph and character index arrays will be set.
* the auxillary data array will be set to the feature tags.
*
* Output parameters:
* @param success - set to an error code if the operation fails
......@@ -137,9 +144,11 @@ protected:
*
* @internal
*/
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
};
U_NAMESPACE_END
#endif
......@@ -37,6 +37,9 @@
#include "KhmerReordering.h"
#include "LEGlyphStorage.h"
U_NAMESPACE_BEGIN
// Characters that get refered to by name...
enum
{
......@@ -53,35 +56,23 @@ enum
enum
{
// simple classes, they are used in the statetable (in this file)
// to control the length of a syllable they are also used to know
// where a character should be placed (location in reference to
// the base character) and also to know if a character, when
// independtly displayed, should be displayed with a dotted-circle
// to indicate error in syllable construction
// simple classes, they are used in the statetable (in this file) to control the length of a syllable
// they are also used to know where a character should be placed (location in reference to the base character)
// and also to know if a character, when independtly displayed, should be displayed with a dotted-circle to
// indicate error in syllable construction
_xx = KhmerClassTable::CC_RESERVED,
_sa = KhmerClassTable::CC_SIGN_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE
| KhmerClassTable::CF_POS_ABOVE,
_sp = KhmerClassTable::CC_SIGN_AFTER | KhmerClassTable::CF_DOTTED_CIRCLE
| KhmerClassTable::CF_POS_AFTER,
_sa = KhmerClassTable::CC_SIGN_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_POS_ABOVE,
_sp = KhmerClassTable::CC_SIGN_AFTER | KhmerClassTable::CF_DOTTED_CIRCLE| KhmerClassTable::CF_POS_AFTER,
_c1 = KhmerClassTable::CC_CONSONANT | KhmerClassTable::CF_CONSONANT,
_c2 = KhmerClassTable::CC_CONSONANT2 | KhmerClassTable::CF_CONSONANT,
_c3 = KhmerClassTable::CC_CONSONANT3 | KhmerClassTable::CF_CONSONANT,
_rb = KhmerClassTable::CC_ROBAT | KhmerClassTable::CF_POS_ABOVE
| KhmerClassTable::CF_DOTTED_CIRCLE,
_cs = KhmerClassTable::CC_CONSONANT_SHIFTER | KhmerClassTable::CF_DOTTED_CIRCLE
| KhmerClassTable::CF_SHIFTER,
_dl = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BEFORE
| KhmerClassTable::CF_DOTTED_CIRCLE,
_db = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BELOW
| KhmerClassTable::CF_DOTTED_CIRCLE,
_da = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_ABOVE
| KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_ABOVE_VOWEL,
_dr = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_AFTER
| KhmerClassTable::CF_DOTTED_CIRCLE,
_co = KhmerClassTable::CC_COENG | KhmerClassTable::CF_COENG
| KhmerClassTable::CF_DOTTED_CIRCLE,
_rb = KhmerClassTable::CC_ROBAT | KhmerClassTable::CF_POS_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE,
_cs = KhmerClassTable::CC_CONSONANT_SHIFTER | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_SHIFTER,
_dl = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BEFORE | KhmerClassTable::CF_DOTTED_CIRCLE,
_db = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_BELOW | KhmerClassTable::CF_DOTTED_CIRCLE,
_da = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_ABOVE | KhmerClassTable::CF_DOTTED_CIRCLE | KhmerClassTable::CF_ABOVE_VOWEL,
_dr = KhmerClassTable::CC_DEPENDENT_VOWEL | KhmerClassTable::CF_POS_AFTER | KhmerClassTable::CF_DOTTED_CIRCLE,
_co = KhmerClassTable::CC_COENG | KhmerClassTable::CF_COENG | KhmerClassTable::CF_DOTTED_CIRCLE,
// split vowel
_va = _da | KhmerClassTable::CF_SPLIT_VOWEL,
......@@ -90,13 +81,10 @@ enum
// Character class tables
// _xx character does not combine into syllable, such as numbers,
// puntuation marks, non-Khmer signs...
// _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs...
// _sa Sign placed above the base
// _sp Sign placed after the base
// _c1 Consonant of type 1 or independent vowel (independent vowels
// behave as type 1 consonants)
// _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants)
// _c2 Consonant of type 2 (only RO)
// _c3 Consonant of type 3
// _rb Khmer sign robat u17CC. combining mark for subscript consonants
......@@ -105,13 +93,10 @@ enum
// _db Dependent vowel placed below the base
// _da Dependent vowel placed above the base
// _dr Dependent vowel placed behind the base (right of the base)
// _co Khmer combining mark COENG u17D2, combines with the consonant
// or independent vowel following it to create a subscript consonant
// or independent vowel
// _va Khmer split vowel in wich the first part is before the base and
// the second one above the base
// _vr Khmer split vowel in wich the first part is before the base and
// the second one behind (right of) the base
// _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following
// it to create a subscript consonant or independent vowel
// _va Khmer split vowel in wich the first part is before the base and the second one above the base
// _vr Khmer split vowel in wich the first part is before the base and the second one behind (right of) the base
static const KhmerClassTable::CharClass khmerCharClasses[] =
{
......@@ -129,19 +114,19 @@ static const KhmerClassTable::CharClass khmerCharClasses[] =
//
//
// The range of characters defined in the above table is defined
// here. FOr Khmer 1780 to 17DF Even if the Khmer range is bigger, all
// other characters are not combinable, and therefore treated as _xx
// The range of characters defined in the above table is defined here. FOr Khmer 1780 to 17DF
// Even if the Khmer range is bigger, all other characters are not combinable, and therefore treated
// as _xx
static const KhmerClassTable khmerClassTable = {0x1780, 0x17df, khmerCharClasses};
// Below we define how a character in the input string is either in
// the khmerCharClasses table (in which case we get its type back), a
// ZWJ or ZWNJ (two characters that may appear within the syllable,
// but are not in the table) we also get their type back, or an
// unknown object in which case we get _xx (CC_RESERVED) back
// Below we define how a character in the input string is either in the khmerCharClasses table
// (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear
// within the syllable, but are not in the table) we also get their type back, or an unknown object
// in which case we get _xx (CC_RESERVED) back
KhmerClassTable::CharClass KhmerClassTable::getCharClass(LEUnicode ch) const
{
if (ch == C_SIGN_ZWJ) {
return CC_ZERO_WIDTH_J_MARK;
}
......@@ -164,13 +149,14 @@ const KhmerClassTable *KhmerClassTable::getKhmerClassTable()
class ReorderingOutput {
class ReorderingOutput : public UMemory {
private:
le_int32 fOutIndex;
LEUnicode *fOutChars;
LEGlyphStorage &fGlyphStorage;
public:
ReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage)
: fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage)
......@@ -232,18 +218,11 @@ public:
#define abvmFeatureMask 0x00100000UL
#define mkmkFeatureMask 0x00080000UL
#define tagPref (prefFeatureMask | presFeatureMask | \
cligFeatureMask | distFeatureMask)
#define tagAbvf (abvfFeatureMask | abvsFeatureMask | \
cligFeatureMask | distFeatureMask | abvmFeatureMask | mkmkFeatureMask)
#define tagPstf (blwfFeatureMask | blwsFeatureMask | prefFeatureMask | \
presFeatureMask | pstfFeatureMask | pstsFeatureMask | cligFeatureMask | \
distFeatureMask | blwmFeatureMask)
#define tagBlwf (blwfFeatureMask | blwsFeatureMask | cligFeatureMask | \
distFeatureMask | blwmFeatureMask | mkmkFeatureMask)
#define tagDefault (prefFeatureMask | blwfFeatureMask | presFeatureMask | \
blwsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | \
blwmFeatureMask | mkmkFeatureMask)
#define tagPref (prefFeatureMask | presFeatureMask | cligFeatureMask | distFeatureMask)
#define tagAbvf (abvfFeatureMask | abvsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | mkmkFeatureMask)
#define tagPstf (blwfFeatureMask | blwsFeatureMask | prefFeatureMask | presFeatureMask | pstfFeatureMask | pstsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask)
#define tagBlwf (blwfFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask | mkmkFeatureMask)
#define tagDefault (prefFeatureMask | blwfFeatureMask | presFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask | mkmkFeatureMask)
......@@ -274,35 +253,32 @@ static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
// The stateTable is used to calculate the end (the length) of a well
// formed Khmer Syllable.
//
// Each horizontal line is ordered exactly the same way as the values
// in KhmerClassTable CharClassValues in KhmerReordering.h This
// coincidence of values allows the follow up of the table.
// Each horizontal line is ordered exactly the same way as the values in KhmerClassTable
// CharClassValues in KhmerReordering.h This coincidence of values allows the
// follow up of the table.
//
// Each line corresponds to a state, which does not necessarily need
// to be a type of component... for example, state 2 is a base, with
// is always a first character in the syllable, but the state could be
// produced a consonant of any type when it is the first character
// that is analysed (in ground state).
// Each line corresponds to a state, which does not necessarily need to be a type
// of component... for example, state 2 is a base, with is always a first character
// in the syllable, but the state could be produced a consonant of any type when
// it is the first character that is analysed (in ground state).
//
// Differentiating 3 types of consonants is necessary in order to
// forbid the use of certain combinations, such as having a second
// coeng after a coeng RO.
// The inexistent possibility of having a type 3 after another type 3
// is permitted, eliminating it would very much complicate the table,
// and it does not create typing problems, as the case above.
// coeng after a coeng RO,
// The inexistent possibility of having a type 3 after another type 3 is permitted,
// eliminating it would very much complicate the table, and it does not create typing
// problems, as the case above.
//
// The table is quite complex, in order to limit the number of coeng
// consonants to 2 (by means of the table).
// The table is quite complex, in order to limit the number of coeng consonants
// to 2 (by means of the table).
//
// There a peculiarity, as far as Unicode is concerned:
// - The consonant-shifter is considered in two possible different
// locations, the one considered in Unicode 3.0 and the one considered
// in Unicode 4.0. (there is a backwards compatibility problem in this
// standard).
// locations, the one considered in Unicode 3.0 and the one considered in
// Unicode 4.0. (there is a backwards compatibility problem in this standard).
// xx independent character, such as a number, punctuation sign or
// non-khmer char
// xx independent character, such as a number, punctuation sign or non-khmer char
//
// c1 Khmer consonant of type 1 or an independent vowel
// that is, a letter in which the subscript for is only under the
......@@ -320,10 +296,9 @@ static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
//
// co coeng character (u17D2)
//
// dv dependent vowel (including split vowels, they are treated in the
// same way). even if dv is not defined above, the component that is
// really tested for is KhmerClassTable::CC_DEPENDENT_VOWEL, which is
// common to all dependent vowels
// dv dependent vowel (including split vowels, they are treated in the same way).
// even if dv is not defined above, the component that is really tested for is
// KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels
//
// zwj Zero Width joiner
//
......@@ -352,8 +327,7 @@ static const le_int8 khmerStateTable[][KhmerClassTable::CC_COUNT] =
{-1, -1, -1, -1, 12, 13, -1, -1, 16, 17, 1, 14}, // 8 - First consonant of type 2 after coeng
{-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 9 - First consonant or type 3 after ceong
{-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, // 10 - Second Coeng (no register shifter before)
{-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 11 - Second coeng consonant
// (or ind. vowel) no register shifter before
{-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 11 - Second coeng consonant (or ind. vowel) no register shifter before
{-1, -1, 1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, // 12 - Second ZWNJ before a register shifter
{-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 13 - Second register shifter
{-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 14 - ZWJ before vowel
......@@ -363,6 +337,7 @@ static const le_int8 khmerStateTable[][KhmerClassTable::CC_COUNT] =
{-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, // 18 - ZWJ after vowel
{-1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, // 19 - Third coeng
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, // 20 - dependent vowel after a Robat
};
......@@ -377,15 +352,13 @@ const FeatureMap *KhmerReordering::getFeatureMap(le_int32 &count)
// Given an input string of characters and a location in which to start looking
// calculate, using the state table, which one is the last character of the syllable
// that starts in the starting position.
le_int32 KhmerReordering::findSyllable(const KhmerClassTable *classTable,
const LEUnicode *chars, le_int32 prev, le_int32 charCount)
le_int32 KhmerReordering::findSyllable(const KhmerClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
{
le_int32 cursor = prev;
le_int8 state = 0;
while (cursor < charCount) {
KhmerClassTable::CharClass charClass = (classTable->getCharClass(chars[cursor])
& KhmerClassTable::CF_CLASS_MASK);
KhmerClassTable::CharClass charClass = (classTable->getCharClass(chars[cursor]) & KhmerClassTable::CF_CLASS_MASK);
state = khmerStateTable[state][charClass];
......@@ -402,8 +375,8 @@ le_int32 KhmerReordering::findSyllable(const KhmerClassTable *classTable,
// This is the real reordering function as applied to the Khmer language
le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount,
le_int32 /*scriptCode*/, LEUnicode *outChars, LEGlyphStorage &glyphStorage)
le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32 /*scriptCode*/,
LEUnicode *outChars, LEGlyphStorage &glyphStorage)
{
const KhmerClassTable *classTable = KhmerClassTable::getKhmerClassTable();
......@@ -442,8 +415,7 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount,
// and because CC_CONSONANT2 is enough to identify it, as it is the only consonant
// with this flag
if ( (charClass & KhmerClassTable::CF_COENG) && (i + 1 < syllable) &&
( (classTable->getCharClass(chars[i + 1]) &
KhmerClassTable::CF_CLASS_MASK) == KhmerClassTable::CC_CONSONANT2) )
( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK) == KhmerClassTable::CC_CONSONANT2) )
{
coengRo = i;
}
......@@ -455,16 +427,15 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount,
output.writeChar(C_RO, coengRo + 1, tagPref);
}
// shall we add a dotted circle? If in the position in which
// the base should be (first char in the string) there is a
// character that has the Dotted circle flag (a character that
// cannot be a base) then write a dotted circle
// shall we add a dotted circle?
// If in the position in which the base should be (first char in the string) there is
// a character that has the Dotted circle flag (a character that cannot be a base)
// then write a dotted circle
if (classTable->getCharClass(chars[prev]) & KhmerClassTable::CF_DOTTED_CIRCLE) {
output.writeChar(C_DOTTED_CIRCLE, prev, tagDefault);
}
// copy what is left to the output, skipping before vowels and
// coeng Ro if they are present
// copy what is left to the output, skipping before vowels and coeng Ro if they are present
for (i = prev; i < syllable; i += 1) {
charClass = classTable->getCharClass(chars[i]);
......@@ -515,30 +486,14 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount,
// and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two
// different positions, right after the shifter or after a vowel (Unicode 4)
if ( (charClass & KhmerClassTable::CF_SHIFTER) && (i + 1 < syllable) ) {
if (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_ABOVE_VOWEL ) {
output.writeChar(chars[i], i, tagBlwf);
break;
}
if (i + 2 < syllable &&
( (classTable->getCharClass(chars[i + 1]) &
KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA) &&
( (classTable->getCharClass(chars[i + 2]) &
KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT) )
{
output.writeChar(chars[i], i, tagBlwf);
break;
}
if (i + 3 < syllable && (classTable->getCharClass(chars[i + 3]) &
KhmerClassTable::CF_ABOVE_VOWEL) )
{
output.writeChar(chars[i], i, tagBlwf);
break;
}
if (i + 4 < syllable &&
( (classTable->getCharClass(chars[i + 3]) &
KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA) &&
( (classTable->getCharClass(chars[i + 4]) &
KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT) )
if ((classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_ABOVE_VOWEL)
|| (i + 2 < syllable
&& ( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA)
&& ( (classTable->getCharClass(chars[i + 2]) & KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT))
|| (i + 3 < syllable && (classTable->getCharClass(chars[i + 3]) & KhmerClassTable::CF_ABOVE_VOWEL))
|| (i + 4 < syllable
&& ( (classTable->getCharClass(chars[i + 3]) & KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA)
&& ( (classTable->getCharClass(chars[i + 4]) & KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT) ) )
{
output.writeChar(chars[i], i, tagBlwf);
break;
......@@ -556,3 +511,6 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount,
return output.getOutputIndex();
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
* This file is a modification of the ICU file IndicReordering.h
......@@ -35,80 +34,60 @@
#ifndef __KHMERREORDERING_H
#define __KHMERREORDERING_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
// Vocabulary
// Base ->
// A consonant or an independent vowel in its full (not
// subscript) form. It is the center of the syllable, it can be
// souranded by coeng (subscript) consonants, vowels, split
// vowels, signs... but there is only one base in a syllable, it
// has to be coded as the first character of the syllable.
// split vowel ->
// vowel that has two parts placed separately (e.g. Before and
// after the consonant). Khmer language has five of them. Khmer
// split vowels either have one part before the base and one after
// the base or they have a part before the base and a part above
// the base. The first part of all Khmer split vowels is the same
// character, identical to the glyph of Khmer dependent vowel SRA
// EI
// coeng ->
// modifier used in Khmer to construct coeng (subscript)
// consonants differently than indian languages, the coeng
// modifies the consonant that follows it, not the one preceding
// it Each consonant has two forms, the base form and the
// subscript form the base form is the normal one (using the
// consonants code-point), the subscript form is displayed when
// the combination coeng + consonant is encountered.
// Consonant of type 1 ->
// A consonant which has subscript for that only occupies space
// under a base consonant
// Consonant of type 2 ->
// Its subscript form occupies space under and before the base
// (only one, RO)
// Consonant of Type 3 ->
// Its subscript form occupies space under and after the base
// (KHO, CHHO, THHO, BA, YO, SA)
// Consonant shifter ->
// Khmer has to series of consonants. The same dependent vowel has
// different sounds if it is attached to a consonant of the first
// series or a consonant of the second series Most consonants have
// an equivalent in the other series, but some of theme exist only
// in one series (for example SA). If we want to use the consonant
// SA with a vowel sound that can only be done with a vowel sound
// that corresponds to a vowel accompanying a consonant of the
// other series, then we need to use a consonant shifter: TRIISAP
// or MUSIKATOAN x17C9 y x17CA. TRIISAP changes a first series
// consonant to second series sound and MUSIKATOAN a second series
// consonant to have a first series vowel sound. Consonant
// shifter are both normally supercript marks, but, when they are
// followed by a superscript, they change shape and take the form
// of subscript dependent vowel SRA U. If they are in the same
// syllable as a coeng consonant, Unicode 3.0 says that they
// should be typed before the coeng. Unicode 4.0 breaks the
// standard and says that it should be placed after the coeng
// consonant.
// Dependent vowel ->
// In khmer dependent vowels can be placed above, below, before or
// after the base Each vowel has its own position. Only one vowel
// per syllable is allowed.
// Signs ->
// Khmer has above signs and post signs. Only one above sign
// and/or one post sign are Allowed in a syllable.
// Base -> A consonant or an independent vowel in its full (not subscript) form. It is the
// center of the syllable, it can be souranded by coeng (subscript) consonants, vowels,
// split vowels, signs... but there is only one base in a syllable, it has to be coded as
// the first character of the syllable.
// split vowel --> vowel that has two parts placed separately (e.g. Before and after the consonant).
// Khmer language has five of them. Khmer split vowels either have one part before the
// base and one after the base or they have a part before the base and a part above the base.
// The first part of all Khmer split vowels is the same character, identical to
// the glyph of Khmer dependent vowel SRA EI
// coeng --> modifier used in Khmer to construct coeng (subscript) consonants
// Differently than indian languages, the coeng modifies the consonant that follows it,
// not the one preceding it Each consonant has two forms, the base form and the subscript form
// the base form is the normal one (using the consonants code-point), the subscript form is
// displayed when the combination coeng + consonant is encountered.
// Consonant of type 1 -> A consonant which has subscript for that only occupies space under a base consonant
// Consonant of type 2.-> Its subscript form occupies space under and before the base (only one, RO)
// Consonant of Type 3 -> Its subscript form occupies space under and after the base (KHO, CHHO, THHO, BA, YO, SA)
// Consonant shifter -> Khmer has to series of consonants. The same dependent vowel has different sounds
// if it is attached to a consonant of the first series or a consonant of the second series
// Most consonants have an equivalent in the other series, but some of theme exist only in
// one series (for example SA). If we want to use the consonant SA with a vowel sound that
// can only be done with a vowel sound that corresponds to a vowel accompanying a consonant
// of the other series, then we need to use a consonant shifter: TRIISAP or MUSIKATOAN
// x17C9 y x17CA. TRIISAP changes a first series consonant to second series sound and
// MUSIKATOAN a second series consonant to have a first series vowel sound.
// Consonant shifter are both normally supercript marks, but, when they are followed by a
// superscript, they change shape and take the form of subscript dependent vowel SRA U.
// If they are in the same syllable as a coeng consonant, Unicode 3.0 says that they
// should be typed before the coeng. Unicode 4.0 breaks the standard and says that it should
// be placed after the coeng consonant.
// Dependent vowel -> In khmer dependent vowels can be placed above, below, before or after the base
// Each vowel has its own position. Only one vowel per syllable is allowed.
// Signs -> Khmer has above signs and post signs. Only one above sign and/or one post sign are
// Allowed in a syllable.
//
//
// This list must include all types of components that can be used
// inside a syllable
struct KhmerClassTable
struct KhmerClassTable // This list must include all types of components that can be used inside a syllable
{
// order is important here! This order must be the same that is
// found in each horizontal line in the statetable for Khmer (file
// KhmerReordering.cpp).
enum CharClassValues
enum CharClassValues // order is important here! This order must be the same that is found in each horizontal
// line in the statetable for Khmer (file KhmerReordering.cpp).
{
CC_RESERVED = 0,
CC_CONSONANT = 1, // consonant of type 1 or independent vowel
......@@ -116,8 +95,7 @@ struct KhmerClassTable
CC_CONSONANT3 = 3, // Consonant of type 3
CC_ZERO_WIDTH_NJ_MARK = 4, // Zero Width non joiner character (0x200C)
CC_CONSONANT_SHIFTER = 5,
CC_ROBAT = 6, // Khmer special diacritic accent
// -treated differently in state table
CC_ROBAT = 6, // Khmer special diacritic accent -treated differently in state table
CC_COENG = 7, // Subscript consonant combining character
CC_DEPENDENT_VOWEL = 8,
CC_SIGN_ABOVE = 9,
......@@ -131,10 +109,8 @@ struct KhmerClassTable
CF_CLASS_MASK = 0x0000FFFF,
CF_CONSONANT = 0x01000000, // flag to speed up comparing
CF_SPLIT_VOWEL = 0x02000000, // flag for a split vowel -> the first part
// is added in front of the syllable
CF_DOTTED_CIRCLE = 0x04000000, // add a dotted circle if a character with
// this flag is the first in a syllable
CF_SPLIT_VOWEL = 0x02000000, // flag for a split vowel -> the first part is added in front of the syllable
CF_DOTTED_CIRCLE = 0x04000000, // add a dotted circle if a character with this flag is the first in a syllable
CF_COENG = 0x08000000, // flag to speed up comparing
CF_SHIFTER = 0x10000000, // flag to speed up comparing
CF_ABOVE_VOWEL = 0x20000000, // flag to speed up comparing
......@@ -161,10 +137,10 @@ struct KhmerClassTable
};
class KhmerReordering {
class KhmerReordering /* not : public UObject because all methods are static */ {
public:
static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount,
le_int32 scriptCode, LEUnicode *outChars, LEGlyphStorage &glyphStorage);
static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode,
LEUnicode *outChars, LEGlyphStorage &glyphStorage);
static const FeatureMap *getFeatureMap(le_int32 &count);
......@@ -172,8 +148,10 @@ private:
// do not instantiate
KhmerReordering();
static le_int32 findSyllable(const KhmerClassTable *classTable,
const LEUnicode *chars, le_int32 prev, le_int32 charCount);
static le_int32 findSyllable(const KhmerClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount);
};
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
*******************************************************************************
*
* Copyright (C) 1999-2005, International Business Machines
......@@ -42,6 +41,10 @@
#include "LEFontInstance.h"
#include "LEGlyphStorage.h"
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEFontInstance)
const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit,
le_int32 script, LEErrorCode &success) const
{
......@@ -59,7 +62,7 @@ const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int
}
void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
{
le_int32 i, out = 0, dir = 1;
......@@ -100,3 +103,5 @@ LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *map
return mapCharToGlyph(mappedChar);
}
U_NAMESPACE_END
......@@ -34,6 +34,12 @@
#define __LEFONTINSTANCE_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Layout Engine Font Instance object
*/
U_NAMESPACE_BEGIN
/**
* Instances of this class are used by <code>LEFontInstance::mapCharsToGlyphs</code> and
......@@ -44,7 +50,7 @@
*
* @stable ICU 3.2
*/
class LECharMapper
class LECharMapper /* not : public UObject because this is an interface/mixin class */
{
public:
/**
......@@ -97,7 +103,7 @@ class LEGlyphStorage;
*
* @draft ICU 3.0
*/
class LEFontInstance
class U_LAYOUT_API LEFontInstance : public UObject
{
public:
......@@ -160,8 +166,7 @@ public:
*
* @stable ICU 3.2
*/
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset,
le_int32 limit, le_int32 script, LEErrorCode &success) const;
virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const;
//
// Font file access
......@@ -238,8 +243,7 @@ public:
*
* @draft ICU 3.0
*/
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const;
virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const;
/**
* This method maps a single character to a glyph index, using the
......@@ -502,6 +506,21 @@ public:
* @stable ICU 3.2
*/
virtual le_int32 getLineHeight() const;
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 3.2
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 3.2
*/
static UClassID getStaticClassID();
};
inline le_bool LEFontInstance::canDisplay(LEUnicode32 ch) const
......@@ -562,4 +581,7 @@ inline le_int32 LEFontInstance::getLineHeight() const
return getAscent() + getDescent() + getLeading();
}
U_NAMESPACE_END
#endif
......@@ -34,14 +34,15 @@
#include "LETypes.h"
U_NAMESPACE_BEGIN
/**
* This is a helper class that is used to
* recognize a set of glyph indices.
*
* @internal
*/
class LEGlyphFilter
{
class LEGlyphFilter /* not : public UObject because this is an interface/mixin class */ {
public:
/**
* Destructor.
......@@ -63,4 +64,5 @@ public:
virtual le_bool accept(LEGlyphID glyph) const = 0;
};
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
**********************************************************************
* Copyright (C) 1998-2005, International Business Machines
* Corporation and others. All Rights Reserved.
......@@ -35,6 +34,10 @@
#include "LEInsertionList.h"
#include "LEGlyphStorage.h"
U_NAMESPACE_BEGIN
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEGlyphStorage)
LEGlyphStorage::LEGlyphStorage()
: fGlyphCount(0), fGlyphs(NULL), fCharIndices(NULL), fPositions(NULL),
fAuxData(NULL), fInsertionList(NULL), fSrcIndex(0), fDestIndex(0)
......@@ -603,3 +606,6 @@ le_bool LEGlyphStorage::applyInsertion(le_int32 atPosition, le_int32 count, LEGl
return FALSE;
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
**********************************************************************
* Copyright (C) 1998-2005, International Business Machines
* Corporation and others. All Rights Reserved.
......@@ -37,6 +36,13 @@
#include "LETypes.h"
#include "LEInsertionList.h"
/**
* \file
* \brief C++ API: This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
*/
U_NAMESPACE_BEGIN
/**
* This class encapsulates the per-glyph storage used by the ICU LayoutEngine.
* For each glyph it holds the glyph ID, the index of the backing store character
......@@ -50,7 +56,7 @@
*
* @draft ICU 3.6
*/
class U_LAYOUT_API LEGlyphStorage : protected LEInsertionCallback
class U_LAYOUT_API LEGlyphStorage : public UObject, protected LEInsertionCallback
{
private:
/**
......@@ -112,35 +118,37 @@ private:
protected:
/**
* This implements <code>LEInsertionCallback</code>. The
* <code>LEInsertionList</code> will call this method once for
* each insertion.
* This implements <code>LEInsertionCallback</code>. The <code>LEInsertionList</code>
* will call this method once for each insertion.
*
* @param atPosition the position of the insertion
* @param count the number of glyphs being inserted
* @param newGlyphs the address of the new glyph IDs
*
* @return <code>true</code> if <code>LEInsertionList</code>
* should stop processing the insertion list after this insertion.
* @return <code>true</code> if <code>LEInsertionList</code> should stop
* processing the insertion list after this insertion.
*
* @see LEInsertionList.h
*
* @draft ICU 3.0
*/
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count,
LEGlyphID newGlyphs[]);
virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]);
public:
/**
* Allocates an empty <code>LEGlyphStorage</code> object. You must
* call <code>allocateGlyphArray, allocatePositions and
* allocateAuxData</code> to allocate the data.
* Allocates an empty <code>LEGlyphStorage</code> object. You must call
* <code>allocateGlyphArray, allocatePositions and allocateAuxData</code>
* to allocate the data.
*
* @draft ICU 3.0
*/
LEGlyphStorage();
/**
* The destructor. This will deallocate all of the arrays.
*
* @draft ICU 3.0
*/
~LEGlyphStorage();
......@@ -154,9 +162,9 @@ public:
inline le_int32 getGlyphCount() const;
/**
* This method copies the glyph array into a caller supplied
* array. The caller must ensure that the array is large enough
* to hold all the glyphs.
* This method copies the glyph array into a caller supplied array.
* The caller must ensure that the array is large enough to hold all
* the glyphs.
*
* @param glyphs - the destiniation glyph array
* @param success - set to an error code if the operation fails
......@@ -166,10 +174,10 @@ public:
void getGlyphs(LEGlyphID glyphs[], LEErrorCode &success) const;
/**
* This method copies the glyph array into a caller supplied
* array, ORing in extra bits. (This functionality is needed by
* the JDK, which uses 32 bits pre glyph idex, with the high 16
* bits encoding the composite font slot number)
* This method copies the glyph array into a caller supplied array,
* ORing in extra bits. (This functionality is needed by the JDK,
* which uses 32 bits pre glyph idex, with the high 16 bits encoding
* the composite font slot number)
*
* @param glyphs - the destination (32 bit) glyph array
* @param extraBits - this value will be ORed with each glyph index
......@@ -177,13 +185,12 @@ public:
*
* @draft ICU 3.0
*/
void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits,
LEErrorCode &success) const;
void getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const;
/**
* This method copies the character index array into a caller
* supplied array. The caller must ensure that the array is large
* enough to hold a character index for each glyph.
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param success - set to an error code if the operation fails
......@@ -193,9 +200,9 @@ public:
void getCharIndices(le_int32 charIndices[], LEErrorCode &success) const;
/**
* This method copies the character index array into a caller
* supplied array. The caller must ensure that the array is large
* enough to hold a character index for each glyph.
* This method copies the character index array into a caller supplied array.
* The caller must ensure that the array is large enough to hold a
* character index for each glyph.
*
* @param charIndices - the destiniation character index array
* @param indexBase - an offset which will be added to each index
......@@ -203,14 +210,13 @@ public:
*
* @draft ICU 3.0
*/
void getCharIndices(le_int32 charIndices[], le_int32 indexBase,
LEErrorCode &success) const;
void getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const;
/**
* This method copies the position array into a caller supplied
* array. The caller must ensure that the array is large enough
* to hold an X and Y position for each glyph, plus an extra X and
* Y for the advance of the last glyph.
* This method copies the position array into a caller supplied array.
* The caller must ensure that the array is large enough to hold an
* X and Y position for each glyph, plus an extra X and Y for the
* advance of the last glyph.
*
* @param positions - the destiniation position array
* @param success - set to an error code if the operation fails
......@@ -233,33 +239,27 @@ public:
*
* @draft ICU 3.0
*/
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y,
LEErrorCode &success) const;
void getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const;
/**
* This method allocates the glyph array, the char indices array
* and the insertion list. You must call this method before using
* the object. This method also initializes the char indices
* This method allocates the glyph array, the char indices array and the insertion list. You
* must call this method before using the object. This method also initializes the char indices
* array.
* @param initialGlyphCount the initial size of the glyph and char
* indices arrays.
* @param rightToLeft <code>true</code> if the original input text
* is right to left.
* @param success set to an error code if the storage cannot be
* allocated of if the initial glyph count is not positive.
*
* @param initialGlyphCount the initial size of the glyph and char indices arrays.
* @param rightToLeft <code>true</code> if the original input text is right to left.
* @param success set to an error code if the storage cannot be allocated of if the initial
* glyph count is not positive.
*
* @draft ICU 3.0
*/
void allocateGlyphArray(le_int32 initialGlyphCount, le_bool rightToLeft,
LEErrorCode &success);
void allocateGlyphArray(le_int32 initialGlyphCount, le_bool rightToLeft, LEErrorCode &success);
/**
* This method allocates the storage for the glyph positions. It
* allocates one extra X, Y position pair for the position just
* after the last glyph.
* This method allocates the storage for the glyph positions. It allocates one extra X, Y
* position pair for the position just after the last glyph.
*
* @param success set to an error code if the positions array
* cannot be allocated.
* @param success set to an error code if the positions array cannot be allocated.
*
* @return the number of X, Y position pairs allocated.
*
......@@ -270,8 +270,7 @@ public:
/**
* This method allocates the storage for the auxillary glyph data.
*
* @param success set to an error code if the aulillary data array
* cannot be allocated.
* @param success set to an error code if the aulillary data array cannot be allocated.
*
* @return the size of the auxillary data array.
*
......@@ -282,10 +281,8 @@ public:
/**
* Copy the entire auxillary data array.
*
* @param auxData the auxillary data array will be copied to this
* address
* @param success set to an error code if the data cannot be
* copied
* @param auxData the auxillary data array will be copied to this address
* @param success set to an error code if the data cannot be copied
*
* @draft ICU 3.6
*/
......@@ -295,8 +292,7 @@ public:
* Get the glyph ID for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the glyph ID cannot be
* retrieved.
* @param success set to an error code if the glyph ID cannot be retrieved.
*
* @return the glyph ID
*
......@@ -308,8 +304,7 @@ public:
* Get the char index for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the char index cannot be
* retrieved.
* @param success set to an error code if the char index cannot be retrieved.
*
* @return the character index
*
......@@ -322,8 +317,7 @@ public:
* Get the auxillary data for a particular glyph.
*
* @param glyphIndex the index into the glyph array
* @param success set to an error code if the auxillary data
* cannot be retrieved.
* @param success set to an error code if the auxillary data cannot be retrieved.
*
* @return the auxillary data
*
......@@ -345,11 +339,10 @@ public:
/**
* Call this method to replace a single glyph in the glyph array
* with multiple glyphs. This method uses the
* <code>LEInsertionList</code> to do the insertion. It returns
* the address of storage where the new glyph IDs can be
* stored. They will not actually be inserted into the glyph array
* until <code>applyInsertions</code> is called.
* with multiple glyphs. This method uses the <code>LEInsertionList</code>
* to do the insertion. It returns the address of storage where the new
* glyph IDs can be stored. They will not actually be inserted into the
* glyph array until <code>applyInsertions</code> is called.
*
* @param atIndex the index of the glyph to be replaced
* @param insertCount the number of glyphs to replace it with
......@@ -381,26 +374,22 @@ public:
*
* @param glyphIndex the index of the glyph
* @param glyphID the new glyph ID
* @param success will be set to an error code if the glyph ID
* cannot be set.
* @param success will be set to an error code if the glyph ID cannot be set.
*
* @draft ICU 3.0
*/
void setGlyphID(le_int32 glyphIndex, LEGlyphID glyphID,
LEErrorCode &success);
void setGlyphID(le_int32 glyphIndex, LEGlyphID glyphID, LEErrorCode &success);
/**
* Set the char index for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param charIndex the new char index
* @param success will be set to an error code if the char index
* cannot be set.
* @param success will be set to an error code if the char index cannot be set.
*
* @draft ICU 3.0
*/
void setCharIndex(le_int32 glyphIndex, le_int32 charIndex,
LEErrorCode &success);
void setCharIndex(le_int32 glyphIndex, le_int32 charIndex, LEErrorCode &success);
/**
* Set the X, Y position for a particular glyph.
......@@ -408,13 +397,11 @@ public:
* @param glyphIndex the index of the glyph
* @param x the new X position
* @param y the new Y position
* @param success will be set to an error code if the position
* cannot be set.
* @param success will be set to an error code if the position cannot be set.
*
* @draft ICU 3.0
*/
void setPosition(le_int32 glyphIndex, float x, float y,
LEErrorCode &success);
void setPosition(le_int32 glyphIndex, float x, float y, LEErrorCode &success);
/**
* Adjust the X, Y position for a particular glyph.
......@@ -422,21 +409,18 @@ public:
* @param glyphIndex the index of the glyph
* @param xAdjust the adjustment to the glyph's X position
* @param yAdjust the adjustment to the glyph's Y position
* @param success will be set to an error code if the glyph's
* position cannot be adjusted.
* @param success will be set to an error code if the glyph's position cannot be adjusted.
*
* @draft ICU 3.0
*/
void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust,
LEErrorCode &success);
void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust, LEErrorCode &success);
/**
* Set the auxillary data for a particular glyph.
*
* @param glyphIndex the index of the glyph
* @param auxData the new auxillary data
* @param success will be set to an error code if the auxillary
* data cannot be set.
* @param success will be set to an error code if the auxillary data cannot be set.
*
* @draft ICU 3.6
*/
......@@ -511,14 +495,28 @@ public:
void adoptGlyphCount(le_int32 newGlyphCount);
/**
* This method frees the glyph, character index, position and
* auxillary data arrays so that the LayoutEngine can be reused to
* layout a different characer array. (This method is also called
* This method frees the glyph, character index, position and
* auxillary data arrays so that the LayoutEngine can be reused
* to layout a different characer array. (This method is also called
* by the destructor)
*
* @draft ICU 3.0
*/
void reset();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @draft ICU 3.0
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @draft ICU 3.0
*/
static UClassID getStaticClassID();
};
inline le_int32 LEGlyphStorage::getGlyphCount() const
......@@ -531,4 +529,7 @@ inline LEGlyphID &LEGlyphStorage::operator[](le_int32 glyphIndex) const
return fGlyphs[glyphIndex];
}
U_NAMESPACE_END
#endif
......@@ -24,7 +24,6 @@
*/
/*
*
**********************************************************************
* Copyright (C) 1998-2004, International Business Machines
* Corporation and others. All Rights Reserved.
......@@ -34,6 +33,8 @@
#include "LETypes.h"
#include "LEInsertionList.h"
U_NAMESPACE_BEGIN
#define ANY_NUMBER 1
struct InsertionRecord
......@@ -44,6 +45,8 @@ struct InsertionRecord
LEGlyphID glyphs[ANY_NUMBER];
};
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEInsertionList)
LEInsertionList::LEInsertionList(le_bool rightToLeft)
: head(NULL), tail(NULL), growAmount(0), append(rightToLeft)
{
......@@ -106,3 +109,5 @@ le_bool LEInsertionList::applyInsertions(LEInsertionCallback *callback)
return FALSE;
}
U_NAMESPACE_END
......@@ -24,7 +24,6 @@
*/
/*
*
**********************************************************************
* Copyright (C) 1998-2004, International Business Machines
* Corporation and others. All Rights Reserved.
......@@ -36,6 +35,8 @@
#include "LETypes.h"
U_NAMESPACE_BEGIN
struct InsertionRecord;
/**
......@@ -78,7 +79,7 @@ public:
*
* @internal
*/
class LEInsertionList
class LEInsertionList : public UObject
{
public:
/**
......@@ -140,6 +141,20 @@ public:
*/
void reset();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
private:
/**
......@@ -174,4 +189,6 @@ private:
le_bool append;
};
U_NAMESPACE_END
#endif
......@@ -25,10 +25,12 @@
/*
*
* (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
* (C) Copyright IBM Corp. 1998-2005. All Rights Reserved.
*
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
* YOU REALLY KNOW WHAT YOU'RE DOING.
*
* Generated on: 07/19/2005 01:01:08 PM PDT
*/
#ifndef __LELANGUAGES_H
......@@ -36,12 +38,19 @@
#include "LETypes.h"
/**
* \file
* \brief C++ API: List of language codes for LayoutEngine
*/
U_NAMESPACE_BEGIN
/**
* A provisional list of language codes. For now,
* this is just a list of languages which the LayoutEngine
* supports.
*
* @draft ICU 3.0
* @draft ICU 3.4
*/
enum LanguageCodes {
......@@ -79,4 +88,5 @@ enum LanguageCodes {
languageCodeCount = 30
};
U_NAMESPACE_END
#endif
......@@ -25,17 +25,23 @@
/*
*
* (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
* (C) Copyright IBM Corp. 1998-2005. All Rights Reserved.
*
* WARNING: THIS FILE IS MACHINE GENERATED. DO NOT HAND EDIT IT UNLESS
* YOU REALLY KNOW WHAT YOU'RE DOING.
*
*/
#ifndef __LESCRIPTS_H
#define __LESCRIPTS_H
#include "LETypes.h"
/**
* \file
* \brief C++ API: Constants for Unicode script values
*/
U_NAMESPACE_BEGIN
/**
* Constants for Unicode script values, generated using
......@@ -104,4 +110,5 @@ enum ScriptCodes {
scriptCodeCount = 55
};
U_NAMESPACE_END
#endif
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
#ifndef __LESTANDALONE
#define __LESTANDALONE
/* Definitions to make Layout Engine work away from ICU. */
#ifndef U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
#endif
#ifndef U_NAMESPACE_END
#define U_NAMESPACE_END
#endif
/* RTTI Definition */
typedef const char *UClassID;
#ifndef UOBJECT_DEFINE_RTTI_IMPLEMENTATION
#define UOBJECT_DEFINE_RTTI_IMPLEMENTATION(x) UClassID x::getStaticClassID(){static char z=0; return (UClassID)&z; } UClassID x::getDynamicClassID() const{return x::getStaticClassID(); }
#endif
/* UMemory's functions aren't used by the layout engine. */
struct UMemory {};
/* UObject's functions aren't used by the layout engine. */
struct UObject {};
/* String handling */
#include <stdlib.h>
#include <string.h>
/**
* A convenience macro to test for the success of a LayoutEngine call.
*
* @stable ICU 2.4
*/
#define LE_SUCCESS(code) ((code)<=LE_NO_ERROR)
/**
* A convenience macro to test for the failure of a LayoutEngine call.
*
* @stable ICU 2.4
*/
#define LE_FAILURE(code) ((code)>LE_NO_ERROR)
#ifndef _LP64
typedef long le_int32;
typedef unsigned long le_uint32;
#else
typedef int le_int32;
typedef unsigned int le_uint32;
#endif
#define HAVE_LE_INT32 1
#define HAVE_LE_UINT32 1
typedef unsigned short UChar;
typedef le_uint32 UChar32;
typedef short le_int16;
#define HAVE_LE_INT16 1
typedef unsigned short le_uint16;
#define HAVE_LE_UINT16
typedef signed char le_int8;
#define HAVE_LE_INT8
typedef unsigned char le_uint8;
#define HAVE_LE_UINT8
typedef char UBool;
/**
* Error codes returned by the LayoutEngine.
*
* @stable ICU 2.4
*/
enum LEErrorCode {
/* informational */
LE_NO_SUBFONT_WARNING = -127, // U_USING_DEFAULT_WARNING,
/* success */
LE_NO_ERROR = 0, // U_ZERO_ERROR,
/* failures */
LE_ILLEGAL_ARGUMENT_ERROR = 1, // U_ILLEGAL_ARGUMENT_ERROR,
LE_MEMORY_ALLOCATION_ERROR = 7, // U_MEMORY_ALLOCATION_ERROR,
LE_INDEX_OUT_OF_BOUNDS_ERROR = 8, //U_INDEX_OUTOFBOUNDS_ERROR,
LE_NO_LAYOUT_ERROR = 16, // U_UNSUPPORTED_ERROR,
LE_INTERNAL_ERROR = 5, // U_INTERNAL_PROGRAM_ERROR,
LE_FONT_FILE_NOT_FOUND_ERROR = 4, // U_FILE_ACCESS_ERROR,
LE_MISSING_FONT_TABLE_ERROR = 2 // U_MISSING_RESOURCE_ERROR
};
#define HAVE_LEERRORCODE
#define U_LAYOUT_API
#define uprv_malloc malloc
#define uprv_free free
#define uprv_memcpy memcpy
#define uprv_realloc realloc
#if !defined(U_IS_BIG_ENDIAN)
#ifdef _LITTLE_ENDIAN
#define U_IS_BIG_ENDIAN 0
#endif
#endif
#endif
......@@ -26,7 +26,7 @@
/*
*
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
*/
......@@ -35,11 +35,12 @@
#include "LETypes.h"
#if !defined(U_IS_BIG_ENDIAN)
#ifdef _LITTLE_ENDIAN
#define U_IS_BIG_ENDIAN 0
#endif
#endif
/**
* \file
* \brief C++ API: Endian independent access to data for LayoutEngine
*/
U_NAMESPACE_BEGIN
/**
* A convenience macro which invokes the swapWord member function
......@@ -47,7 +48,6 @@
*
* @stable ICU 2.8
*/
#if defined(U_IS_BIG_ENDIAN)
#if U_IS_BIG_ENDIAN
#define SWAPW(value) (value)
......@@ -64,7 +64,6 @@
*
* @stable ICU 2.8
*/
#if defined(U_IS_BIG_ENDIAN)
#if U_IS_BIG_ENDIAN
#define SWAPL(value) (value)
......@@ -86,8 +85,7 @@
*
* @stable ICU 2.8
*/
class LESwaps
{
class U_LAYOUT_API LESwaps /* not : public UObject because all methods are static */ {
public:
#if !defined(U_IS_BIG_ENDIAN)
......@@ -144,4 +142,5 @@ private:
LESwaps() {} // private - forbid instantiation
};
U_NAMESPACE_END
#endif
......@@ -23,7 +23,6 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
......@@ -33,75 +32,99 @@
#ifndef __LETYPES_H
#define __LETYPES_H
/**
* If LE_Standalone is defined, it must exist and contain
* definitions for some core ICU defines.
*/
#ifdef LE_STANDALONE
#include "LEStandalone.h"
#endif
#ifdef LE_STANDALONE
/* Stand-alone Layout Engine- without ICU. */
#include "LEStandalone.h"
#define LE_USE_CMEMORY
#else
#if !defined(LE_USE_CMEMORY) && (defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_STATIC_IMPLEMENTATION) || defined(U_COMBINED_IMPLEMENTATION))
#define LE_USE_CMEMORY
#endif
#include "unicode/utypes.h"
#include "unicode/uobject.h"
#ifdef LE_USE_CMEMORY
#include <stdlib.h>
#include <string.h>
#include "cmemory.h"
#endif
#endif /* not standalone */
#ifndef _LP64
typedef long le_int32;
typedef unsigned long le_uint32;
#else
typedef int le_int32;
typedef unsigned int le_uint32;
#endif
typedef short le_int16;
typedef unsigned short le_uint16;
typedef signed char le_int8;
typedef unsigned char le_uint8;
typedef char le_bool;
U_NAMESPACE_BEGIN
typedef char UClassID;
/*!
* \file
* \brief Basic definitions for the ICU LayoutEngine
*/
#if 0
/**
* A type used for signed, 32-bit integers.
*
* @stable ICU 2.4
*/
#ifndef HAVE_LE_INT32
typedef int32_t le_int32;
#endif
/**
* A type used for unsigned, 32-bit integers.
*
* @stable ICU 2.4
*/
#ifndef HAVE_LE_UINT32
typedef uint32_t le_uint32;
#endif
/**
* A type used for signed, 16-bit integers.
*
* @stable ICU 2.4
*/
#ifndef HAVE_LE_INT16
typedef int16_t le_int16;
#endif
#ifndef HAVE_LE_UINT16
/**
* A type used for unsigned, 16-bit integers.
*
* @stable ICU 2.4
*/
typedef uint16_t le_uint16;
#endif
#ifndef HAVE_LE_INT8
/**
* A type used for signed, 8-bit integers.
*
* @stable ICU 2.4
*/
typedef int8_t le_int8;
#endif
#ifndef HAVE_LE_UINT8
/**
* A type used for unsigned, 8-bit integers.
*
* @stable ICU 2.4
*/
typedef uint8_t le_uint8;
typedef char le_bool;
#endif
/**
* A type used for boolean values.
*
* @stable ICU 2.4
*/
typedef UBool le_bool;
#ifndef TRUE
/**
* Used for <code>le_bool</code> values which are <code>true</code>.
......@@ -264,21 +287,21 @@ typedef le_uint32 LEGlyphID;
*
* @stable ICU 2.4
*/
typedef le_uint16 LEUnicode16;
typedef UChar LEUnicode16;
/**
* Used to represent 32-bit Unicode code points.
*
* @stable ICU 2.4
*/
typedef le_uint32 LEUnicode32;
typedef UChar32 LEUnicode32;
/**
* Used to represent 16-bit Unicode code points.
*
* @deprecated since ICU 2.4. Use LEUnicode16 instead
*/
typedef le_uint16 LEUnicode;
typedef UChar LEUnicode;
/**
* Used to hold a pair of (x, y) values which represent a point.
......@@ -325,7 +348,7 @@ typedef struct LEPoint LEPoint;
*
* @internal
*/
#define LE_ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
#define LE_ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
/**
* Allocate an array of basic types. This is used to isolate the rest of
......@@ -333,7 +356,7 @@ typedef struct LEPoint LEPoint;
*
* @internal
*/
#define LE_NEW_ARRAY(type, count) (type *) malloc((count) * sizeof(type))
#define LE_NEW_ARRAY(type, count) (type *) uprv_malloc((count) * sizeof(type))
/**
* Re-allocate an array of basic types. This is used to isolate the rest of
......@@ -341,7 +364,7 @@ typedef struct LEPoint LEPoint;
*
* @internal
*/
#define LE_GROW_ARRAY(array, newSize) realloc((void *) (array), (newSize) * sizeof (array)[0])
#define LE_GROW_ARRAY(array, newSize) uprv_realloc((void *) (array), (newSize) * sizeof (array)[0])
/**
* Free an array of basic types. This is used to isolate the rest of
......@@ -349,7 +372,7 @@ typedef struct LEPoint LEPoint;
*
* @internal
*/
#define LE_DELETE_ARRAY(array) free((void *) (array))
#define LE_DELETE_ARRAY(array) uprv_free((void *) (array))
#endif
/**
......@@ -567,22 +590,24 @@ enum LEFeatureTags {
*
* @stable ICU 2.4
*/
#ifndef HAVE_LEERRORCODE
enum LEErrorCode {
/* informational */
LE_NO_SUBFONT_WARNING = -127, // U_USING_DEFAULT_WARNING,
LE_NO_SUBFONT_WARNING = U_USING_DEFAULT_WARNING, /**< The font does not contain subfonts. */
/* success */
LE_NO_ERROR = 0, // U_ZERO_ERROR,
LE_NO_ERROR = U_ZERO_ERROR, /**< No error, no warning. */
/* failures */
LE_ILLEGAL_ARGUMENT_ERROR = 1, // U_ILLEGAL_ARGUMENT_ERROR,
LE_MEMORY_ALLOCATION_ERROR = 7, // U_MEMORY_ALLOCATION_ERROR,
LE_INDEX_OUT_OF_BOUNDS_ERROR = 8, //U_INDEX_OUTOFBOUNDS_ERROR,
LE_NO_LAYOUT_ERROR = 16, // U_UNSUPPORTED_ERROR,
LE_INTERNAL_ERROR = 5, // U_INTERNAL_PROGRAM_ERROR,
LE_FONT_FILE_NOT_FOUND_ERROR = 4, // U_FILE_ACCESS_ERROR,
LE_MISSING_FONT_TABLE_ERROR = 2 // U_MISSING_RESOURCE_ERROR
LE_ILLEGAL_ARGUMENT_ERROR = U_ILLEGAL_ARGUMENT_ERROR, /**< An illegal argument was detected. */
LE_MEMORY_ALLOCATION_ERROR = U_MEMORY_ALLOCATION_ERROR, /**< Memory allocation error. */
LE_INDEX_OUT_OF_BOUNDS_ERROR = U_INDEX_OUTOFBOUNDS_ERROR, /**< Trying to access an index that is out of bounds. */
LE_NO_LAYOUT_ERROR = U_UNSUPPORTED_ERROR, /**< You must call layoutChars() first. */
LE_INTERNAL_ERROR = U_INTERNAL_PROGRAM_ERROR, /**< An internal error was encountered. */
LE_FONT_FILE_NOT_FOUND_ERROR = U_FILE_ACCESS_ERROR, /**< The requested font file cannot be opened. */
LE_MISSING_FONT_TABLE_ERROR = U_MISSING_RESOURCE_ERROR /**< The requested font table does not exist. */
};
#endif
#ifndef XP_CPLUSPLUS
/**
......@@ -598,14 +623,20 @@ typedef enum LEErrorCode LEErrorCode;
*
* @stable ICU 2.4
*/
#define LE_SUCCESS(code) ((code)<=LE_NO_ERROR)
#ifndef LE_FAILURE
#define LE_SUCCESS(code) (U_SUCCESS((UErrorCode)code))
#endif
/**
* A convenience macro to test for the failure of a LayoutEngine call.
*
* @stable ICU 2.4
*/
#define LE_FAILURE(code) ((code)>LE_NO_ERROR)
#ifndef LE_FAILURE
#define LE_FAILURE(code) (U_FAILURE((UErrorCode)code))
#endif
#define U_LAYOUT_API
U_NAMESPACE_END
#endif
......@@ -23,6 +23,7 @@
*
*/
/*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
......@@ -40,6 +41,7 @@
#include "IndicLayoutEngine.h"
#include "KhmerLayoutEngine.h"
#include "ThaiLayoutEngine.h"
//#include "TibetanLayoutEngine.h"
#include "GXLayoutEngine.h"
#include "ScriptAndLanguageTags.h"
#include "CharSubstitutionFilter.h"
......@@ -55,6 +57,8 @@
#include "KernTable.h"
U_NAMESPACE_BEGIN
const LEUnicode32 DefaultCharMapper::controlChars[] = {
0x0009, 0x000A, 0x000D,
/*0x200C, 0x200D,*/ 0x200E, 0x200F,
......@@ -101,9 +105,7 @@ LEUnicode32 DefaultCharMapper::mapChar(LEUnicode32 ch) const
}
if (fMirror) {
le_int32 index = OpenTypeUtilities::search((le_uint32) ch,
(le_uint32 *)DefaultCharMapper::mirroredChars,
DefaultCharMapper::mirroredCharsCount);
le_int32 index = OpenTypeUtilities::search((le_uint32) ch, (le_uint32 *)DefaultCharMapper::mirroredChars, DefaultCharMapper::mirroredCharsCount);
if (mirroredChars[index] == ch) {
return DefaultCharMapper::srahCderorrim[index];
......@@ -132,6 +134,9 @@ CharSubstitutionFilter::~CharSubstitutionFilter()
// nothing to do
}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LayoutEngine)
#define ccmpFeatureTag LE_CCMP_FEATURE_TAG
#define ccmpFeatureMask 0x80000000UL
......@@ -145,10 +150,9 @@ static const FeatureMap canonFeatureMap[] =
static const le_int32 canonFeatureMapCount = LE_ARRAY_SIZE(canonFeatureMap);
LayoutEngine::LayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode,
le_int32 languageCode, le_int32 typoFlags)
: fGlyphStorage(NULL), fFontInstance(fontInstance), fScriptCode(scriptCode),
fLanguageCode(languageCode), fTypoFlags(typoFlags)
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();
}
......@@ -158,8 +162,7 @@ le_int32 LayoutEngine::getGlyphCount() const
return fGlyphStorage->getGlyphCount();
}
void LayoutEngine::getCharIndices(le_int32 charIndices[], le_int32 indexBase,
LEErrorCode &success) const
void LayoutEngine::getCharIndices(le_int32 charIndices[], le_int32 indexBase, LEErrorCode &success) const
{
fGlyphStorage->getCharIndices(charIndices, indexBase, success);
}
......@@ -170,8 +173,7 @@ void LayoutEngine::getCharIndices(le_int32 charIndices[], LEErrorCode &success)
}
// Copy the glyphs into caller's (32-bit) glyph array, OR in extraBits
void LayoutEngine::getGlyphs(le_uint32 glyphs[], le_uint32 extraBits,
LEErrorCode &success) const
void LayoutEngine::getGlyphs(le_uint32 glyphs[], le_uint32 extraBits, LEErrorCode &success) const
{
fGlyphStorage->getGlyphs(glyphs, extraBits, success);
}
......@@ -218,15 +220,13 @@ void LayoutEngine::getGlyphPositions(float positions[], LEErrorCode &success) co
fGlyphStorage->getGlyphPositions(positions, success);
}
void LayoutEngine::getGlyphPosition(le_int32 glyphIndex, float &x, float &y,
LEErrorCode &success) const
void LayoutEngine::getGlyphPosition(le_int32 glyphIndex, float &x, float &y, LEErrorCode &success) const
{
fGlyphStorage->getGlyphPosition(glyphIndex, x, y, success);
}
le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft, LEUnicode *&outChars,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
......@@ -237,12 +237,7 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off
return 0;
}
if ((fTypoFlags & 0x4) == 0) { // no canonical processing
return count;
}
const GlyphSubstitutionTableHeader *canonGSUBTable =
(GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
LETag scriptTag = OpenTypeLayoutEngine::getScriptTag(fScriptCode);
LETag langSysTag = OpenTypeLayoutEngine::getLangSysTag(fLanguageCode);
le_int32 i, dir = 1, out = 0, outCharCount = count;
......@@ -256,16 +251,15 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off
// We could just do the mark reordering for all scripts, but most
// of them probably don't need it...
if (fScriptCode == hebrScriptCode) {
reordered = LE_NEW_ARRAY(LEUnicode, count);
reordered = LE_NEW_ARRAY(LEUnicode, count);
if (reordered == NULL) {
success = LE_MEMORY_ALLOCATION_ERROR;
return 0;
}
if (reordered == NULL) {
success = LE_MEMORY_ALLOCATION_ERROR;
return 0;
}
CanonShaping::reorderMarks(&chars[offset], count, rightToLeft,
reordered, glyphStorage);
inChars = reordered;
CanonShaping::reorderMarks(&chars[offset], count, rightToLeft, reordered, glyphStorage);
inChars = reordered;
}
glyphStorage.allocateGlyphArray(count, rightToLeft, success);
......@@ -289,8 +283,7 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off
LE_DELETE_ARRAY(reordered);
}
outCharCount = canonGSUBTable->process(glyphStorage, rightToLeft, scriptTag,
langSysTag, NULL, substitutionFilter, canonFeatureMap, canonFeatureMapCount, FALSE);
outCharCount = canonGSUBTable->process(glyphStorage, rightToLeft, scriptTag, langSysTag, NULL, substitutionFilter, canonFeatureMap, canonFeatureMapCount, FALSE);
out = (rightToLeft? count - 1 : 0);
......@@ -305,35 +298,26 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off
return outCharCount;
}
le_int32 LayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
le_int32 LayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max ||
offset + count > max) {
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
LEUnicode *outChars = NULL;
le_int32 outCharCount = characterProcessing(chars, offset, count, max,
rightToLeft, outChars, glyphStorage, success);
le_int32 outCharCount = characterProcessing(chars, offset, count, max, rightToLeft, outChars, glyphStorage, success);
if (outChars != NULL) {
mapCharsToGlyphs(outChars, 0, outCharCount, rightToLeft, rightToLeft,
glyphStorage, success);
// FIXME: a subclass may have allocated this, in which case this delete
// might not work...
LE_DELETE_ARRAY(outChars);
mapCharsToGlyphs(outChars, 0, outCharCount, rightToLeft, rightToLeft, glyphStorage, success);
LE_DELETE_ARRAY(outChars); // FIXME: a subclass may have allocated this, in which case this delete might not work...
} else {
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft,
glyphStorage, success);
mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphStorage, success);
}
return glyphStorage.getGlyphCount();
......@@ -341,8 +325,7 @@ le_int32 LayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset,
// Input: glyphs
// Output: positions
void LayoutEngine::positionGlyphs(LEGlyphStorage &glyphStorage,
float x, float y, LEErrorCode &success)
void LayoutEngine::positionGlyphs(LEGlyphStorage &glyphStorage, float x, float y, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -369,9 +352,8 @@ void LayoutEngine::positionGlyphs(LEGlyphStorage &glyphStorage,
glyphStorage.setPosition(glyphCount, x, y, success);
}
void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -398,8 +380,7 @@ void LayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset
return;
}
void LayoutEngine::adjustMarkGlyphs(LEGlyphStorage &glyphStorage,
LEGlyphFilter *markFilter, LEErrorCode &success)
void LayoutEngine::adjustMarkGlyphs(LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success)
{
float xAdjust = 0;
le_int32 p, glyphCount = glyphStorage.getGlyphCount();
......@@ -435,9 +416,7 @@ void LayoutEngine::adjustMarkGlyphs(LEGlyphStorage &glyphStorage,
glyphStorage.adjustPosition(glyphCount, xAdjust, 0, success);
}
void LayoutEngine::adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount,
le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter,
LEErrorCode &success)
void LayoutEngine::adjustMarkGlyphs(const LEUnicode chars[], le_int32 charCount, le_bool reverse, LEGlyphStorage &glyphStorage, LEGlyphFilter *markFilter, LEErrorCode &success)
{
float xAdjust = 0;
le_int32 c = 0, direction = 1, p;
......@@ -484,9 +463,8 @@ const void *LayoutEngine::getFontTable(LETag tableTag) const
return fFontInstance->getFontTable(tableTag);
}
void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
le_int32 count, le_bool reverse, le_bool mirror,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
LEGlyphStorage &glyphStorage, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return;
......@@ -496,32 +474,27 @@ void LayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset,
DefaultCharMapper charMapper(TRUE, mirror);
fFontInstance->mapCharsToGlyphs(chars, offset, count, reverse,
&charMapper, glyphStorage);
fFontInstance->mapCharsToGlyphs(chars, offset, count, reverse, &charMapper, glyphStorage);
}
// 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,
float x, float y, LEErrorCode &success)
le_int32 LayoutEngine::layoutChars(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
float x, float y, LEErrorCode &success)
{
if (LE_FAILURE(success)) {
return 0;
}
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max ||
offset + count > max) {
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
le_int32 glyphCount;
glyphCount = computeGlyphs(chars, offset, count, max, rightToLeft,
*fGlyphStorage, success);
glyphCount = computeGlyphs(chars, offset, count, max, rightToLeft, *fGlyphStorage, success);
positionGlyphs(*fGlyphStorage, x, y, success);
adjustGlyphPositions(chars, offset, count, rightToLeft, *fGlyphStorage, success);
......@@ -533,17 +506,13 @@ void LayoutEngine::reset()
fGlyphStorage->reset();
}
LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstance,
le_int32 scriptCode, le_int32 languageCode, LEErrorCode &success)
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);
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)
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;
......@@ -552,18 +521,12 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
return NULL;
}
// code2000 has GPOS kern feature tags for latn script
const GlyphSubstitutionTableHeader *gsubTable =
(const GlyphSubstitutionTableHeader *) fontInstance->getFontTable(gsubTableTag);
const GlyphSubstitutionTableHeader *gsubTable = (const GlyphSubstitutionTableHeader *) fontInstance->getFontTable(gsubTableTag);
LayoutEngine *result = NULL;
LETag scriptTag = 0x00000000;
LETag languageTag = 0x00000000;
if (gsubTable != NULL &&
gsubTable->coversScript(scriptTag =
OpenTypeLayoutEngine::getScriptTag(scriptCode))) {
if (gsubTable != NULL && gsubTable->coversScript(scriptTag = OpenTypeLayoutEngine::getScriptTag(scriptCode))) {
switch (scriptCode) {
case bengScriptCode:
case devaScriptCode:
......@@ -575,13 +538,11 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case tamlScriptCode:
case teluScriptCode:
case sinhScriptCode:
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
case arabScriptCode:
result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
case haniScriptCode:
......@@ -593,33 +554,33 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case zhtLanguageCode:
case zhsLanguageCode:
if (gsubTable->coversScriptAndLanguage(scriptTag, languageTag, TRUE)) {
result = new HanOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new HanOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
// note: falling through to default case.
default:
result = new OpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
break;
#if 0
case tibtScriptCode:
result = new TibetanOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
#endif
case khmrScriptCode:
result = new KhmerOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new KhmerOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
default:
result = new OpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags, gsubTable);
result = new OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
break;
}
} else {
const MorphTableHeader *morphTable =
(MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
const MorphTableHeader *morphTable = (MorphTableHeader *) fontInstance->getFontTable(mortTableTag);
if (morphTable != NULL) {
result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, morphTable);
......@@ -636,16 +597,18 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
case teluScriptCode:
case sinhScriptCode:
{
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags);
result = new IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
}
case arabScriptCode:
result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode,
languageCode, typoFlags);
//case hebrScriptCode:
result = new UnicodeArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
//case hebrScriptCode:
// return new HebrewOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
case thaiScriptCode:
result = new ThaiLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
break;
......@@ -667,3 +630,5 @@ LayoutEngine *LayoutEngine::layoutEngineFactory(const LEFontInstance *fontInstan
LayoutEngine::~LayoutEngine() {
delete fGlyphStorage;
}
U_NAMESPACE_END
......@@ -32,11 +32,20 @@
#ifndef __LAYOUTTABLES_H
#define __LAYOUTTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
U_NAMESPACE_BEGIN
#define ANY_NUMBER 1
typedef le_int16 ByteOffset;
typedef le_int16 WordOffset;
U_NAMESPACE_END
#endif
......@@ -39,10 +39,14 @@
#include "LEGlyphStorage.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
#define ExtendedComplement(m) ((le_int32) (~((le_uint32) (m))))
#define SignBit(m) ((ExtendedComplement(m) >> 1) & (le_int32)(m))
#define SignExtend(v,m) (((v) & SignBit(m))? ((v) | ExtendedComplement(m)): (v))
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LigatureSubstitutionProcessor)
LigatureSubstitutionProcessor::LigatureSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader)
: StateTableProcessor(morphSubtableHeader)
{
......@@ -63,8 +67,7 @@ void LigatureSubstitutionProcessor::beginStateTable()
m = -1;
}
ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage,
le_int32 &currGlyph, EntryTableIndex index)
ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
{
const LigatureSubstitutionStateEntry *entry = &entryTable[index];
ByteOffset newState = SWAPW(entry->newStateOffset);
......@@ -135,3 +138,5 @@ ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyp
void LigatureSubstitutionProcessor::endStateTable()
{
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __LIGATURESUBSTITUTIONPROCESSOR_H
#define __LIGATURESUBSTITUTIONPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "MorphTables.h"
#include "SubtableProcessor.h"
#include "StateTableProcessor.h"
#include "LigatureSubstitution.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
#define nComponents 16
......@@ -54,6 +61,20 @@ public:
LigatureSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader);
virtual ~LigatureSubstitutionProcessor();
/**
* ICU "poor man's RTTI", returns a UClassID for the actual class.
*
* @stable ICU 2.8
*/
virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @stable ICU 2.8
*/
static UClassID getStaticClassID();
private:
LigatureSubstitutionProcessor();
......@@ -68,6 +89,8 @@ protected:
le_int16 m;
const LigatureSubstitutionHeader *ligatureSubstitutionHeader;
};
U_NAMESPACE_END
#endif
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
*
......@@ -37,6 +38,8 @@
#include "GlyphIterator.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
{
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
......@@ -92,3 +95,5 @@ le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, co
return 0;
}
U_NAMESPACE_END
......@@ -32,12 +32,19 @@
#ifndef __LIGATURESUBSTITUTIONSUBTABLES_H
#define __LIGATURESUBSTITUTIONSUBTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "OpenTypeTables.h"
#include "GlyphSubstitutionTables.h"
#include "GlyphIterator.h"
U_NAMESPACE_BEGIN
struct LigatureSetTable
{
le_uint16 ligatureCount;
......@@ -59,4 +66,5 @@ struct LigatureSubstitutionSubtable : GlyphSubstitutionSubtable
le_uint32 process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter = NULL) const;
};
U_NAMESPACE_END
#endif
......@@ -32,12 +32,19 @@
#ifndef __LIGATURESUBSTITUTION_H
#define __LIGATURESUBSTITUTION_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LayoutTables.h"
#include "StateTables.h"
#include "MorphTables.h"
#include "MorphStateTables.h"
U_NAMESPACE_BEGIN
struct LigatureSubstitutionHeader : MorphStateTableHeader
{
ByteOffset ligatureActionTableOffset;
......@@ -65,4 +72,5 @@ enum LigatureActionFlags
lafComponentOffsetMask = 0x3FFFFFFF
};
U_NAMESPACE_END
#endif
......@@ -42,6 +42,8 @@
#include "LEGlyphStorage.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_uint32 LookupProcessor::applyLookupTable(const LookupTable *lookupTable, GlyphIterator *glyphIterator,
const LEFontInstance *fontInstance) const
{
......@@ -65,10 +67,9 @@ le_uint32 LookupProcessor::applyLookupTable(const LookupTable *lookupTable, Glyp
return 1;
}
le_int32 LookupProcessor::process(LEGlyphStorage &glyphStorage,
GlyphPositionAdjustments *glyphPositionAdjustments,
le_bool rightToLeft, const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance) const
le_int32 LookupProcessor::process(LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments,
le_bool rightToLeft, const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance) const
{
le_int32 glyphCount = glyphStorage.getGlyphCount();
......@@ -133,8 +134,7 @@ le_int32 LookupProcessor::selectLookups(const FeatureTable *featureTable, Featur
LookupProcessor::LookupProcessor(const char *baseAddress,
Offset scriptListOffset, Offset featureListOffset, Offset lookupListOffset,
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap,
le_int32 featureMapCount, le_bool orderFeatures)
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool orderFeatures)
: lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL),
lookupOrderArray(NULL), lookupOrderCount(0)
{
......@@ -296,3 +296,5 @@ LookupProcessor::~LookupProcessor()
LE_DELETE_ARRAY(lookupOrderArray);
LE_DELETE_ARRAY(lookupSelectArray);
}
U_NAMESPACE_END
......@@ -24,6 +24,7 @@
*/
/*
*
*
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
*
......@@ -32,9 +33,18 @@
#ifndef __LOOKUPPROCESSOR_H
#define __LOOKUPPROCESSOR_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
//#include "Lookups.h"
//#include "Features.h"
U_NAMESPACE_BEGIN
class LEFontInstance;
class LEGlyphStorage;
......@@ -46,13 +56,10 @@ struct GlyphDefinitionTableHeader;
struct LookupSubtable;
struct LookupTable;
class LookupProcessor
{
class LookupProcessor : public UMemory {
public:
le_int32 process(LEGlyphStorage &glyphStorage,
GlyphPositionAdjustments *glyphPositionAdjustments,
le_bool rightToLeft, const GlyphDefinitionTableHeader *glyphDefinitionTableHeader,
const LEFontInstance *fontInstance) const;
le_int32 process(LEGlyphStorage &glyphStorage, GlyphPositionAdjustments *glyphPositionAdjustments,
le_bool rightToLeft, const GlyphDefinitionTableHeader *glyphDefinitionTableHeader, const LEFontInstance *fontInstance) const;
le_uint32 applyLookupTable(const LookupTable *lookupTable, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const;
......@@ -64,19 +71,18 @@ public:
virtual ~LookupProcessor();
protected:
LookupProcessor(const char *baseAddress,
LookupProcessor(const char *baseAddress,
Offset scriptListOffset, Offset featureListOffset, Offset lookupListOffset,
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap,
le_int32 featureMapCount, le_bool orderFeatures);
LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool orderFeatures);
LookupProcessor();
LookupProcessor();
le_int32 selectLookups(const FeatureTable *featureTable, FeatureMask featureMask, le_int32 order);
const LookupListTable *lookupListTable;
const FeatureListTable *featureListTable;
FeatureMask *lookupSelectArray;
FeatureMask *lookupSelectArray;
le_uint16 *lookupOrderArray;
le_uint32 lookupOrderCount;
......@@ -87,4 +93,5 @@ private:
LookupProcessor &operator=(const LookupProcessor &other); // forbid copying of this class
};
U_NAMESPACE_END
#endif
......@@ -34,6 +34,8 @@
#include "LookupTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
/*
These are the rolled-up versions of the uniform binary search.
Someday, if we need more performance, we can un-roll them.
......@@ -104,3 +106,5 @@ const LookupSingle *BinarySearchLookupTable::lookupSingle(const LookupSingle *en
return NULL;
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __LOOKUPTABLES_H
#define __LOOKUPTABLES_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LayoutTables.h"
U_NAMESPACE_BEGIN
enum LookupTableFormat
{
ltfSimpleArray = 0,
......@@ -104,4 +111,5 @@ struct TrimmedArrayLookupTable : LookupTable
LookupValue valueArray[ANY_NUMBER];
};
U_NAMESPACE_END
#endif
......@@ -35,6 +35,8 @@
#include "CoverageTables.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
const LookupTable *LookupListTable::getLookupTable(le_uint16 lookupTableIndex) const
{
if (lookupTableIndex >= SWAPW(lookupCount)) {
......@@ -63,3 +65,5 @@ le_int32 LookupSubtable::getGlyphCoverage(Offset tableOffset, LEGlyphID glyphID)
return coverageTable->getGlyphCoverage(glyphID);
}
U_NAMESPACE_END
......@@ -32,9 +32,16 @@
#ifndef __LOOKUPS_H
#define __LOOKUPS_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
enum LookupFlags
{
lfBaselineIsLogicalEnd = 0x0001, // The MS spec. calls this flag "RightToLeft" but this name is more accurate
......@@ -79,6 +86,5 @@ inline le_int32 LookupSubtable::getGlyphCoverage(LEGlyphID glyphID) const
return getGlyphCoverage(coverageTableOffset, glyphID);
}
U_NAMESPACE_END
#endif
......@@ -33,6 +33,8 @@
#include "LEGlyphStorage.h"
#include "MPreFixups.h"
U_NAMESPACE_BEGIN
struct FixupData
{
le_int32 fBaseIndex;
......@@ -92,7 +94,7 @@ void MPreFixups::apply(LEGlyphStorage &glyphStorage)
for (i = 0; i < mpreCount; i += 1) {
mpreSave[i] = glyphStorage[mpreIndex + i];
indexSave[i] = glyphStorage.getCharIndex(mpreIndex + i, success);
indexSave[i] = glyphStorage.getCharIndex(mpreIndex + i, success); //charIndices[mpreIndex + i];
}
for (i = 0; i < moveCount; i += 1) {
......@@ -112,3 +114,5 @@ void MPreFixups::apply(LEGlyphStorage &glyphStorage)
LE_DELETE_ARRAY(mpreSave);
}
}
U_NAMESPACE_END
......@@ -32,14 +32,22 @@
#ifndef __MPREFIXUPS_H
#define __MPREFIXUPS_H
/**
* \file
* \internal
*/
#include "LETypes.h"
U_NAMESPACE_BEGIN
class LEGlyphStorage;
// Might want to make this a private member...
struct FixupData;
class MPreFixups {
class MPreFixups : public UMemory
{
public:
MPreFixups(le_int32 charCount);
~MPreFixups();
......@@ -53,4 +61,7 @@ private:
le_int32 fFixupCount;
};
U_NAMESPACE_END
#endif
......@@ -36,6 +36,8 @@
#include "MarkArrays.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
le_int32 MarkArray::getMarkClass(LEGlyphID glyphID, le_int32 coverageIndex, const LEFontInstance *fontInstance,
LEPoint &anchor) const
{
......@@ -58,3 +60,5 @@ le_int32 MarkArray::getMarkClass(LEGlyphID glyphID, le_int32 coverageIndex, cons
return markClass;
}
U_NAMESPACE_END
......@@ -32,10 +32,17 @@
#ifndef __MARKARRAYS_H
#define __MARKARRAYS_H
/**
* \file
* \internal
*/
#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
U_NAMESPACE_BEGIN
struct MarkRecord
{
le_uint16 markClass;
......@@ -51,4 +58,7 @@ struct MarkArray
LEPoint &anchor) const;
};
U_NAMESPACE_END
#endif
......@@ -40,6 +40,8 @@
#include "GlyphIterator.h"
#include "LESwaps.h"
U_NAMESPACE_BEGIN
LEGlyphID MarkToBasePositioningSubtable::findBaseGlyph(GlyphIterator *glyphIterator) const
{
if (glyphIterator->prev()) {
......@@ -106,7 +108,6 @@ le_int32 MarkToBasePositioningSubtable::process(GlyphIterator *glyphIterator, co
glyphIterator->setCurrGlyphBaseOffset(baseIterator.getCurrStreamPosition());
if (glyphIterator->isRightToLeft()) {
// dlf flip advance to local coordinate system
glyphIterator->setCurrGlyphPositionAdjustment(anchorDiffX, anchorDiffY, -markAdvance.fX, -markAdvance.fY);
} else {
LEPoint baseAdvance;
......@@ -114,9 +115,10 @@ le_int32 MarkToBasePositioningSubtable::process(GlyphIterator *glyphIterator, co
fontInstance->getGlyphAdvance(baseGlyph, pixels);
fontInstance->pixelsToUnits(pixels, baseAdvance);
// flip advances to local coordinate system
glyphIterator->setCurrGlyphPositionAdjustment(anchorDiffX - baseAdvance.fX, anchorDiffY - baseAdvance.fY, -markAdvance.fX, -markAdvance.fY);
}
return 1;
}
U_NAMESPACE_END
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册