2000-11-28 20:56:52 +00:00
|
|
|
/*
|
2009-03-02 23:35:48 +00:00
|
|
|
/ *
|
|
|
|
* (C) Copyright IBM Corp. 1998-2009 - All Rights Reserved
|
2004-04-12 18:51:31 +00:00
|
|
|
*
|
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
|
|
|
|
|
2006-04-25 19:08:11 +00:00
|
|
|
#define loclFeatureTag LE_LOCL_FEATURE_TAG
|
2005-08-08 21:01:27 +00:00
|
|
|
#define initFeatureTag LE_INIT_FEATURE_TAG
|
|
|
|
#define nuktFeatureTag LE_NUKT_FEATURE_TAG
|
|
|
|
#define akhnFeatureTag LE_AKHN_FEATURE_TAG
|
|
|
|
#define rphfFeatureTag LE_RPHF_FEATURE_TAG
|
2009-03-02 23:35:48 +00:00
|
|
|
#define rkrfFeatureTag LE_RKRF_FEATURE_TAG
|
2005-08-08 21:01:27 +00:00
|
|
|
#define blwfFeatureTag LE_BLWF_FEATURE_TAG
|
|
|
|
#define halfFeatureTag LE_HALF_FEATURE_TAG
|
|
|
|
#define pstfFeatureTag LE_PSTF_FEATURE_TAG
|
|
|
|
#define vatuFeatureTag LE_VATU_FEATURE_TAG
|
|
|
|
#define presFeatureTag LE_PRES_FEATURE_TAG
|
|
|
|
#define blwsFeatureTag LE_BLWS_FEATURE_TAG
|
|
|
|
#define abvsFeatureTag LE_ABVS_FEATURE_TAG
|
|
|
|
#define pstsFeatureTag LE_PSTS_FEATURE_TAG
|
|
|
|
#define halnFeatureTag LE_HALN_FEATURE_TAG
|
2009-03-02 23:35:48 +00:00
|
|
|
#define cjctFeatureTag LE_CJCT_FEATURE_TAG
|
2005-08-08 21:01:27 +00:00
|
|
|
#define blwmFeatureTag LE_BLWM_FEATURE_TAG
|
|
|
|
#define abvmFeatureTag LE_ABVM_FEATURE_TAG
|
|
|
|
#define distFeatureTag LE_DIST_FEATURE_TAG
|
2009-03-02 23:35:48 +00:00
|
|
|
#define caltFeatureTag LE_CALT_FEATURE_TAG
|
|
|
|
#define kernFeatureTag LE_KERN_FEATURE_TAG
|
2005-08-08 21:01:27 +00:00
|
|
|
|
2006-04-25 19:08:11 +00:00
|
|
|
#define loclFeatureMask 0x80000000UL
|
|
|
|
#define rphfFeatureMask 0x40000000UL
|
|
|
|
#define blwfFeatureMask 0x20000000UL
|
|
|
|
#define halfFeatureMask 0x10000000UL
|
|
|
|
#define pstfFeatureMask 0x08000000UL
|
|
|
|
#define nuktFeatureMask 0x04000000UL
|
|
|
|
#define akhnFeatureMask 0x02000000UL
|
|
|
|
#define vatuFeatureMask 0x01000000UL
|
|
|
|
#define presFeatureMask 0x00800000UL
|
|
|
|
#define blwsFeatureMask 0x00400000UL
|
|
|
|
#define abvsFeatureMask 0x00200000UL
|
2009-03-02 23:35:48 +00:00
|
|
|
#define pstsFeatureMask 0x00100000UL
|
2006-04-25 19:08:11 +00:00
|
|
|
#define halnFeatureMask 0x00080000UL
|
|
|
|
#define blwmFeatureMask 0x00040000UL
|
|
|
|
#define abvmFeatureMask 0x00020000UL
|
|
|
|
#define distFeatureMask 0x00010000UL
|
|
|
|
#define initFeatureMask 0x00008000UL
|
2009-03-02 23:35:48 +00:00
|
|
|
#define cjctFeatureMask 0x00004000UL
|
|
|
|
#define rkrfFeatureMask 0x00002000UL
|
|
|
|
#define caltFeatureMask 0x00001000UL
|
|
|
|
#define kernFeatureMask 0x00000800UL
|
|
|
|
|
|
|
|
// Syllable structure bits
|
|
|
|
#define baseConsonantMask 0x00000400UL
|
|
|
|
#define consonantMask 0x00000200UL
|
|
|
|
#define halfConsonantMask 0x00000100UL
|
|
|
|
#define rephConsonantMask 0x00000080UL
|
|
|
|
#define matraMask 0x00000040UL
|
|
|
|
#define vowelModifierMask 0x00000020UL
|
|
|
|
#define markPositionMask 0x00000018UL
|
|
|
|
|
|
|
|
#define postBasePosition 0x00000000UL
|
|
|
|
#define preBasePosition 0x00000008UL
|
|
|
|
#define aboveBasePosition 0x00000010UL
|
|
|
|
#define belowBasePosition 0x00000018UL
|
|
|
|
|
|
|
|
#define repositionedGlyphMask 0x00000002UL
|
|
|
|
|
|
|
|
#define basicShapingFormsMask ( loclFeatureMask | nuktFeatureMask | akhnFeatureMask | rkrfFeatureMask | blwfFeatureMask | halfFeatureMask | vatuFeatureMask | cjctFeatureMask )
|
|
|
|
#define positioningFormsMask ( kernFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask )
|
|
|
|
#define presentationFormsMask ( presFeatureMask | abvsFeatureMask | blwsFeatureMask | pstsFeatureMask | halnFeatureMask | caltFeatureMask )
|
|
|
|
|
|
|
|
|
|
|
|
#define C_MALAYALAM_VOWEL_SIGN_U 0x0D41
|
|
|
|
#define C_DOTTED_CIRCLE 0x25CC
|
|
|
|
#define NO_GLYPH 0xFFFF
|
|
|
|
|
2009-10-08 19:13:13 +00:00
|
|
|
// Some level of debate as to the proper value for MAX_CONSONANTS_PER_SYLLABLE. Ticket 5588 states that 4
|
|
|
|
// is the magic number according to ISCII, but 5 seems to be the more consistent with XP.
|
|
|
|
#define MAX_CONSONANTS_PER_SYLLABLE 5
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
#define INDIC_BLOCK_SIZE 0x7F
|
2005-08-08 21:01:27 +00:00
|
|
|
|
2006-02-06 06:41:52 +00:00
|
|
|
class IndicReorderingOutput : public UMemory {
|
2000-11-28 20:56:52 +00:00
|
|
|
private:
|
2007-10-09 19:40:14 +00:00
|
|
|
le_int32 fSyllableCount;
|
2005-08-06 00:48:27 +00:00
|
|
|
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
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fMpre;
|
|
|
|
le_int32 fMpreIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fMbelow;
|
|
|
|
le_int32 fMbelowIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fMabove;
|
|
|
|
le_int32 fMaboveIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fMpost;
|
|
|
|
le_int32 fMpostIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fLengthMark;
|
|
|
|
le_int32 fLengthMarkIndex;
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
LEUnicode fAlLakuna;
|
|
|
|
le_int32 fAlLakunaIndex;
|
2005-07-28 20:56:04 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
FeatureMask fMatraFeatures;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
le_int32 fMPreOutIndex;
|
2003-01-04 02:52:23 +00:00
|
|
|
MPreFixups *fMPreFixups;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fVMabove;
|
|
|
|
LEUnicode fVMpost;
|
|
|
|
le_int32 fVMIndex;
|
|
|
|
FeatureMask fVMFeatures;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
LEUnicode fSMabove;
|
|
|
|
LEUnicode fSMbelow;
|
|
|
|
le_int32 fSMIndex;
|
|
|
|
FeatureMask fSMFeatures;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
LEUnicode fPreBaseConsonant;
|
|
|
|
LEUnicode fPreBaseVirama;
|
|
|
|
le_int32 fPBCIndex;
|
|
|
|
FeatureMask fPBCFeatures;
|
2009-03-02 23:35:48 +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;
|
2008-05-27 22:44:40 +00:00
|
|
|
} else if (IndicClassTable::isAlLakuna(matraClass)) {
|
|
|
|
fAlLakuna = matra;
|
|
|
|
fAlLakunaIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
} else {
|
2005-06-17 19:20:43 +00:00
|
|
|
switch (matraClass & CF_POS_MASK) {
|
|
|
|
case CF_POS_BEFORE:
|
2004-02-13 19:34:17 +00:00
|
|
|
fMpre = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMpreIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CF_POS_BELOW:
|
2004-02-13 19:34:17 +00:00
|
|
|
fMbelow = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMbelowIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CF_POS_ABOVE:
|
2004-02-13 19:34:17 +00:00
|
|
|
fMabove = matra;
|
2004-08-24 22:42:42 +00:00
|
|
|
fMaboveIndex = matraIndex;
|
2004-02-13 19:34:17 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CF_POS_AFTER:
|
2004-02-13 19:34:17 +00:00
|
|
|
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:
|
2006-02-06 06:41:52 +00:00
|
|
|
IndicReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage, MPreFixups *mpreFixups)
|
2007-10-09 19:40:14 +00:00
|
|
|
: fSyllableCount(0), 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),
|
2008-05-27 22:44:40 +00:00
|
|
|
fMpost(0), fMpostIndex(0), fLengthMark(0), fLengthMarkIndex(0), fAlLakuna(0), fAlLakunaIndex(0),
|
2005-08-06 00:48:27 +00:00
|
|
|
fMatraFeatures(0), fMPreOutIndex(-1), fMPreFixups(mpreFixups),
|
|
|
|
fVMabove(0), fVMpost(0), fVMIndex(0), fVMFeatures(0),
|
2009-06-11 18:34:01 +00:00
|
|
|
fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0),
|
|
|
|
fPreBaseConsonant(0), fPreBaseVirama(0), fPBCIndex(0), fPBCFeatures(0)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
// nothing else to do...
|
|
|
|
}
|
|
|
|
|
2006-02-06 06:41:52 +00:00
|
|
|
~IndicReorderingOutput()
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
// nothing to do here...
|
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
void reset()
|
|
|
|
{
|
2007-10-09 19:40:14 +00:00
|
|
|
fSyllableCount += 1;
|
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
fMpre = fMbelow = fMabove = fMpost = fLengthMark = fAlLakuna = 0;
|
2004-02-13 19:34:17 +00:00
|
|
|
fMPreOutIndex = -1;
|
|
|
|
|
|
|
|
fVMabove = fVMpost = 0;
|
|
|
|
fSMabove = fSMbelow = 0;
|
2009-06-11 18:34:01 +00:00
|
|
|
|
|
|
|
fPreBaseConsonant = fPreBaseVirama = 0;
|
2004-02-13 19:34:17 +00:00
|
|
|
}
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
void writeChar(LEUnicode ch, le_uint32 charIndex, FeatureMask charFeatures)
|
2004-12-30 07:45:48 +00:00
|
|
|
{
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
|
|
|
|
fOutChars[fOutIndex] = ch;
|
|
|
|
|
|
|
|
fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
|
2007-10-09 19:40:14 +00:00
|
|
|
fGlyphStorage.setAuxData(fOutIndex, charFeatures | (fSyllableCount & LE_GLYPH_GROUP_MASK), success);
|
2004-12-30 07:45:48 +00:00
|
|
|
|
|
|
|
fOutIndex += 1;
|
|
|
|
}
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
void setFeatures ( le_uint32 charIndex, FeatureMask charFeatures)
|
|
|
|
{
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
|
|
|
|
fGlyphStorage.setAuxData( charIndex, charFeatures, success );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
FeatureMask getFeatures ( le_uint32 charIndex )
|
|
|
|
{
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
return fGlyphStorage.getAuxData(charIndex,success);
|
|
|
|
}
|
|
|
|
|
|
|
|
void decomposeReorderMatras ( const IndicClassTable *classTable, le_int32 beginSyllable, le_int32 nextSyllable, le_int32 inv_count ) {
|
|
|
|
le_int32 i;
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
|
|
|
|
for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
|
|
|
|
if ( classTable->isMatra(fOutChars[i+inv_count])) {
|
|
|
|
IndicClassTable::CharClass matraClass = classTable->getCharClass(fOutChars[i+inv_count]);
|
|
|
|
if ( classTable->isSplitMatra(matraClass)) {
|
|
|
|
le_int32 saveIndex = fGlyphStorage.getCharIndex(i+inv_count,success);
|
|
|
|
le_uint32 saveAuxData = fGlyphStorage.getAuxData(i+inv_count,success);
|
|
|
|
const SplitMatra *splitMatra = classTable->getSplitMatra(matraClass);
|
|
|
|
int j;
|
|
|
|
for (j = 0 ; *(splitMatra)[j] != 0 ; j++) {
|
|
|
|
LEUnicode piece = (*splitMatra)[j];
|
|
|
|
if ( j == 0 ) {
|
|
|
|
fOutChars[i+inv_count] = piece;
|
|
|
|
matraClass = classTable->getCharClass(piece);
|
|
|
|
} else {
|
|
|
|
insertCharacter(piece,i+1+inv_count,saveIndex,saveAuxData);
|
|
|
|
nextSyllable++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((matraClass & CF_POS_MASK) == CF_POS_BEFORE) {
|
|
|
|
moveCharacter(i+inv_count,beginSyllable+inv_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void moveCharacter( le_int32 fromPosition, le_int32 toPosition ) {
|
|
|
|
le_int32 i,saveIndex;
|
|
|
|
le_uint32 saveAuxData;
|
|
|
|
LEUnicode saveChar = fOutChars[fromPosition];
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
LEErrorCode success2 = LE_NO_ERROR;
|
|
|
|
saveIndex = fGlyphStorage.getCharIndex(fromPosition,success);
|
|
|
|
saveAuxData = fGlyphStorage.getAuxData(fromPosition,success);
|
|
|
|
|
|
|
|
if ( fromPosition > toPosition ) {
|
|
|
|
for ( i = fromPosition ; i > toPosition ; i-- ) {
|
|
|
|
fOutChars[i] = fOutChars[i-1];
|
|
|
|
fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i-1,success2),success);
|
|
|
|
fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i-1,success2), success);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( i = fromPosition ; i < toPosition ; i++ ) {
|
|
|
|
fOutChars[i] = fOutChars[i+1];
|
|
|
|
fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i+1,success2),success);
|
|
|
|
fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i+1,success2), success);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
fOutChars[toPosition] = saveChar;
|
|
|
|
fGlyphStorage.setCharIndex(toPosition,saveIndex,success);
|
|
|
|
fGlyphStorage.setAuxData(toPosition,saveAuxData,success);
|
|
|
|
|
|
|
|
}
|
|
|
|
void insertCharacter( LEUnicode ch, le_int32 toPosition, le_int32 charIndex, le_uint32 auxData ) {
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
le_int32 i;
|
|
|
|
fOutIndex += 1;
|
|
|
|
|
|
|
|
for ( i = fOutIndex ; i > toPosition ; i--) {
|
|
|
|
fOutChars[i] = fOutChars[i-1];
|
|
|
|
fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i-1,success),success);
|
|
|
|
fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i-1,success), success);
|
|
|
|
}
|
|
|
|
|
|
|
|
fOutChars[toPosition] = ch;
|
|
|
|
fGlyphStorage.setCharIndex(toPosition,charIndex,success);
|
|
|
|
fGlyphStorage.setAuxData(toPosition,auxData,success);
|
|
|
|
|
|
|
|
}
|
|
|
|
void removeCharacter( le_int32 fromPosition ) {
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
le_int32 i;
|
|
|
|
fOutIndex -= 1;
|
|
|
|
|
|
|
|
for ( i = fromPosition ; i < fOutIndex ; i--) {
|
|
|
|
fOutChars[i] = fOutChars[i+1];
|
|
|
|
fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i+1,success),success);
|
|
|
|
fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i+1,success), success);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-08 21:01:27 +00:00
|
|
|
le_bool noteMatra(const IndicClassTable *classTable, LEUnicode matra, le_uint32 matraIndex, FeatureMask matraFeatures, le_bool wordStart)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
IndicClassTable::CharClass matraClass = classTable->getCharClass(matra);
|
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
fMatraFeatures = matraFeatures;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-08-08 21:01:27 +00:00
|
|
|
if (wordStart) {
|
|
|
|
fMatraFeatures |= initFeatureMask;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
void noteVowelModifier(const IndicClassTable *classTable, LEUnicode vowelModifier, le_uint32 vowelModifierIndex, FeatureMask vowelModifierFeatures)
|
2004-02-13 19:34:17 +00:00
|
|
|
{
|
|
|
|
IndicClassTable::CharClass vmClass = classTable->getCharClass(vowelModifier);
|
|
|
|
|
|
|
|
fVMIndex = vowelModifierIndex;
|
2005-08-06 00:48:27 +00:00
|
|
|
fVMFeatures = vowelModifierFeatures;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
if (IndicClassTable::isVowelModifier(vmClass)) {
|
2005-06-17 19:20:43 +00:00
|
|
|
switch (vmClass & CF_POS_MASK) {
|
|
|
|
case CF_POS_ABOVE:
|
2004-02-13 19:34:17 +00:00
|
|
|
fVMabove = vowelModifier;
|
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CF_POS_AFTER:
|
2004-02-13 19:34:17 +00:00
|
|
|
fVMpost = vowelModifier;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// FIXME: this is an error...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
void noteStressMark(const IndicClassTable *classTable, LEUnicode stressMark, le_uint32 stressMarkIndex, FeatureMask stressMarkFeatures)
|
2004-02-13 19:34:17 +00:00
|
|
|
{
|
|
|
|
IndicClassTable::CharClass smClass = classTable->getCharClass(stressMark);
|
|
|
|
|
|
|
|
fSMIndex = stressMarkIndex;
|
2005-08-06 00:48:27 +00:00
|
|
|
fSMFeatures = stressMarkFeatures;
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
if (IndicClassTable::isStressMark(smClass)) {
|
2005-06-17 19:20:43 +00:00
|
|
|
switch (smClass & CF_POS_MASK) {
|
|
|
|
case CF_POS_ABOVE:
|
2004-02-13 19:34:17 +00:00
|
|
|
fSMabove = stressMark;
|
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CF_POS_BELOW:
|
2004-02-13 19:34:17 +00:00
|
|
|
fSMbelow = stressMark;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// FIXME: this is an error...
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
void notePreBaseConsonant(le_uint32 index,LEUnicode PBConsonant, LEUnicode PBVirama, FeatureMask features)
|
|
|
|
{
|
|
|
|
fPBCIndex = index;
|
|
|
|
fPreBaseConsonant = PBConsonant;
|
|
|
|
fPreBaseVirama = PBVirama;
|
|
|
|
fPBCFeatures = features;
|
|
|
|
}
|
|
|
|
|
2003-01-04 02:52:23 +00:00
|
|
|
void noteBaseConsonant()
|
|
|
|
{
|
|
|
|
if (fMPreFixups != NULL && fMPreOutIndex >= 0) {
|
|
|
|
fMPreFixups->add(fOutIndex, fMPreOutIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
// Handles Al-Lakuna in Sinhala split vowels.
|
|
|
|
void writeAlLakuna()
|
2005-07-28 20:56:04 +00:00
|
|
|
{
|
2008-05-27 22:44:40 +00:00
|
|
|
if (fAlLakuna != 0) {
|
|
|
|
writeChar(fAlLakuna, fAlLakunaIndex, fMatraFeatures);
|
2005-07-28 20:56:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
void writeMpre()
|
|
|
|
{
|
|
|
|
if (fMpre != 0) {
|
2003-01-04 02:52:23 +00:00
|
|
|
fMPreOutIndex = fOutIndex;
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fMpre, fMpreIndex, fMatraFeatures);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMbelow()
|
|
|
|
{
|
|
|
|
if (fMbelow != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fMbelow, fMbelowIndex, fMatraFeatures);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMabove()
|
|
|
|
{
|
|
|
|
if (fMabove != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fMabove, fMaboveIndex, fMatraFeatures);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeMpost()
|
|
|
|
{
|
|
|
|
if (fMpost != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fMpost, fMpostIndex, fMatraFeatures);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeLengthMark()
|
|
|
|
{
|
|
|
|
if (fLengthMark != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fLengthMark, fLengthMarkIndex, fMatraFeatures);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-13 19:34:17 +00:00
|
|
|
|
|
|
|
void writeVMabove()
|
|
|
|
{
|
|
|
|
if (fVMabove != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fVMabove, fVMIndex, fVMFeatures);
|
2004-02-13 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeVMpost()
|
|
|
|
{
|
|
|
|
if (fVMpost != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fVMpost, fVMIndex, fVMFeatures);
|
2004-02-13 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSMabove()
|
|
|
|
{
|
|
|
|
if (fSMabove != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fSMabove, fSMIndex, fSMFeatures);
|
2004-02-13 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSMbelow()
|
|
|
|
{
|
|
|
|
if (fSMbelow != 0) {
|
2005-08-06 00:48:27 +00:00
|
|
|
writeChar(fSMbelow, fSMIndex, fSMFeatures);
|
2004-02-13 19:34:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
void writePreBaseConsonant()
|
|
|
|
{
|
|
|
|
// The TDIL spec says that consonant + virama + RRA should produce a rakar in Malayalam. However,
|
|
|
|
// it seems that almost none of the fonts for Malayalam are set up to handle this.
|
|
|
|
// So, we're going to force the issue here by using the rakar as defined with RA in most fonts.
|
|
|
|
|
|
|
|
if (fPreBaseConsonant == 0x0d31) { // RRA
|
|
|
|
fPreBaseConsonant = 0x0d30; // RA
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fPreBaseConsonant != 0) {
|
|
|
|
writeChar(fPreBaseConsonant, fPBCIndex, fPBCFeatures);
|
|
|
|
writeChar(fPreBaseVirama,fPBCIndex-1,fPBCFeatures);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 getOutputIndex()
|
|
|
|
{
|
|
|
|
return fOutIndex;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
// TODO: Find better names for these!
|
2006-04-25 19:08:11 +00:00
|
|
|
#define tagArray4 (loclFeatureMask | nuktFeatureMask | akhnFeatureMask | vatuFeatureMask | presFeatureMask | blwsFeatureMask | abvsFeatureMask | pstsFeatureMask | halnFeatureMask | blwmFeatureMask | abvmFeatureMask | distFeatureMask)
|
2005-08-06 00:48:27 +00:00
|
|
|
#define tagArray3 (pstfFeatureMask | tagArray4)
|
|
|
|
#define tagArray2 (halfFeatureMask | tagArray3)
|
|
|
|
#define tagArray1 (blwfFeatureMask | tagArray2)
|
|
|
|
#define tagArray0 (rphfFeatureMask | tagArray1)
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
static const FeatureMap featureMap[] = {
|
2006-04-25 19:08:11 +00:00
|
|
|
{loclFeatureTag, loclFeatureMask},
|
2005-08-08 21:01:27 +00:00
|
|
|
{initFeatureTag, initFeatureMask},
|
2005-08-06 00:48:27 +00:00
|
|
|
{nuktFeatureTag, nuktFeatureMask},
|
|
|
|
{akhnFeatureTag, akhnFeatureMask},
|
|
|
|
{rphfFeatureTag, rphfFeatureMask},
|
|
|
|
{blwfFeatureTag, blwfFeatureMask},
|
|
|
|
{halfFeatureTag, halfFeatureMask},
|
|
|
|
{pstfFeatureTag, pstfFeatureMask},
|
|
|
|
{vatuFeatureTag, vatuFeatureMask},
|
|
|
|
{presFeatureTag, presFeatureMask},
|
|
|
|
{blwsFeatureTag, blwsFeatureMask},
|
|
|
|
{abvsFeatureTag, abvsFeatureMask},
|
|
|
|
{pstsFeatureTag, pstsFeatureMask},
|
|
|
|
{halnFeatureTag, halnFeatureMask},
|
|
|
|
{blwmFeatureTag, blwmFeatureMask},
|
|
|
|
{abvmFeatureTag, abvmFeatureMask},
|
|
|
|
{distFeatureTag, distFeatureMask}
|
2002-03-01 22:24:10 +00:00
|
|
|
};
|
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
static const le_int32 featureCount = LE_ARRAY_SIZE(featureMap);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
static const FeatureMap v2FeatureMap[] = {
|
|
|
|
{loclFeatureTag, loclFeatureMask},
|
|
|
|
{nuktFeatureTag, nuktFeatureMask},
|
|
|
|
{akhnFeatureTag, akhnFeatureMask},
|
|
|
|
{rphfFeatureTag, rphfFeatureMask},
|
|
|
|
{rkrfFeatureTag, rkrfFeatureMask},
|
|
|
|
{blwfFeatureTag, blwfFeatureMask},
|
|
|
|
{halfFeatureTag, halfFeatureMask},
|
|
|
|
{vatuFeatureTag, vatuFeatureMask},
|
|
|
|
{cjctFeatureTag, cjctFeatureMask},
|
|
|
|
{presFeatureTag, presFeatureMask},
|
|
|
|
{abvsFeatureTag, abvsFeatureMask},
|
|
|
|
{blwsFeatureTag, blwsFeatureMask},
|
|
|
|
{pstsFeatureTag, pstsFeatureMask},
|
|
|
|
{halnFeatureTag, halnFeatureMask},
|
|
|
|
{caltFeatureTag, caltFeatureMask},
|
|
|
|
{kernFeatureTag, kernFeatureMask},
|
|
|
|
{distFeatureTag, distFeatureMask},
|
|
|
|
{abvmFeatureTag, abvmFeatureMask},
|
|
|
|
{blwmFeatureTag, blwmFeatureMask}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const le_int32 v2FeatureMapCount = LE_ARRAY_SIZE(v2FeatureMap);
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
static const le_int8 stateTable[][CC_COUNT] =
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2008-05-27 22:44:40 +00:00
|
|
|
// xx vm sm iv i2 i3 ct cn nu dv s1 s2 s3 vr zw al
|
|
|
|
{ 1, 6, 1, 5, 8, 11, 3, 2, 1, 5, 9, 5, 5, 1, 1, 1}, // 0 - ground state
|
|
|
|
{-1, -1, -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, -1, 5, 9, 5, 5, 4, 12, -1}, // 2 - consonant with nukta
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, 2, 5, 9, 5, 5, 4, 12, 13}, // 3 - consonant
|
|
|
|
{-1, -1, -1, -1, -1, -1, 3, 2, -1, -1, -1, -1, -1, -1, 7, -1}, // 4 - consonant virama
|
|
|
|
{-1, 6, 1, -1, -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, -1, -1}, // 6 - vowel mark
|
|
|
|
{-1, -1, -1, -1, -1, -1, 3, 2, -1, -1, -1, -1, -1, -1, -1, -1}, // 7 - consonant virama ZWJ, consonant ZWJ virama
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1}, // 8 - independent vowels that can take a virama
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 5, -1, -1, -1}, // 9 - first part of split vowel
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1}, // 10 - second part of split vowel
|
|
|
|
{-1, 6, 1, -1, -1, -1, -1, -1, -1, 5, 9, 5, 5, 4, -1, -1}, // 11 - independent vowels that can take an iv
|
|
|
|
{-1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, -1, 7}, // 12 - consonant ZWJ (TODO: Take everything else that can be after a consonant?)
|
|
|
|
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, -1} // 13 - consonant al-lakuna ZWJ consonant
|
2000-11-28 20:56:52 +00:00
|
|
|
};
|
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
|
|
|
|
const FeatureMap *IndicReordering::getFeatureMap(le_int32 &count)
|
2002-03-01 22:24:10 +00:00
|
|
|
{
|
2005-08-06 00:48:27 +00:00
|
|
|
count = featureCount;
|
|
|
|
|
|
|
|
return featureMap;
|
2002-03-01 22:24:10 +00:00
|
|
|
}
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
const FeatureMap *IndicReordering::getv2FeatureMap(le_int32 &count)
|
|
|
|
{
|
|
|
|
count = v2FeatureMapCount;
|
|
|
|
|
|
|
|
return v2FeatureMap;
|
|
|
|
}
|
|
|
|
|
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;
|
2009-10-08 19:13:13 +00:00
|
|
|
le_int8 consonant_count = 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
while (cursor < charCount) {
|
|
|
|
IndicClassTable::CharClass charClass = classTable->getCharClass(chars[cursor]);
|
2009-10-08 19:13:13 +00:00
|
|
|
|
|
|
|
if ( IndicClassTable::isConsonant(charClass) ) {
|
|
|
|
consonant_count++;
|
|
|
|
if ( consonant_count > MAX_CONSONANTS_PER_SYLLABLE ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
state = stateTable[state][charClass & CF_CLASS_MASK];
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
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,
|
2008-10-28 14:50:15 +00:00
|
|
|
MPreFixups **outMPreFixups, LEErrorCode& success)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2008-10-28 14:50:15 +00:00
|
|
|
if (LE_FAILURE(success)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if (classTable->scriptFlags & SF_MPRE_FIXUP) {
|
2003-01-04 02:52:23 +00:00
|
|
|
mpreFixups = new MPreFixups(charCount);
|
2008-10-28 14:50:15 +00:00
|
|
|
if (mpreFixups == NULL) {
|
|
|
|
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-04 02:52:23 +00:00
|
|
|
}
|
|
|
|
|
2006-02-06 06:41:52 +00:00
|
|
|
IndicReorderingOutput output(outChars, glyphStorage, mpreFixups);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 i, prev = 0;
|
2005-08-08 21:01:27 +00:00
|
|
|
le_bool lastInWord = FALSE;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
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;
|
2005-08-06 00:48:27 +00:00
|
|
|
output.noteStressMark(classTable, chars[markStart], markStart, tagArray1);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2004-02-13 19:34:17 +00:00
|
|
|
|
2006-04-18 00:38:45 +00:00
|
|
|
if (markStart != prev && classTable->isVowelModifier(chars[markStart - 1])) {
|
2004-02-13 19:34:17 +00:00
|
|
|
markStart -= 1;
|
2005-08-06 00:48:27 +00:00
|
|
|
output.noteVowelModifier(classTable, chars[markStart], markStart, tagArray1);
|
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
|
|
|
|
2005-08-08 21:01:27 +00:00
|
|
|
while (output.noteMatra(classTable, chars[matra], matra, tagArray1, !lastInWord) && matra != prev) {
|
2004-08-24 22:42:42 +00:00
|
|
|
matra -= 1;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-08-08 21:01:27 +00:00
|
|
|
lastInWord = TRUE;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
switch (classTable->getCharClass(chars[prev]) & CF_CLASS_MASK) {
|
|
|
|
case CC_RESERVED:
|
2005-08-08 21:01:27 +00:00
|
|
|
lastInWord = FALSE;
|
|
|
|
/* fall through */
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CC_INDEPENDENT_VOWEL:
|
|
|
|
case CC_ZERO_WIDTH_MARK:
|
2000-11-28 20:56:52 +00:00
|
|
|
for (i = prev; i < syllable; i += 1) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[i], i, tagArray1);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2008-05-29 23:23:55 +00:00
|
|
|
case CC_AL_LAKUNA:
|
2005-06-17 19:20:43 +00:00
|
|
|
case CC_NUKTA:
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
|
|
|
|
output.writeChar(chars[prev], prev, tagArray1);
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-14 23:10:04 +00:00
|
|
|
case CC_VIRAMA:
|
|
|
|
// A lone virama is illegal unless it follows a
|
|
|
|
// MALAYALAM_VOWEL_SIGN_U. Such a usage is called
|
|
|
|
// "samvruthokaram".
|
|
|
|
if (chars[prev - 1] != C_MALAYALAM_VOWEL_SIGN_U) {
|
|
|
|
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
|
|
|
|
}
|
|
|
|
|
|
|
|
output.writeChar(chars[prev], prev, tagArray1);
|
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CC_DEPENDENT_VOWEL:
|
|
|
|
case CC_SPLIT_VOWEL_PIECE_1:
|
|
|
|
case CC_SPLIT_VOWEL_PIECE_2:
|
|
|
|
case CC_SPLIT_VOWEL_PIECE_3:
|
|
|
|
case CC_VOWEL_MODIFIER:
|
|
|
|
case CC_STRESS_MARK:
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeMpre();
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
|
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
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
output.writeMpost();
|
|
|
|
}
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) != 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove(); // FIXME: there are no SM's in these scripts...
|
|
|
|
}
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
output.writeMpost();
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
output.writeLengthMark();
|
2008-05-27 22:44:40 +00:00
|
|
|
output.writeAlLakuna();
|
2004-08-24 22:42:42 +00:00
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
|
2004-08-24 22:42:42 +00:00
|
|
|
output.writeVMabove();
|
|
|
|
output.writeSMabove();
|
|
|
|
}
|
|
|
|
|
|
|
|
output.writeVMpost();
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
case CC_INDEPENDENT_VOWEL_2:
|
2005-07-28 21:27:12 +00:00
|
|
|
case CC_INDEPENDENT_VOWEL_3:
|
2005-06-17 19:20:43 +00:00
|
|
|
case CC_CONSONANT:
|
|
|
|
case CC_CONSONANT_WITH_NUKTA:
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
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
|
2008-07-28 21:02:06 +00:00
|
|
|
if (length > 2 && classTable->isReph(chars[prev]) && classTable->isVirama(chars[prev + 1]) && chars[prev + 2] != C_SIGN_ZWNJ) {
|
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
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & 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;
|
|
|
|
}
|
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
|
2006-11-22 22:50:53 +00:00
|
|
|
IndicClassTable::CharClass charClass = CC_RESERVED;
|
|
|
|
IndicClassTable::CharClass nextClass = CC_RESERVED;
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 baseConsonant = lastConsonant;
|
|
|
|
le_int32 postBase = lastConsonant + 1;
|
2005-06-17 19:20:43 +00:00
|
|
|
le_int32 postBaseLimit = classTable->scriptFlags & SF_POST_BASE_LIMIT_MASK;
|
2003-12-08 22:43:41 +00:00
|
|
|
le_bool seenVattu = FALSE;
|
|
|
|
le_bool seenBelowBaseForm = FALSE;
|
2009-06-11 18:34:01 +00:00
|
|
|
le_bool seenPreBaseForm = FALSE;
|
2006-11-22 22:50:53 +00:00
|
|
|
le_bool hasNukta = FALSE;
|
|
|
|
le_bool hasBelowBaseForm = FALSE;
|
|
|
|
le_bool hasPostBaseForm = FALSE;
|
2009-06-11 18:34:01 +00:00
|
|
|
le_bool hasPreBaseForm = FALSE;
|
2003-01-28 23:30:56 +00:00
|
|
|
|
2005-06-16 22:46:37 +00:00
|
|
|
if (postBase < markStart && classTable->isNukta(chars[postBase])) {
|
2006-11-22 22:50:53 +00:00
|
|
|
charClass = CC_NUKTA;
|
2004-03-25 19:27:43 +00:00
|
|
|
postBase += 1;
|
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
while (baseConsonant > baseLimit) {
|
2006-11-22 22:50:53 +00:00
|
|
|
nextClass = charClass;
|
|
|
|
hasNukta = IndicClassTable::isNukta(nextClass);
|
|
|
|
charClass = classTable->getCharClass(chars[baseConsonant]);
|
|
|
|
|
|
|
|
hasBelowBaseForm = IndicClassTable::hasBelowBaseForm(charClass) && !hasNukta;
|
|
|
|
hasPostBaseForm = IndicClassTable::hasPostBaseForm(charClass) && !hasNukta;
|
2009-06-11 18:34:01 +00:00
|
|
|
hasPreBaseForm = IndicClassTable::hasPreBaseForm(charClass) && !hasNukta;
|
2003-01-28 23:30:56 +00:00
|
|
|
|
|
|
|
if (IndicClassTable::isConsonant(charClass)) {
|
|
|
|
if (postBaseLimit == 0 || seenVattu ||
|
|
|
|
(baseConsonant > baseLimit && !classTable->isVirama(chars[baseConsonant - 1])) ||
|
2009-06-11 18:34:01 +00:00
|
|
|
!(hasBelowBaseForm || hasPostBaseForm || hasPreBaseForm)) {
|
2003-01-28 23:30:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
// Note any pre-base consonants
|
|
|
|
if ( baseConsonant == lastConsonant && lastConsonant > 0 &&
|
|
|
|
hasPreBaseForm && classTable->isVirama(chars[baseConsonant - 1])) {
|
|
|
|
output.notePreBaseConsonant(lastConsonant,chars[lastConsonant],chars[lastConsonant-1],tagArray2);
|
|
|
|
seenPreBaseForm = TRUE;
|
|
|
|
|
|
|
|
}
|
2006-11-22 22:50:53 +00:00
|
|
|
// consonants with nuktas are never vattus
|
|
|
|
seenVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2006-11-22 22:50:53 +00:00
|
|
|
// consonants with nuktas never have below- or post-base forms
|
|
|
|
if (hasPostBaseForm) {
|
2003-01-28 23:30:56 +00:00
|
|
|
if (seenBelowBaseForm) {
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
postBase = baseConsonant;
|
2006-11-22 22:50:53 +00:00
|
|
|
} else if (hasBelowBaseForm) {
|
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) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[prev], prev, tagArray2);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, tagArray2);
|
|
|
|
output.writeChar(chars[prev + 2], prev + 2, tagArray2);
|
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 any pre-base consonants
|
2009-06-11 18:34:01 +00:00
|
|
|
output.writePreBaseConsonant();
|
|
|
|
|
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];
|
2009-06-11 18:34:01 +00:00
|
|
|
// Don't put 'pstf' or 'blwf' on anything before the base consonant.
|
|
|
|
FeatureMask features = tagArray1 & ~( pstfFeatureMask | blwfFeatureMask );
|
2006-11-22 22:50:53 +00:00
|
|
|
|
|
|
|
charClass = classTable->getCharClass(ch);
|
|
|
|
nextClass = classTable->getCharClass(chars[i + 1]);
|
|
|
|
hasNukta = IndicClassTable::isNukta(nextClass);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
if (IndicClassTable::isConsonant(charClass)) {
|
2006-11-22 22:50:53 +00:00
|
|
|
if (IndicClassTable::isVattu(charClass) && !hasNukta && supressVattu) {
|
2005-08-06 00:48:27 +00:00
|
|
|
features = tagArray4;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 22:50:53 +00:00
|
|
|
supressVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
|
2003-01-28 23:30:56 +00:00
|
|
|
} else if (IndicClassTable::isVirama(charClass) && chars[i + 1] == C_SIGN_ZWNJ)
|
|
|
|
{
|
2005-08-06 00:48:27 +00:00
|
|
|
features = tagArray4;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(ch, i, features);
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
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
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
if (baseConsonant == lastConsonant && bcSpan < markStart &&
|
|
|
|
(classTable->isVirama(chars[bcSpan]) || classTable->isAlLakuna(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) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[i], i, tagArray4);
|
2003-01-28 23:30:56 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
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
|
2009-06-11 18:34:01 +00:00
|
|
|
if (baseConsonant != lastConsonant && !seenPreBaseForm) {
|
2003-01-28 23:30:56 +00:00
|
|
|
for (i = bcSpan + 1; i < postBase; i += 1) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[i], i, tagArray1);
|
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
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[bcSpan], bcSpan, tagArray1);
|
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
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
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
|
|
|
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) != 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
if (baseLimit == prev + 2) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[prev], prev, tagArray0);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, tagArray0);
|
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?
|
2009-06-11 18:34:01 +00:00
|
|
|
if (baseConsonant != lastConsonant && !seenPreBaseForm) {
|
2003-01-28 23:30:56 +00:00
|
|
|
if (postBase <= lastConsonant) {
|
|
|
|
for (i = postBase; i <= lastConsonant; i += 1) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[i], i, tagArray3);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write halant that was after base consonant
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[bcSpan], bcSpan, tagArray1);
|
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])) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[matra], matra, tagArray4);
|
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
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeMpost();
|
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
output.writeLengthMark();
|
2008-05-27 22:44:40 +00:00
|
|
|
output.writeAlLakuna();
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-01-28 23:30:56 +00:00
|
|
|
// write reph
|
2005-06-17 19:20:43 +00:00
|
|
|
if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
|
2003-01-28 23:30:56 +00:00
|
|
|
if (baseLimit == prev + 2) {
|
2005-08-06 00:48:27 +00:00
|
|
|
output.writeChar(chars[prev], prev, tagArray0);
|
|
|
|
output.writeChar(chars[prev + 1], prev + 1, tagArray0);
|
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();
|
|
|
|
}
|
|
|
|
|
2008-10-28 14:50:15 +00:00
|
|
|
void IndicReordering::adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage, LEErrorCode& success)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-01-28 23:30:56 +00:00
|
|
|
if (mpreFixups != NULL) {
|
2008-10-28 14:50:15 +00:00
|
|
|
mpreFixups->apply(glyphStorage, success);
|
2003-01-04 02:52:23 +00:00
|
|
|
|
|
|
|
delete mpreFixups;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-02 23:35:48 +00:00
|
|
|
void IndicReordering::applyPresentationForms(LEGlyphStorage &glyphStorage, le_int32 count)
|
|
|
|
{
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
|
|
|
|
// This sets us up for 2nd pass of glyph substitution as well as setting the feature masks for the
|
|
|
|
// GPOS table lookups
|
|
|
|
|
|
|
|
for ( le_int32 i = 0 ; i < count ; i++ ) {
|
|
|
|
glyphStorage.setAuxData(i, ( presentationFormsMask | positioningFormsMask ), success);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void IndicReordering::finalReordering(LEGlyphStorage &glyphStorage, le_int32 count)
|
|
|
|
{
|
|
|
|
LEErrorCode success = LE_NO_ERROR;
|
|
|
|
|
|
|
|
// Reposition REPH as appropriate
|
|
|
|
|
|
|
|
for ( le_int32 i = 0 ; i < count ; i++ ) {
|
|
|
|
|
|
|
|
le_int32 tmpAuxData = glyphStorage.getAuxData(i,success);
|
|
|
|
LEGlyphID tmpGlyph = glyphStorage.getGlyphID(i,success);
|
|
|
|
|
|
|
|
if ( ( tmpGlyph != NO_GLYPH ) && (tmpAuxData & rephConsonantMask) && !(tmpAuxData & repositionedGlyphMask)) {
|
|
|
|
|
|
|
|
le_bool targetPositionFound = false;
|
|
|
|
le_int32 targetPosition = i+1;
|
|
|
|
le_int32 baseConsonantData;
|
|
|
|
|
|
|
|
while (!targetPositionFound) {
|
|
|
|
tmpGlyph = glyphStorage.getGlyphID(targetPosition,success);
|
|
|
|
tmpAuxData = glyphStorage.getAuxData(targetPosition,success);
|
|
|
|
|
|
|
|
if ( tmpAuxData & baseConsonantMask ) {
|
|
|
|
baseConsonantData = tmpAuxData;
|
|
|
|
targetPositionFound = true;
|
|
|
|
} else {
|
|
|
|
targetPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we are not putting the reph into an empty hole
|
|
|
|
|
|
|
|
le_bool targetPositionHasGlyph = false;
|
|
|
|
while (!targetPositionHasGlyph) {
|
|
|
|
tmpGlyph = glyphStorage.getGlyphID(targetPosition,success);
|
|
|
|
if ( tmpGlyph != NO_GLYPH ) {
|
|
|
|
targetPositionHasGlyph = true;
|
|
|
|
} else {
|
|
|
|
targetPosition--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure that REPH is positioned after any above base or post base matras
|
|
|
|
//
|
|
|
|
le_bool checkMatraDone = false;
|
|
|
|
le_int32 checkMatraPosition = targetPosition+1;
|
|
|
|
while ( !checkMatraDone ) {
|
|
|
|
tmpAuxData = glyphStorage.getAuxData(checkMatraPosition,success);
|
|
|
|
if ( checkMatraPosition >= count || ( (tmpAuxData ^ baseConsonantData) & LE_GLYPH_GROUP_MASK)) {
|
|
|
|
checkMatraDone = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( (tmpAuxData & matraMask) &&
|
|
|
|
(((tmpAuxData & markPositionMask) == aboveBasePosition) ||
|
|
|
|
((tmpAuxData & markPositionMask) == postBasePosition))) {
|
|
|
|
targetPosition = checkMatraPosition;
|
|
|
|
}
|
|
|
|
checkMatraPosition++;
|
|
|
|
}
|
|
|
|
|
|
|
|
glyphStorage.moveGlyph(i,targetPosition,repositionedGlyphMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
le_int32 IndicReordering::v2process(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
|
|
|
|
LEUnicode *outChars, LEGlyphStorage &glyphStorage)
|
|
|
|
{
|
|
|
|
const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
|
|
|
|
|
|
|
|
DynamicProperties dynProps[INDIC_BLOCK_SIZE];
|
|
|
|
IndicReordering::getDynamicProperties(dynProps,classTable);
|
|
|
|
|
|
|
|
IndicReorderingOutput output(outChars, glyphStorage, NULL);
|
|
|
|
le_int32 i, firstConsonant, baseConsonant, secondConsonant, inv_count = 0, beginSyllable = 0;
|
2009-04-15 01:57:02 +00:00
|
|
|
//le_bool lastInWord = FALSE;
|
2009-03-02 23:35:48 +00:00
|
|
|
|
|
|
|
while (beginSyllable < charCount) {
|
|
|
|
le_int32 nextSyllable = findSyllable(classTable, chars, beginSyllable, charCount);
|
|
|
|
|
|
|
|
output.reset();
|
|
|
|
|
|
|
|
// Find the First Consonant
|
|
|
|
for ( firstConsonant = beginSyllable ; firstConsonant < nextSyllable ; firstConsonant++ ) {
|
|
|
|
if ( classTable->isConsonant(chars[firstConsonant]) ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the base consonant
|
|
|
|
|
|
|
|
baseConsonant = nextSyllable - 1;
|
|
|
|
secondConsonant = firstConsonant;
|
|
|
|
|
|
|
|
// TODO: Use Dynamic Properties for hasBelowBaseForm and hasPostBaseForm()
|
|
|
|
|
|
|
|
while ( baseConsonant > firstConsonant ) {
|
|
|
|
if ( classTable->isConsonant(chars[baseConsonant]) &&
|
|
|
|
!classTable->hasBelowBaseForm(chars[baseConsonant]) &&
|
|
|
|
!classTable->hasPostBaseForm(chars[baseConsonant]) ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ( classTable->isConsonant(chars[baseConsonant]) ) {
|
|
|
|
secondConsonant = baseConsonant;
|
|
|
|
}
|
|
|
|
baseConsonant--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the syllable starts with Ra + Halant ( in a script that has Reph ) and has more than one
|
|
|
|
// consonant, Ra is excluced from candidates for base consonants
|
|
|
|
|
|
|
|
if ( classTable->isReph(chars[beginSyllable]) &&
|
|
|
|
beginSyllable+1 < nextSyllable && classTable->isVirama(chars[beginSyllable+1]) &&
|
|
|
|
secondConsonant != firstConsonant) {
|
|
|
|
baseConsonant = secondConsonant;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populate the output
|
|
|
|
for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
|
|
|
|
|
|
|
|
// Handle invalid combinartions
|
|
|
|
|
|
|
|
if ( classTable->isVirama(chars[beginSyllable]) ||
|
|
|
|
classTable->isMatra(chars[beginSyllable]) ||
|
|
|
|
classTable->isVowelModifier(chars[beginSyllable]) ||
|
|
|
|
classTable->isNukta(chars[beginSyllable]) ) {
|
|
|
|
output.writeChar(C_DOTTED_CIRCLE,beginSyllable,basicShapingFormsMask);
|
|
|
|
inv_count++;
|
|
|
|
}
|
|
|
|
output.writeChar(chars[i],i, basicShapingFormsMask);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adjust features and set syllable structure bits
|
|
|
|
|
|
|
|
for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
|
|
|
|
|
|
|
|
FeatureMask outMask = output.getFeatures(i+inv_count);
|
|
|
|
FeatureMask saveMask = outMask;
|
|
|
|
|
|
|
|
// Since reph can only validly occur at the beginning of a syllable
|
|
|
|
// We only apply it to the first 2 characters in the syllable, to keep it from
|
|
|
|
// conflicting with other features ( i.e. rkrf )
|
|
|
|
|
|
|
|
// TODO : Use the dynamic property for determining isREPH
|
|
|
|
if ( i == beginSyllable && i < baseConsonant && classTable->isReph(chars[i]) &&
|
|
|
|
i+1 < nextSyllable && classTable->isVirama(chars[i+1])) {
|
|
|
|
outMask |= rphfFeatureMask;
|
|
|
|
outMask |= rephConsonantMask;
|
|
|
|
output.setFeatures(i+1+inv_count,outMask);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( i == baseConsonant ) {
|
|
|
|
outMask |= baseConsonantMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( classTable->isMatra(chars[i])) {
|
|
|
|
outMask |= matraMask;
|
|
|
|
if ( classTable->hasAboveBaseForm(chars[i])) {
|
|
|
|
outMask |= aboveBasePosition;
|
|
|
|
} else if ( classTable->hasBelowBaseForm(chars[i])) {
|
|
|
|
outMask |= belowBasePosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't apply half form to virama that stands alone at the end of a syllable
|
|
|
|
// to prevent half forms from forming when syllable ends with virama
|
|
|
|
|
|
|
|
if ( classTable->isVirama(chars[i]) && (i+1 == nextSyllable) ) {
|
|
|
|
outMask ^= halfFeatureMask;
|
|
|
|
if ( classTable->isConsonant(chars[i-1]) ) {
|
|
|
|
FeatureMask tmp = output.getFeatures(i-1+inv_count);
|
|
|
|
tmp ^= halfFeatureMask;
|
|
|
|
output.setFeatures(i-1+inv_count,tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( outMask != saveMask ) {
|
|
|
|
output.setFeatures(i+inv_count,outMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output.decomposeReorderMatras(classTable,beginSyllable,nextSyllable,inv_count);
|
|
|
|
|
|
|
|
beginSyllable = nextSyllable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return output.getOutputIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-11 18:34:01 +00:00
|
|
|
void IndicReordering::getDynamicProperties( DynamicProperties *, const IndicClassTable *classTable ) {
|
2009-03-02 23:35:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
LEUnicode currentChar;
|
|
|
|
LEUnicode virama;
|
|
|
|
LEUnicode workChars[2];
|
|
|
|
LEGlyphStorage workGlyphs;
|
|
|
|
|
|
|
|
IndicReorderingOutput workOutput(workChars, workGlyphs, NULL);
|
|
|
|
|
2009-04-15 01:57:02 +00:00
|
|
|
//le_int32 offset = 0;
|
2009-03-02 23:35:48 +00:00
|
|
|
|
|
|
|
// First find the relevant virama for the script we are dealing with
|
|
|
|
|
|
|
|
for ( currentChar = classTable->firstChar ; currentChar <= classTable->lastChar ; currentChar++ ) {
|
|
|
|
if ( classTable->isVirama(currentChar)) {
|
|
|
|
virama = currentChar;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( currentChar = classTable->firstChar ; currentChar <= classTable->lastChar ; currentChar++ ) {
|
|
|
|
if ( classTable->isConsonant(currentChar)) {
|
|
|
|
workOutput.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|