3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
5 * Developed at DIT - Government of Bhutan
7 * Contact person: Pema Geyleg - <pema_geyleg@druknet.bt>
9 * This file is a modification of the ICU file KhmerReordering.cpp
10 * by Jens Herden and Javier Sola who have given all their possible rights to IBM and the Governement of Bhutan
11 * A first module for Dzongkha was developed by Karunakar under Panlocalisation funding.
12 * Assistance for this module has been received from Namgay Thinley, Christopher Fynn and Javier Sola
17 #include "OpenTypeLayoutEngine.h"
18 #include "TibetanLayoutEngine.h"
19 #include "LEGlyphStorage.h"
20 #include "TibetanReordering.h"
24 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TibetanOpenTypeLayoutEngine)
26 TibetanOpenTypeLayoutEngine::TibetanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
27 le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success)
28 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success)
30 fFeatureMap = TibetanReordering::getFeatureMap(fFeatureMapCount);
34 TibetanOpenTypeLayoutEngine::TibetanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
35 le_int32 typoFlags, LEErrorCode &success)
36 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success)
38 fFeatureMap = TibetanReordering::getFeatureMap(fFeatureMapCount);
42 TibetanOpenTypeLayoutEngine::~TibetanOpenTypeLayoutEngine()
48 // Output: characters, char indices, tags
49 // Returns: output character count
50 le_int32 TibetanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
51 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
53 if (LE_FAILURE(success)) {
57 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
58 success = LE_ILLEGAL_ARGUMENT_ERROR;
62 le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough
64 outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
66 if (outChars == NULL) {
67 success = LE_MEMORY_ALLOCATION_ERROR;
71 glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
72 glyphStorage.allocateAuxData(success);
74 if (LE_FAILURE(success)) {
75 LE_DELETE_ARRAY(outChars);
79 // NOTE: assumes this allocates featureTags...
80 // (probably better than doing the worst case stuff here...)
81 le_int32 outCharCount = TibetanReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
83 glyphStorage.adoptGlyphCount(outCharCount);