3171N/A/*
3171N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3171N/A *
3171N/A * This code is free software; you can redistribute it and/or modify it
3171N/A * under the terms of the GNU General Public License version 2 only, as
3171N/A * published by the Free Software Foundation. Oracle designates this
3171N/A * particular file as subject to the "Classpath" exception as provided
3171N/A * by Oracle in the LICENSE file that accompanied this code.
3171N/A *
3171N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3171N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3171N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3171N/A * version 2 for more details (a copy is included in the LICENSE file that
3171N/A * accompanied this code).
3171N/A *
3171N/A * You should have received a copy of the GNU General Public License version
3171N/A * 2 along with this work; if not, write to the Free Software Foundation,
3171N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3171N/A *
3171N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3171N/A * or visit www.oracle.com if you need additional information or have any
3171N/A * questions.
3171N/A *
3171N/A */
3171N/A
3171N/A/*
3171N/A *
3171N/A * (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved
3171N/A *
3171N/A * Developed at DIT - Government of Bhutan
3171N/A *
3171N/A * Contact person: Pema Geyleg - <pema_geyleg@druknet.bt>
3171N/A *
3171N/A * This file is a modification of the ICU file KhmerReordering.cpp
3171N/A * by Jens Herden and Javier Sola who have given all their possible rights to IBM and the Governement of Bhutan
3171N/A * A first module for Dzongkha was developed by Karunakar under Panlocalisation funding.
3171N/A * Assistance for this module has been received from Namgay Thinley, Christopher Fynn and Javier Sola
3171N/A *
3171N/A */
3171N/A
3171N/A//#include <stdio.h>
3171N/A#include "LETypes.h"
3171N/A#include "OpenTypeTables.h"
3171N/A#include "TibetanReordering.h"
3171N/A#include "LEGlyphStorage.h"
3171N/A
3171N/A
3171N/AU_NAMESPACE_BEGIN
3171N/A
3171N/A// Characters that get refered to by name...
3171N/Aenum
3171N/A{
3171N/A C_DOTTED_CIRCLE = 0x25CC,
3171N/A C_PRE_NUMBER_MARK = 0x0F3F
3171N/A };
3171N/A
3171N/A
3171N/Aenum
3171N/A{
3171N/A // simple classes, they are used in the statetable (in this file) to control the length of a syllable
3171N/A // they are also used to know where a character should be placed (location in reference to the base character)
3171N/A // and also to know if a character, when independtly displayed, should be displayed with a dotted-circle to
3171N/A // indicate error in syllable construction
3171N/A _xx = TibetanClassTable::CC_RESERVED,
3171N/A _ba = TibetanClassTable::CC_BASE,
3171N/A _sj = TibetanClassTable::CC_SUBJOINED | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _tp = TibetanClassTable::CC_TSA_PHRU | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_ABOVE,
3171N/A _ac = TibetanClassTable::CC_A_CHUNG | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _cs = TibetanClassTable::CC_COMP_SANSKRIT | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _ha = TibetanClassTable::CC_HALANTA | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _bv = TibetanClassTable::CC_BELOW_VOWEL | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _av = TibetanClassTable::CC_ABOVE_VOWEL | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_ABOVE,
3171N/A _an = TibetanClassTable::CC_ANUSVARA | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_ABOVE,
3171N/A _cb = TibetanClassTable::CC_CANDRABINDU | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_ABOVE,
3171N/A _vs = TibetanClassTable::CC_VISARGA | TibetanClassTable::CF_DOTTED_CIRCLE| TibetanClassTable::CF_POS_AFTER,
3171N/A _as = TibetanClassTable::CC_ABOVE_S_MARK | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_ABOVE,
3171N/A _bs = TibetanClassTable::CC_BELOW_S_MARK | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_BELOW,
3171N/A _di = TibetanClassTable::CC_DIGIT | TibetanClassTable::CF_DIGIT,
3171N/A _pd = TibetanClassTable::CC_PRE_DIGIT_MARK | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_PREDIGIT | TibetanClassTable::CF_POS_BEFORE ,
3171N/A _bd = TibetanClassTable::CC_POST_BELOW_DIGIT_M | TibetanClassTable::CF_DOTTED_CIRCLE | TibetanClassTable::CF_POS_AFTER
3171N/A};
3171N/A
3171N/A
3171N/A// Character class tables
3171N/A//_xx Non Combining characters
3171N/A//_ba Base Consonants
3171N/A//_sj Subjoined consonants
3171N/A//_tp Tsa - phru
3171N/A//_ac A-chung, Vowel Lengthening mark
3171N/A//_cs Precomposed Sanskrit vowel + subjoined consonants
3171N/A//_ha Halanta/Virama
3171N/A//_bv Below vowel
3171N/A//_av above vowel
3171N/A//_an Anusvara
3171N/A//_cb Candrabindu
3171N/A//_vs Visaraga/Post mark
3171N/A//_as Upper Stress marks
3171N/A//_bs Lower Stress marks
3171N/A//_di Digit
3171N/A//_pd Number pre combining, Needs reordering
3171N/A//_bd Other number combining marks
3171N/A
3171N/Astatic const TibetanClassTable::CharClass tibetanCharClasses[] =
3171N/A{
3171N/A // 0 1 2 3 4 5 6 7 8 9 a b c d e f
3171N/A _xx, _ba, _xx, _xx, _ba, _ba, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0F00 - 0F0F 0
3171N/A _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _bd, _bd, _xx, _xx, _xx, _xx, _xx, _xx, // 0F10 - 0F1F 1
3171N/A _di, _di, _di, _di, _di, _di, _di, _di, _di, _di, _xx, _xx, _xx, _xx, _xx, _xx, // 0F20 - 0F2F 2
3171N/A _xx, _xx, _xx, _xx, _xx, _bs, _xx, _bs, _xx, _tp, _xx, _xx, _xx, _xx, _bd, _pd, // 0F30 - 0F3F 3
3171N/A _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _xx, _ba, _ba, _ba, _ba, _ba, _ba, _ba, // 0F40 - 0F4F 4
3171N/A _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, // 0F50 - 0F5F 5
3171N/A _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _xx, _xx, _xx, _xx, _xx, // 0F60 - 0F6F 6
3171N/A _xx, _ac, _av, _cs, _bv, _bv, _cs, _cs, _cs, _cs, _av, _av, _av, _av, _an, _vs, // 0F70 - 0F7F 7
3171N/A _av, _cs, _cb, _cb, _ha, _xx, _as, _as, _ba, _ba, _ba, _ba, _xx, _xx, _xx, _xx, // 0F80 - 0F8F 8
3171N/A _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _xx, _sj, _sj, _sj, _sj, _sj, _sj, _sj, // 0F90 - 0F9F 9
3171N/A _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, // 0FA0 - 0FAF a
3171N/A _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _xx, _sj, _sj, // 0FB0 - 0FBF b
3171N/A _xx, _xx, _xx, _xx, _xx, _xx, _bs, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0FC0 - 0FCF c
3171N/A _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx,// 0FD0 - 0FDF d
3171N/A _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0FE0 - 0FEF e
3171N/A _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0FF0 - 0FFF f
3171N/A};
3171N/A
3171N/A
3171N/A//
3171N/A// Tibetan Class Tables
3171N/A//
3171N/A
3171N/A//
3171N/A// The range of characters defined in the above table is defined here. For Tibetan 0F00 to 0FFF
3171N/A// Even if the Tibetan range is bigger, most of the characters are not combinable, and therefore treated
3171N/A// as _xx
3171N/Astatic const TibetanClassTable tibetanClassTable = {0x0F00, 0x0FFF, tibetanCharClasses};
3171N/A
3171N/A
3171N/A// Below we define how a character in the input string is either in the tibetanCharClasses table
3171N/A// (in which case we get its type back), or an unknown object in which case we get _xx (CC_RESERVED) back
3171N/ATibetanClassTable::CharClass TibetanClassTable::getCharClass(LEUnicode ch) const
3171N/A{
3171N/A if (ch < firstChar || ch > lastChar) {
3171N/A return CC_RESERVED;
3171N/A }
3171N/A
3171N/A return classTable[ch - firstChar];
3171N/A}
3171N/A
3171N/Aconst TibetanClassTable *TibetanClassTable::getTibetanClassTable()
3171N/A{
3171N/A return &tibetanClassTable;
3171N/A}
3171N/A
3171N/A
3171N/A
3171N/Aclass TibetanReorderingOutput : public UMemory {
3171N/Aprivate:
3171N/A le_int32 fSyllableCount;
3171N/A le_int32 fOutIndex;
3171N/A LEUnicode *fOutChars;
3171N/A
3171N/A LEGlyphStorage &fGlyphStorage;
3171N/A
3171N/A
3171N/Apublic:
3171N/A TibetanReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage)
3171N/A : fSyllableCount(0), fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage)
3171N/A {
3171N/A // nothing else to do...
3171N/A }
3171N/A
3171N/A ~TibetanReorderingOutput()
3171N/A {
3171N/A // nothing to do here...
3171N/A }
3171N/A
3171N/A void reset()
3171N/A {
3171N/A fSyllableCount += 1;
3171N/A }
3171N/A
3171N/A void writeChar(LEUnicode ch, le_uint32 charIndex, FeatureMask featureMask)
3171N/A {
3171N/A LEErrorCode success = LE_NO_ERROR;
3171N/A
3171N/A fOutChars[fOutIndex] = ch;
3171N/A
3171N/A fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
3171N/A fGlyphStorage.setAuxData(fOutIndex, featureMask, success);
3171N/A
3171N/A fOutIndex += 1;
3171N/A }
3171N/A
3171N/A le_int32 getOutputIndex()
3171N/A {
3171N/A return fOutIndex;
3171N/A }
3171N/A};
3171N/A
3171N/A
3171N/A//TODO remove unused flags
3171N/A#define ccmpFeatureTag LE_CCMP_FEATURE_TAG
3171N/A#define blwfFeatureTag LE_BLWF_FEATURE_TAG
3171N/A#define pstfFeatureTag LE_PSTF_FEATURE_TAG
3171N/A#define presFeatureTag LE_PRES_FEATURE_TAG
3171N/A#define blwsFeatureTag LE_BLWS_FEATURE_TAG
3171N/A#define abvsFeatureTag LE_ABVS_FEATURE_TAG
3171N/A#define pstsFeatureTag LE_PSTS_FEATURE_TAG
3171N/A
3171N/A#define blwmFeatureTag LE_BLWM_FEATURE_TAG
3171N/A#define abvmFeatureTag LE_ABVM_FEATURE_TAG
3171N/A#define distFeatureTag LE_DIST_FEATURE_TAG
3171N/A
3171N/A#define prefFeatureTag LE_PREF_FEATURE_TAG
3171N/A#define abvfFeatureTag LE_ABVF_FEATURE_TAG
3171N/A#define cligFeatureTag LE_CLIG_FEATURE_TAG
3171N/A#define mkmkFeatureTag LE_MKMK_FEATURE_TAG
3171N/A
3171N/A// Shaping features
3171N/A#define prefFeatureMask 0x80000000UL
3171N/A#define blwfFeatureMask 0x40000000UL
3171N/A#define abvfFeatureMask 0x20000000UL
3171N/A#define pstfFeatureMask 0x10000000UL
3171N/A#define presFeatureMask 0x08000000UL
3171N/A#define blwsFeatureMask 0x04000000UL
3171N/A#define abvsFeatureMask 0x02000000UL
3171N/A#define pstsFeatureMask 0x01000000UL
3171N/A#define cligFeatureMask 0x00800000UL
3171N/A#define ccmpFeatureMask 0x00040000UL
3171N/A
3171N/A// Positioning features
3171N/A#define distFeatureMask 0x00400000UL
3171N/A#define blwmFeatureMask 0x00200000UL
3171N/A#define abvmFeatureMask 0x00100000UL
3171N/A#define mkmkFeatureMask 0x00080000UL
3171N/A
3171N/A#define tagPref (ccmpFeatureMask | prefFeatureMask | presFeatureMask | cligFeatureMask | distFeatureMask)
3171N/A#define tagAbvf (ccmpFeatureMask | abvfFeatureMask | abvsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | mkmkFeatureMask)
3171N/A#define tagPstf (ccmpFeatureMask | blwfFeatureMask | blwsFeatureMask | prefFeatureMask | presFeatureMask | pstfFeatureMask | pstsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask)
3171N/A#define tagBlwf (ccmpFeatureMask | blwfFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask | mkmkFeatureMask)
3171N/A#define tagDefault (ccmpFeatureMask | prefFeatureMask | blwfFeatureMask | presFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask | mkmkFeatureMask)
3171N/A
3171N/A
3171N/A
3171N/A// These are in the order in which the features need to be applied
3171N/A// for correct processing
3171N/Astatic const FeatureMap featureMap[] =
3171N/A{
3171N/A // Shaping features
3171N/A {ccmpFeatureTag, ccmpFeatureMask},
3171N/A {prefFeatureTag, prefFeatureMask},
3171N/A {blwfFeatureTag, blwfFeatureMask},
3171N/A {abvfFeatureTag, abvfFeatureMask},
3171N/A {pstfFeatureTag, pstfFeatureMask},
3171N/A {presFeatureTag, presFeatureMask},
3171N/A {blwsFeatureTag, blwsFeatureMask},
3171N/A {abvsFeatureTag, abvsFeatureMask},
3171N/A {pstsFeatureTag, pstsFeatureMask},
3171N/A {cligFeatureTag, cligFeatureMask},
3171N/A
3171N/A // Positioning features
3171N/A {distFeatureTag, distFeatureMask},
3171N/A {blwmFeatureTag, blwmFeatureMask},
3171N/A {abvmFeatureTag, abvmFeatureMask},
3171N/A {mkmkFeatureTag, mkmkFeatureMask},
3171N/A};
3171N/A
3171N/Astatic const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
3171N/A
3171N/A// The stateTable is used to calculate the end (the length) of a well
3171N/A// formed Tibetan Syllable.
3171N/A//
3171N/A// Each horizontal line is ordered exactly the same way as the values in TibetanClassTable
3171N/A// CharClassValues in TibetanReordering.h This coincidence of values allows the
3171N/A// follow up of the table.
3171N/A//
3171N/A// Each line corresponds to a state, which does not necessarily need to be a type
3171N/A// of component... for example, state 2 is a base, with is always a first character
3171N/A// in the syllable, but the state could be produced a consonant of any type when
3171N/A// it is the first character that is analysed (in ground state).
3171N/A//
3171N/Astatic const le_int8 tibetanStateTable[][TibetanClassTable::CC_COUNT] =
3171N/A{
3171N/A
3171N/A
3171N/A //Dzongkha state table
3171N/A //xx ba sj tp ac cs ha bv av an cb vs as bs di pd bd
3171N/A { 1, 2, 4, 3, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, 20, 21, 21,}, // 0 - ground state
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, // 1 - exit state (or sign to the right of the syllable)
3171N/A {-1, -1, 4, 3, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 2 - Base consonant
3171N/A {-1, -1, 5, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 3 - Tsa phru after base
3171N/A {-1, -1, 4, 6, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 4 - Subjoined consonant after base
3171N/A {-1, -1, 5, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 5 - Subjoined consonant after tsa phru
3171N/A {-1, -1, -1, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 6 - Tsa phru after subjoined consonant
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, // 7 - Pre Composed Sanskrit
3171N/A {-1, -1, -1, -1, -1, -1, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 8 - A-chung
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, -1, 19, 19, -1, -1, -1,}, // 9 - Halanta
3171N/A {-1, -1, -1, -1, -1, -1, -1, 11, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 10 - below vowel 1
3171N/A {-1, -1, -1, -1, -1, -1, -1, 12, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 11 - below vowel 2
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, // 12 - below vowel 3
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, 14, 17, 17, 18, 19, 19, -1, -1, -1,}, // 13 - Anusvara before vowel
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 17, 18, 19, 19, -1, -1, -1,}, // 14 - above vowel 1
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, 16, 17, 17, 18, 19, 19, -1, -1, -1,}, // 15 - above vowel 2
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 17, 18, 19, 19, -1, -1, -1,}, // 16 - above vowel 3
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 19, 19, -1, -1, -1,}, // 17 - Anusvara or Candrabindu after vowel
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, // 18 - Visarga
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, // 19 - strss mark
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 21,}, // 20 - digit
3171N/A {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, // 21 - digit mark
3171N/A
3171N/A
3171N/A};
3171N/A
3171N/A
3171N/Aconst FeatureMap *TibetanReordering::getFeatureMap(le_int32 &count)
3171N/A{
3171N/A count = featureMapCount;
3171N/A
3171N/A return featureMap;
3171N/A}
3171N/A
3171N/A
3171N/A// Given an input string of characters and a location in which to start looking
3171N/A// calculate, using the state table, which one is the last character of the syllable
3171N/A// that starts in the starting position.
3171N/Ale_int32 TibetanReordering::findSyllable(const TibetanClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
3171N/A{
3171N/A le_int32 cursor = prev;
3171N/A le_int8 state = 0;
3171N/A
3171N/A while (cursor < charCount) {
3171N/A TibetanClassTable::CharClass charClass = (classTable->getCharClass(chars[cursor]) & TibetanClassTable::CF_CLASS_MASK);
3171N/A
3171N/A state = tibetanStateTable[state][charClass];
3171N/A
3171N/A if (state < 0) {
3171N/A break;
3171N/A }
3171N/A
3171N/A cursor += 1;
3171N/A }
3171N/A
3171N/A return cursor;
3171N/A}
3171N/A
3171N/A
3171N/A// This is the real reordering function as applied to the Tibetan language
3171N/A
3171N/Ale_int32 TibetanReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32,
3171N/A LEUnicode *outChars, LEGlyphStorage &glyphStorage)
3171N/A{
3171N/A const TibetanClassTable *classTable = TibetanClassTable::getTibetanClassTable();
3171N/A
3171N/A TibetanReorderingOutput output(outChars, glyphStorage);
3171N/A TibetanClassTable::CharClass charClass;
3171N/A le_int32 i, prev = 0;
3171N/A
3171N/A // This loop only exits when we reach the end of a run, which may contain
3171N/A // several syllables.
3171N/A while (prev < charCount) {
3171N/A le_int32 syllable = findSyllable(classTable, chars, prev, charCount);
3171N/A
3171N/A output.reset();
3171N/A
3171N/A // shall we add a dotted circle?
3171N/A // If in the position in which the base should be (first char in the string) there is
3171N/A // a character that has the Dotted circle flag (a character that cannot be a base)
3171N/A // then write a dotted circle
3171N/A if (classTable->getCharClass(chars[prev]) & TibetanClassTable::CF_DOTTED_CIRCLE) {
3171N/A output.writeChar(C_DOTTED_CIRCLE, prev, tagDefault);
3171N/A }
3171N/A
3171N/A // copy the rest to output, inverting the pre-number mark if present after a digit.
3171N/A for (i = prev; i < syllable; i += 1) {
3171N/A charClass = classTable->getCharClass(chars[i]);
3171N/A
3171N/A if ((TibetanClassTable::CF_DIGIT & charClass)
3171N/A && ( classTable->getCharClass(chars[i+1]) & TibetanClassTable::CF_PREDIGIT))
3171N/A {
3171N/A output.writeChar(C_PRE_NUMBER_MARK, i, tagPref);
3171N/A output.writeChar(chars[i], i+1 , tagPref);
3171N/A i += 1;
3171N/A } else {
3171N/A switch (charClass & TibetanClassTable::CF_POS_MASK) {
3171N/A
3171N/A // If the present character is a number, and the next character is a pre-number combining mark
3171N/A // then the two characters are reordered
3171N/A
3171N/A case TibetanClassTable::CF_POS_ABOVE :
3171N/A output.writeChar(chars[i], i, tagAbvf);
3171N/A break;
3171N/A
3171N/A case TibetanClassTable::CF_POS_AFTER :
3171N/A output.writeChar(chars[i], i, tagPstf);
3171N/A break;
3171N/A
3171N/A case TibetanClassTable::CF_POS_BELOW :
3171N/A output.writeChar(chars[i], i, tagBlwf);
3171N/A break;
3171N/A
3171N/A default:
3171N/A // default - any other characters
3171N/A output.writeChar(chars[i], i, tagDefault);
3171N/A break;
3171N/A } // switch
3171N/A } // if
3171N/A } // for
3171N/A
3171N/A prev = syllable; // move the pointer to the start of next syllable
3171N/A }
3171N/A
3171N/A return output.getOutputIndex();
3171N/A}
3171N/A
3171N/A
3171N/AU_NAMESPACE_END