/*
- * @(#)ThaiShaping.cpp 1.13 00/03/15
*
- * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
*
*/
#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "OpenTypeTables.h"
+#include "LEGlyphStorage.h"
#include "ThaiShaping.h"
U_NAMESPACE_BEGIN
LEUnicode ThaiShaping::leftAboveVowel(LEUnicode vowel, le_uint8 glyphSet)
{
- static LEUnicode leftAboveVowels[][7] = {
+ static const LEUnicode leftAboveVowels[][7] = {
{0x0E61, 0x0E32, 0x0E33, 0x0E64, 0x0E65, 0x0E66, 0x0E67},
{0xF710, 0x0E32, 0x0E33, 0xF701, 0xF702, 0xF703, 0xF704},
{0xF884, 0x0E32, 0x0E33, 0xF885, 0xF886, 0xF887, 0xF788},
LEUnicode ThaiShaping::lowerRightTone(LEUnicode tone, le_uint8 glyphSet)
{
- static LEUnicode lowerRightTones[][7] = {
+ static const LEUnicode lowerRightTones[][7] = {
{0x0E68, 0x0E69, 0x0E6A, 0x0E6B, 0x0E6C, 0x0E6D, 0x0E6E},
{0x0E47, 0xF70A, 0xF70B, 0xF70C, 0xF70D, 0xF70E, 0x0E4D},
{0x0E47, 0xF88B, 0xF88E, 0xF891, 0xF894, 0xF897, 0x0E4D},
LEUnicode ThaiShaping::lowerLeftTone(LEUnicode tone, le_uint8 glyphSet)
{
- static LEUnicode lowerLeftTones[][7] = {
+ static const LEUnicode lowerLeftTones[][7] = {
{0x0E76, 0x0E77, 0x0E78, 0x0E79, 0x0E7A, 0x0E7B, 0x0E7C},
{0xF712, 0xF705, 0xF706, 0xF707, 0xF708, 0xF709, 0xF711},
{0xF889, 0xF88C, 0xF88F, 0xF892, 0xF895, 0xF898, 0xF899},
LEUnicode ThaiShaping::upperLeftTone(LEUnicode tone, le_uint8 glyphSet)
{
- static LEUnicode upperLeftTones[][7] = {
+ static const LEUnicode upperLeftTones[][7] = {
{0x0E6F, 0x0E70, 0x0E71, 0x0E72, 0x0E73, 0x0E74, 0x0E75},
{0xF712, 0xF713, 0xF714, 0xF715, 0xF716, 0xF717, 0xF711},
{0xF889, 0xF88A, 0xF88D, 0xF890, 0xF893, 0xF896, 0xF899},
LEUnicode ThaiShaping::lowerBelowVowel(LEUnicode vowel, le_uint8 glyphSet)
{
- static LEUnicode lowerBelowVowels[][3] = {
+ static const LEUnicode lowerBelowVowels[][3] = {
{0x0E3C, 0x0E3D, 0x0E3E},
{0xF718, 0xF719, 0xF71A},
{0x0E38, 0x0E39, 0x0E3A},
LEUnicode ThaiShaping::noDescenderCOD(LEUnicode cod, le_uint8 glyphSet)
{
- static LEUnicode noDescenderCODs[][4] = {
+ static const LEUnicode noDescenderCODs[][4] = {
{0x0E60, 0x0E0E, 0x0E0F, 0x0E63},
{0xF70F, 0x0E0E, 0x0E0F, 0xF700},
{0x0E0D, 0x0E0E, 0x0E0F, 0x0E10},
}
le_uint8 ThaiShaping::doTransition (StateTransition transition, LEUnicode currChar, le_int32 inputIndex, le_uint8 glyphSet,
- LEUnicode errorChar, LEUnicode *outputBuffer, le_int32 *charIndicies, le_int32 &outputIndex)
+ LEUnicode errorChar, LEUnicode *outputBuffer, LEGlyphStorage &glyphStorage, le_int32 &outputIndex)
{
+ LEErrorCode success = LE_NO_ERROR;
+
switch (transition.action) {
- case _A:
- charIndicies[outputIndex] = inputIndex;
+ case tA:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
- case _C:
- charIndicies[outputIndex] = inputIndex;
+ case tC:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
- case _D:
- charIndicies[outputIndex] = inputIndex;
+ case tD:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = leftAboveVowel(currChar, glyphSet);
break;
- case _E:
- charIndicies[outputIndex] = inputIndex;
+ case tE:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = lowerRightTone(currChar, glyphSet);
break;
- case _F:
- charIndicies[outputIndex] = inputIndex;
+ case tF:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = lowerLeftTone(currChar, glyphSet);
break;
- case _G:
- charIndicies[outputIndex] = inputIndex;
+ case tG:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = upperLeftTone(currChar, glyphSet);
break;
- case _H:
+ case tH:
{
LEUnicode cod = outputBuffer[outputIndex - 1];
LEUnicode coa = noDescenderCOD(cod, glyphSet);
if (cod != coa) {
outputBuffer[outputIndex - 1] = coa;
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
}
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = lowerBelowVowel(currChar, glyphSet);
break;
}
- case _R:
- charIndicies[outputIndex] = inputIndex;
+ case tR:
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = errorChar;
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
- case _S:
+ case tS:
if (currChar == CH_SARA_AM) {
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = errorChar;
}
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
default:
// FIXME: if we get here, there's an error
// in the state table!
- charIndicies[outputIndex] = inputIndex;
+ glyphStorage.setCharIndex(outputIndex, inputIndex, success);
outputBuffer[outputIndex++] = currChar;
break;
}
}
le_uint8 ThaiShaping::getNextState(LEUnicode ch, le_uint8 prevState, le_int32 inputIndex, le_uint8 glyphSet, LEUnicode errorChar,
- le_uint8 &charClass, LEUnicode *output, le_int32 *charIndicies, le_int32 &outputIndex)
+ le_uint8 &charClass, LEUnicode *output, LEGlyphStorage &glyphStorage, le_int32 &outputIndex)
{
StateTransition transition;
charClass = getCharClass(ch);
transition = getTransition(prevState, charClass);
- return doTransition(transition, ch, inputIndex, glyphSet, errorChar, output, charIndicies, outputIndex);
+ return doTransition(transition, ch, inputIndex, glyphSet, errorChar, output, glyphStorage, outputIndex);
}
le_bool ThaiShaping::isLegalHere(LEUnicode ch, le_uint8 prevState)
StateTransition transition = getTransition(prevState, charClass);
switch (transition.action) {
- case _A:
- case _C:
- case _D:
- case _E:
- case _F:
- case _G:
- case _H:
- return true;
+ case tA:
+ case tC:
+ case tD:
+ case tE:
+ case tF:
+ case tG:
+ case tH:
+ return TRUE;
- case _R:
- case _S:
- return false;
+ case tR:
+ case tS:
+ return FALSE;
default:
// FIXME: if we get here, there's an error
// in the state table!
- return false;
+ return FALSE;
}
}
le_int32 ThaiShaping::compose(const LEUnicode *input, le_int32 offset, le_int32 charCount, le_uint8 glyphSet,
- LEUnicode errorChar, LEUnicode *output, le_int32 *charIndicies)
+ LEUnicode errorChar, LEUnicode *output, LEGlyphStorage &glyphStorage)
{
le_uint8 state = 0;
le_int32 inputIndex;
if (ch == CH_SARA_AM && isLegalHere(ch, state)) {
outputIndex = conOutput;
state = getNextState(CH_NIKHAHIT, conState, inputIndex, glyphSet, errorChar, charClass,
- output, charIndicies, outputIndex);
+ output, glyphStorage, outputIndex);
for (int j = conInput + 1; j < inputIndex; j += 1) {
ch = input[j + offset];
state = getNextState(ch, state, j, glyphSet, errorChar, charClass,
- output, charIndicies, outputIndex);
+ output, glyphStorage, outputIndex);
}
ch = CH_SARA_AA;
}
state = getNextState(ch, state, inputIndex, glyphSet, errorChar, charClass,
- output, charIndicies, outputIndex);
+ output, glyphStorage, outputIndex);
if (charClass >= CON && charClass <= COD) {
conState = state;