2000-11-28 20:56:52 +00:00
|
|
|
/*
|
2004-04-12 18:51:31 +00:00
|
|
|
*
|
|
|
|
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
|
|
|
|
*
|
2000-11-28 20:56:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "OpenTypeUtilities.h"
|
|
|
|
#include "IndicReordering.h"
|
2004-04-12 18:51:31 +00:00
|
|
|
#include "LEGlyphStorage.h"
|
2003-01-04 02:52:23 +00:00
|
|
|
#include "MPreFixups.h"
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-10-04 19:27:01 +00:00
|
|
|
class ReorderingOutput : public UMemory {
|
2000-11-28 20:56:52 +00:00
|
|
|
private:
|
|
|
|
le_int32 fOutIndex;
|
2004-05-07 23:29:16 +00:00
|
|
|
LEUnicode *fOutChars;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-04-12 18:51:31 +00:00
|
|
|
LEGlyphStorage &fGlyphStorage;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
LEUnicode fMpre;
|
2004-08-24 22:42:42 +00:00
|
|
|
le_int32 fMpreIndex;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
LEUnicode fMbelow;
|
2004-08-24 22:42:42 +00:00
|
|
|
le_int32 fMbelowIndex;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
LEUnicode fMabove;
|
2004-08-24 22:42:42 +00:00
|
|
|
le_int32 fMaboveIndex;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
LEUnicode fMpost;
|
2004-08-24 22:42:42 +00:00
|
|
|
le_int32 fMpostIndex;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
LEUnicode fLengthMark;
|
2004-08-24 22:42:42 +00:00
|
|
|
le_int32 fLengthMarkIndex;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
const LETag *fMatraTags;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
le_int32 fMPreOutIndex;
|
|
|
|
MPreFixups *fMPreFixups;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
LEUnicode fVMabove;
|
|
|
|
LEUnicode fVMpost;
|
|
|
|
le_int32 fVMIndex;
|
|
|
|
const LETag *fVMTags;
|
|
|
|
|
|
|
|
LEUnicode fSMabove;
|
|
|
|
LEUnicode fSMbelow;
|
|
|
|
le_int32 fSMIndex;
|
|
|
|
const LETag *fSMTags;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-08-24 22:42:42 +00:00
|
|
|
void saveMatra(LEUnicode matra, le_int32 matraIndex, IndicClassTable::CharClass matraClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
// FIXME: check if already set, or if not a matra...
|
2004-02-13 19:34:17 +00:00
|
|
|
if (IndicClassTable::isLengthMark(matraClass)) {
|
2000-11-28 20:56:52 +00:00
|
|
|
fLengthMark = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fLengthMarkIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
} else {
|
|
|
|
switch (matraClass & IndicClassTable::CF_POS_MASK) {
|
|
|
|
case IndicClassTable::CF_POS_BEFORE:
|
|
|
|
fMpre = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMpreIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CF_POS_BELOW:
|
|
|
|
fMbelow = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMbelowIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CF_POS_ABOVE:
|
|
|
|
fMabove = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMaboveIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CF_POS_AFTER:
|
|
|
|
fMpost = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMpostIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// can't get here...
|
|
|
|
break;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2004-04-12 18:51:31 +00:00
|
|
|
ReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage, MPreFixups *mpreFixups)
|
|
|
|
: fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage),
|
2004-08-24 22:42:42 +00:00
|
|
|
fMpre(0), fMpreIndex(0), fMbelow(0), fMbelowIndex(0), fMabove(0), fMaboveIndex(0),
|
|
|
|
fMpost(0), fMpostIndex(0), fLengthMark(0), fLengthMarkIndex(0), fMatraTags(NULL),
|
2004-02-13 19:34:17 +00:00
|
|
|
fMPreOutIndex(-1), fMPreFixups(mpreFixups),
|
|
|
|
fVMabove(0), fVMpost(0), fVMIndex(0), fVMTags(NULL),
|
|
|
|
fSMabove(0), fSMbelow(0), fSMIndex(0), fSMTags(NULL)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
// nothing else to do...
|
|
|
|
}
|
|
|
|
|
|
|
|
~ReorderingOutput()
|
|
|
|
{
|
|
|
|
// nothing to do here...
|
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
void reset()
|
|
|
|
{
|
|
|
|
fMpre = fMbelow = fMabove = fMpost = fLengthMark = 0;
|
|
|
|
fMPreOutIndex = -1;
|
|
|
|
|
|
|
|
fVMabove = fVMpost = 0;
|
|
|
|
fSMabove = fSMbelow = 0;
|
|
|
|
}
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
le_bool noteMatra(const IndicClassTable *classTable, LEUnicode matra, le_uint32 matraIndex, const LETag *matraTags)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
IndicClassTable::CharClass matraClass = classTable->getCharClass(matra);
|
|
|
|
|
2004-08-24 22:42:42 +00:00
|
|
|
fMatraTags = matraTags;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
if (IndicClassTable::isMatra(matraClass)) {
|
|
|
|
if (IndicClassTable::isSplitMatra(matraClass)) {
|
|
|
|
const SplitMatra *splitMatra = classTable->getSplitMatra(matraClass);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3 && (*splitMatra)[i] != 0; i += 1) {
|
|
|
|
LEUnicode piece = (*splitMatra)[i];
|
|
|
|
IndicClassTable::CharClass pieceClass = classTable->getCharClass(piece);
|
|
|
|
|
2004-08-24 22:42:42 +00:00
|
|
|
saveMatra(piece, matraIndex, pieceClass);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-08-24 22:42:42 +00:00
|
|
|
saveMatra(matra, matraIndex, matraClass);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
void noteVowelModifier(const IndicClassTable *classTable, LEUnicode vowelModifier, le_uint32 vowelModifierIndex, const LETag *vowelModifierTags)
|
|
|
|
{
|
|
|
|
IndicClassTable::CharClass vmClass = classTable->getCharClass(vowelModifier);
|
|
|
|
|
|
|
|
fVMIndex = vowelModifierIndex;
|
|
|
|
fVMTags = vowelModifierTags;
|
|
|
|
|
|
|
|
if (IndicClassTable::isVowelModifier(vmClass)) {
|
|
|
|
switch (vmClass & IndicClassTable::CF_POS_MASK) {
|
|
|
|
case IndicClassTable::CF_POS_ABOVE:
|
|
|
|
fVMabove = vowelModifier;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CF_POS_AFTER:
|
|
|
|
fVMpost = vowelModifier;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// FIXME: this is an error...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void noteStressMark(const IndicClassTable *classTable, LEUnicode stressMark, le_uint32 stressMarkIndex, const LETag *stressMarkTags)
|
|
|
|
{
|
|
|
|
IndicClassTable::CharClass smClass = classTable->getCharClass(stressMark);
|
|
|
|
|
|
|
|
fSMIndex = stressMarkIndex;
|
|
|
|
fSMTags = stressMarkTags;
|
|
|
|
|
|
|
|
if (IndicClassTable::isStressMark(smClass)) {
|
|
|
|
switch (smClass & IndicClassTable::CF_POS_MASK) {
|
|
|
|
case IndicClassTable::CF_POS_ABOVE:
|
|
|
|
fSMabove = stressMark;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CF_POS_BELOW:
|
|
|
|
fSMbelow = stressMark;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// FIXME: this is an error...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
void noteBaseConsonant()
|
|
|
|
{
|
|
|
|
if (fMPreFixups != NULL && fMPreOutIndex >= 0) {
|
|
|
|
fMPreFixups->add(fOutIndex, fMPreOutIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
void writeMpre()
|
|
|
|
{
|
|
|
|
if (fMpre != 0) {
|
2003-01-04 02:52:23 +00:00
|
|
|
fMPreOutIndex = fOutIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
writeChar(fMpre, fMpreIndex, fMatraTags);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMbelow()
|
|
|
|
{
|
|
|
|
if (fMbelow != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
writeChar(fMbelow, fMbelowIndex, fMatraTags);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMabove()
|
|
|
|
{
|
|
|
|
if (fMabove != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
writeChar(fMabove, fMaboveIndex, fMatraTags);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMpost()
|
|
|
|
{
|
|
|
|
if (fMpost != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
writeChar(fMpost, fMpostIndex, fMatraTags);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeLengthMark()
|
|
|
|
{
|
|
|
|
if (fLengthMark != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
writeChar(fLengthMark, fLengthMarkIndex, fMatraTags);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
void writeVMabove()
|
|
|
|
{
|
|
|
|
if (fVMabove != 0) {
|
|
|
|
writeChar(fVMabove, fVMIndex, fVMTags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeVMpost()
|
|
|
|
{
|
|
|
|
if (fVMpost != 0) {
|
|
|
|
writeChar(fVMpost, fVMIndex, fVMTags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSMabove()
|
|
|
|
{
|
|
|
|
if (fSMabove != 0) {
|
|
|
|
writeChar(fSMabove, fSMIndex, fSMTags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSMbelow()
|
|
|
|
{
|
|
|
|
if (fSMbelow != 0) {
|
|
|
|
writeChar(fSMbelow, fSMIndex, fSMTags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
void writeChar(LEUnicode ch, le_uint32 charIndex, const LETag *charTags)
|
|
|
|
{
|
2004-05-07 23:29:16 +00:00
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
2004-04-12 18:51:31 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
fOutChars[fOutIndex] = ch;
|
2004-04-12 18:51:31 +00:00
|
|
|
|
2004-05-07 23:29:16 +00:00
|
|
|
fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
|
|
|
|
fGlyphStorage.setAuxData(fOutIndex, (void *) charTags, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
fOutIndex += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
le_int32 getOutputIndex()
|
|
|
|
{
|
|
|
|
return fOutIndex;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
C_DOTTED_CIRCLE = 0x25CC
|
|
|
|
};
|
|
|
|
|
2004-07-19 21:33:03 +00:00
|
|
|
static const LETag emptyTag = 0x00000000; // ''
|
|
|
|
|
|
|
|
static const LETag nuktFeatureTag = LE_NUKT_FEATURE_TAG;
|
|
|
|
static const LETag akhnFeatureTag = LE_AKHN_FEATURE_TAG;
|
|
|
|
static const LETag rphfFeatureTag = LE_RPHF_FEATURE_TAG;
|
|
|
|
static const LETag blwfFeatureTag = LE_BLWF_FEATURE_TAG;
|
|
|
|
static const LETag halfFeatureTag = LE_HALF_FEATURE_TAG;
|
|
|
|
static const LETag pstfFeatureTag = LE_PSTF_FEATURE_TAG;
|
|
|
|
static const LETag vatuFeatureTag = LE_VATU_FEATURE_TAG;
|
|
|
|
static const LETag presFeatureTag = LE_PRES_FEATURE_TAG;
|
|
|
|
static const LETag blwsFeatureTag = LE_BLWS_FEATURE_TAG;
|
|
|
|
static const LETag abvsFeatureTag = LE_ABVS_FEATURE_TAG;
|
|
|
|
static const LETag pstsFeatureTag = LE_PSTS_FEATURE_TAG;
|
|
|
|
static const LETag halnFeatureTag = LE_HALN_FEATURE_TAG;
|
|
|
|
|
|
|
|
static const LETag blwmFeatureTag = LE_BLWM_FEATURE_TAG;
|
|
|
|
static const LETag abvmFeatureTag = LE_ABVM_FEATURE_TAG;
|
|
|
|
static const LETag distFeatureTag = LE_DIST_FEATURE_TAG;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2002-03-01 22:24:10 +00:00
|
|
|
// These are in the order in which the features need to be applied
|
|
|
|
// for correct processing
|
2004-07-19 21:33:03 +00:00
|
|
|
static const LETag featureOrder[] =
|
2002-03-01 22:24:10 +00:00
|
|
|
{
|
|
|
|
nuktFeatureTag, akhnFeatureTag, rphfFeatureTag, blwfFeatureTag, halfFeatureTag, pstfFeatureTag,
|
|
|
|
vatuFeatureTag, presFeatureTag, blwsFeatureTag, abvsFeatureTag, pstsFeatureTag, halnFeatureTag,
|
|
|
|
blwmFeatureTag, abvmFeatureTag, distFeatureTag, emptyTag
|
|
|
|
};
|
|
|
|
|
|
|
|
// The order of these is determined so that the tag array of each glyph can start
|
|
|
|
// at an offset into this array
|
2000-11-28 20:56:52 +00:00
|
|
|
// FIXME: do we want a seperate tag array for each kind of character??
|
2002-03-01 22:24:10 +00:00
|
|
|
// FIXME: are there cases where this ordering causes glyphs to get tags
|
|
|
|
// that they shouldn't?
|
2004-07-19 21:33:03 +00:00
|
|
|
static const LETag tagArray[] =
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-01-28 23:30:56 +00:00
|
|
|
rphfFeatureTag, blwfFeatureTag, halfFeatureTag, pstfFeatureTag, nuktFeatureTag, akhnFeatureTag,
|
2000-11-28 20:56:52 +00:00
|
|
|
vatuFeatureTag, presFeatureTag, blwsFeatureTag, abvsFeatureTag, pstsFeatureTag, halnFeatureTag,
|
2002-03-01 22:24:10 +00:00
|
|
|
blwmFeatureTag, abvmFeatureTag, distFeatureTag, emptyTag
|
2000-11-28 20:56:52 +00:00
|
|
|
};
|
|
|
|
|
2004-07-19 21:33:03 +00:00
|
|
|
static const le_int8 stateTable[][IndicClassTable::CC_COUNT] =
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-08-24 22:42:42 +00:00
|
|
|
// xx vm sm iv i2 ct cn nu dv s1 s2 s3 vr zw
|
|
|
|
{ 1, 1, 1, 5, 8, 3, 2, 1, 5, 9, 5, 1, 1, 1}, // 0 - ground state
|
|
|
|
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 1 - exit state
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, 5, 9, 5, 5, 4, -1}, // 2 - consonant
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, 2, 5, 9, 5, 5, 4, -1}, // 3 - consonant with nukta
|
|
|
|
{-1, -1, -1, -1, -1, 3, 2, -1, -1, -1, -1, -1, -1, 7}, // 4 - consonant virama
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 5 - dependent vowels
|
|
|
|
{-1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, // 6 - vowel mark
|
|
|
|
{-1, -1, -1, -1, -1, 3, 2, -1, -1, -1, -1, -1, -1, -1}, // 7 - ZWJ, ZWNJ
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1}, // 8 - independent vowels that can take a virama
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, 10, 5, -1, -1}, // 9 - first part of split vowel
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1} // 10 - second part of split vowel
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-03-01 22:24:10 +00:00
|
|
|
const LETag *IndicReordering::getFeatureOrder()
|
|
|
|
{
|
|
|
|
return featureOrder;
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 IndicReordering::findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
|
|
|
|
{
|
|
|
|
le_int32 cursor = prev;
|
|
|
|
le_int8 state = 0;
|
|
|
|
|
|
|
|
while (cursor < charCount) {
|
|
|
|
IndicClassTable::CharClass charClass = classTable->getCharClass(chars[cursor]);
|
|
|
|
|
|
|
|
state = stateTable[state][charClass & IndicClassTable::CF_CLASS_MASK];
|
|
|
|
|
|
|
|
if (state < 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
le_int32 IndicReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
|
2004-04-12 18:51:31 +00:00
|
|
|
LEUnicode *outChars, LEGlyphStorage &glyphStorage,
|
2003-01-04 02:52:23 +00:00
|
|
|
MPreFixups **outMPreFixups)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-01-04 02:52:23 +00:00
|
|
|
MPreFixups *mpreFixups = NULL;
|
2000-11-28 20:56:52 +00:00
|
|
|
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
|
2003-01-04 02:52:23 +00:00
|
|
|
|
|
|
|
if (classTable->scriptFlags & IndicClassTable::SF_MPRE_FIXUP) {
|
|
|
|
mpreFixups = new MPreFixups(charCount);
|
|
|
|
}
|
|
|
|
|
2004-04-12 18:51:31 +00:00
|
|
|
ReorderingOutput output(outChars, glyphStorage, mpreFixups);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 i, prev = 0;
|
|
|
|
|
|
|
|
while (prev < charCount) {
|
|
|
|
le_int32 syllable = findSyllable(classTable, chars, prev, charCount);
|
2004-02-13 19:34:17 +00:00
|
|
|
le_int32 matra, markStart = syllable;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
output.reset();
|
|
|
|
|
|
|
|
if (classTable->isStressMark(chars[markStart - 1])) {
|
|
|
|
markStart -= 1;
|
|
|
|
output.noteStressMark(classTable, chars[markStart], markStart, &tagArray[1]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
if (classTable->isVowelModifier(chars[markStart - 1])) {
|
|
|
|
markStart -= 1;
|
|
|
|
output.noteVowelModifier(classTable, chars[markStart], markStart, &tagArray[1]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
matra = markStart - 1;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
while (output.noteMatra(classTable, chars[matra], matra, &tagArray[1]) && matra != prev) {
|
|
|
|
matra -= 1;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
switch (classTable->getCharClass(chars[prev]) & IndicClassTable::CF_CLASS_MASK) {
|
|
|
|
case IndicClassTable::CC_RESERVED:
|
|
|
|
case IndicClassTable::CC_INDEPENDENT_VOWEL:
|
|
|
|
case IndicClassTable::CC_ZERO_WIDTH_MARK:
|
|
|
|
for (i = prev; i < syllable; i += 1) {
|
|
|
|
output.writeChar(chars[i], i, &tagArray[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CC_NUKTA:
|
|
|
|
case IndicClassTable::CC_VIRAMA:
|
|
|
|
output.writeChar(C_DOTTED_CIRCLE, prev, &tagArray[1]);
|
|
|
|
output.writeChar(chars[prev], prev, &tagArray[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IndicClassTable::CC_DEPENDENT_VOWEL:
|
2004-08-24 22:42:42 +00:00
|
|
|
case IndicClassTable::CC_SPLIT_VOWEL_PIECE_1:
|
|
|
|
case IndicClassTable::CC_SPLIT_VOWEL_PIECE_2:
|
|
|
|
case IndicClassTable::CC_SPLIT_VOWEL_PIECE_3:
|
|
|
|
case IndicClassTable::CC_VOWEL_MODIFIER:
|
|
|
|
case IndicClassTable::CC_STRESS_MARK:
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeMpre();
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeChar(C_DOTTED_CIRCLE, prev, &tagArray[1]);
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeMbelow();
|
2004-08-24 22:42:42 +00:00
|
|
|
output.writeSMbelow();
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeMabove();
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_MATRAS_AFTER_BASE) != 0) {
|
|
|
|
output.writeMpost();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_REPH_AFTER_BELOW) != 0) {
|
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove(); // FIXME: there are no SM's in these scripts...
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_MATRAS_AFTER_BASE) == 0) {
|
|
|
|
output.writeMpost();
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeLengthMark();
|
2004-08-24 22:42:42 +00:00
|
|
|
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_REPH_AFTER_BELOW) == 0) {
|
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove();
|
|
|
|
}
|
|
|
|
|
|
|
|
output.writeVMpost();
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
|
2004-08-06 18:13:16 +00:00
|
|
|
case IndicClassTable::CC_INDEPENDENT_VOWEL_2:
|
2000-11-28 20:56:52 +00:00
|
|
|
case IndicClassTable::CC_CONSONANT:
|
|
|
|
case IndicClassTable::CC_CONSONANT_WITH_NUKTA:
|
|
|
|
{
|
2004-02-13 19:34:17 +00:00
|
|
|
le_uint32 length = markStart - prev;
|
|
|
|
le_int32 lastConsonant = markStart - 1;
|
2003-01-28 23:30:56 +00:00
|
|
|
le_int32 baseLimit = prev;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
// Check for REPH at front of syllable
|
|
|
|
if (length > 2 && classTable->isReph(chars[prev]) && classTable->isVirama(chars[prev + 1])) {
|
2003-01-28 23:30:56 +00:00
|
|
|
baseLimit += 2;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
// Check for eyelash RA, if the script supports it
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_EYELASH_RA) != 0 &&
|
2003-01-28 23:30:56 +00:00
|
|
|
chars[baseLimit] == C_SIGN_ZWJ) {
|
2000-11-28 20:56:52 +00:00
|
|
|
if (length > 3) {
|
|
|
|
baseLimit += 1;
|
|
|
|
} else {
|
2003-01-28 23:30:56 +00:00
|
|
|
baseLimit -= 2;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-25 19:27:43 +00:00
|
|
|
while (lastConsonant > baseLimit && !classTable->isConsonant(chars[lastConsonant])) {
|
2000-11-28 20:56:52 +00:00
|
|
|
lastConsonant -= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
le_int32 baseConsonant = lastConsonant;
|
|
|
|
le_int32 postBase = lastConsonant + 1;
|
2003-01-28 23:30:56 +00:00
|
|
|
le_int32 postBaseLimit = classTable->scriptFlags & IndicClassTable::SF_POST_BASE_LIMIT_MASK;
|
2003-12-08 22:43:41 +00:00
|
|
|
le_bool seenVattu = FALSE;
|
|
|
|
le_bool seenBelowBaseForm = FALSE;
|
2003-01-28 23:30:56 +00:00
|
|
|
|
2004-03-25 19:27:43 +00:00
|
|
|
if (classTable->isNukta(chars[postBase])) {
|
|
|
|
postBase += 1;
|
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
while (baseConsonant > baseLimit) {
|
|
|
|
IndicClassTable::CharClass charClass = classTable->getCharClass(chars[baseConsonant]);
|
|
|
|
|
|
|
|
if (IndicClassTable::isConsonant(charClass)) {
|
|
|
|
if (postBaseLimit == 0 || seenVattu ||
|
|
|
|
(baseConsonant > baseLimit && !classTable->isVirama(chars[baseConsonant - 1])) ||
|
|
|
|
!IndicClassTable::hasPostOrBelowBaseForm(charClass)) {
|
|
|
|
break;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
seenVattu = IndicClassTable::isVattu(charClass);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
if (IndicClassTable::hasPostBaseForm(charClass)) {
|
|
|
|
if (seenBelowBaseForm) {
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
postBase = baseConsonant;
|
|
|
|
} else if (IndicClassTable::hasBelowBaseForm(charClass)) {
|
2003-12-08 22:43:41 +00:00
|
|
|
seenBelowBaseForm = TRUE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
postBaseLimit -= 1;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
baseConsonant -= 1;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// Write Mpre
|
|
|
|
output.writeMpre();
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// Write eyelash RA
|
|
|
|
// NOTE: baseLimit == prev + 3 iff eyelash RA present...
|
|
|
|
if (baseLimit == prev + 3) {
|
|
|
|
output.writeChar(chars[prev], prev, &tagArray[2]);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, &tagArray[2]);
|
|
|
|
output.writeChar(chars[prev + 2], prev + 2, &tagArray[2]);
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write any pre-base consonants
|
2003-12-08 22:43:41 +00:00
|
|
|
le_bool supressVattu = TRUE;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
for (i = baseLimit; i < baseConsonant; i += 1) {
|
|
|
|
LEUnicode ch = chars[i];
|
2004-08-19 23:51:11 +00:00
|
|
|
// Don't put 'blwf' on first consonant.
|
|
|
|
const LETag *tag = (i == baseLimit? &tagArray[2] : &tagArray[1]);
|
2003-01-28 23:30:56 +00:00
|
|
|
IndicClassTable::CharClass charClass = classTable->getCharClass(ch);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
if (IndicClassTable::isConsonant(charClass)) {
|
|
|
|
if (IndicClassTable::isVattu(charClass) && supressVattu) {
|
|
|
|
tag = &tagArray[4];
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
supressVattu = IndicClassTable::isVattu(charClass);
|
|
|
|
} else if (IndicClassTable::isVirama(charClass) && chars[i + 1] == C_SIGN_ZWNJ)
|
|
|
|
{
|
|
|
|
tag = &tagArray[4];
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeChar(ch, i, tag);
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
le_int32 bcSpan = baseConsonant + 1;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
if (bcSpan < markStart && classTable->isNukta(chars[bcSpan])) {
|
2003-01-28 23:30:56 +00:00
|
|
|
bcSpan += 1;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
if (baseConsonant == lastConsonant && bcSpan < markStart && classTable->isVirama(chars[bcSpan])) {
|
2003-01-28 23:30:56 +00:00
|
|
|
bcSpan += 1;
|
2003-01-04 02:52:23 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
if (bcSpan < markStart && chars[bcSpan] == C_SIGN_ZWNJ) {
|
2003-01-28 23:30:56 +00:00
|
|
|
bcSpan += 1;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// note the base consonant for post-GSUB fixups
|
|
|
|
output.noteBaseConsonant();
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write base consonant
|
|
|
|
for (i = baseConsonant; i < bcSpan; i += 1) {
|
|
|
|
output.writeChar(chars[i], i, &tagArray[4]);
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_MATRAS_AFTER_BASE) != 0) {
|
|
|
|
output.writeMbelow();
|
2004-02-13 19:34:17 +00:00
|
|
|
output.writeSMbelow(); // FIXME: there are no SMs in these scripts...
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeMabove();
|
|
|
|
output.writeMpost();
|
|
|
|
}
|
|
|
|
|
|
|
|
// write below-base consonants
|
|
|
|
if (baseConsonant != lastConsonant) {
|
|
|
|
for (i = bcSpan + 1; i < postBase; i += 1) {
|
|
|
|
output.writeChar(chars[i], i, &tagArray[1]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
if (postBase > lastConsonant) {
|
|
|
|
// write halant that was after base consonant
|
|
|
|
output.writeChar(chars[bcSpan], bcSpan, &tagArray[1]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
// write Mbelow, SMbelow, Mabove
|
2003-01-28 23:30:56 +00:00
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_MATRAS_AFTER_BASE) == 0) {
|
|
|
|
output.writeMbelow();
|
2004-02-13 19:34:17 +00:00
|
|
|
output.writeSMbelow();
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeMabove();
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_REPH_AFTER_BELOW) != 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
if (baseLimit == prev + 2) {
|
|
|
|
output.writeChar(chars[prev], prev, &tagArray[0]);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, &tagArray[0]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove(); // FIXME: there are no SM's in these scripts...
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write post-base consonants
|
|
|
|
// FIXME: does this put the right tags on post-base consonants?
|
|
|
|
if (baseConsonant != lastConsonant) {
|
|
|
|
if (postBase <= lastConsonant) {
|
|
|
|
for (i = postBase; i <= lastConsonant; i += 1) {
|
|
|
|
output.writeChar(chars[i], i, &tagArray[3]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write halant that was after base consonant
|
|
|
|
output.writeChar(chars[bcSpan], bcSpan, &tagArray[1]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write the training halant, if there is one
|
|
|
|
if (lastConsonant < matra && classTable->isVirama(chars[matra])) {
|
|
|
|
output.writeChar(chars[matra], matra, &tagArray[4]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write Mpost
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_MATRAS_AFTER_BASE) == 0) {
|
|
|
|
output.writeMpost();
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeLengthMark();
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write reph
|
|
|
|
if ((classTable->scriptFlags & IndicClassTable::SF_REPH_AFTER_BELOW) == 0) {
|
|
|
|
if (baseLimit == prev + 2) {
|
|
|
|
output.writeChar(chars[prev], prev, &tagArray[0]);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, &tagArray[0]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove();
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
output.writeVMpost();
|
2003-01-28 23:30:56 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prev = syllable;
|
|
|
|
}
|
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
*outMPreFixups = mpreFixups;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
return output.getOutputIndex();
|
|
|
|
}
|
|
|
|
|
2004-04-12 18:51:31 +00:00
|
|
|
void IndicReordering::adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-01-28 23:30:56 +00:00
|
|
|
if (mpreFixups != NULL) {
|
2004-04-12 18:51:31 +00:00
|
|
|
mpreFixups->apply(glyphStorage);
|
2003-01-04 02:52:23 +00:00
|
|
|
|
|
|
|
delete mpreFixups;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|