36 #include "OpenTypeLayoutEngine.h" |
36 #include "OpenTypeLayoutEngine.h" |
37 #include "KhmerLayoutEngine.h" |
37 #include "KhmerLayoutEngine.h" |
38 #include "LEGlyphStorage.h" |
38 #include "LEGlyphStorage.h" |
39 #include "KhmerReordering.h" |
39 #include "KhmerReordering.h" |
40 |
40 |
41 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, |
41 U_NAMESPACE_BEGIN |
42 le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, |
42 |
43 const GlyphSubstitutionTableHeader *gsubTable) |
43 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine) |
|
44 |
|
45 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, |
|
46 le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable) |
44 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable) |
47 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable) |
45 { |
48 { |
46 fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount); |
49 fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount); |
47 fFeatureOrder = TRUE; |
50 fFeatureOrder = TRUE; |
48 } |
51 } |
49 |
52 |
50 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, |
53 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, |
51 le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags) |
54 le_int32 typoFlags) |
52 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags) |
55 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags) |
53 { |
56 { |
54 fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount); |
57 fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount); |
55 fFeatureOrder = TRUE; |
58 fFeatureOrder = TRUE; |
56 } |
59 } |
61 } |
64 } |
62 |
65 |
63 // Input: characters |
66 // Input: characters |
64 // Output: characters, char indices, tags |
67 // Output: characters, char indices, tags |
65 // Returns: output character count |
68 // Returns: output character count |
66 le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], |
69 le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, |
67 le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, |
70 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
68 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
|
69 { |
71 { |
70 if (LE_FAILURE(success)) { |
72 if (LE_FAILURE(success)) { |
71 return 0; |
73 return 0; |
72 } |
74 } |
73 |
75 |
74 if (chars == NULL || offset < 0 || count < 0 || max < 0 || |
76 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { |
75 offset >= max || offset + count > max) { |
|
76 success = LE_ILLEGAL_ARGUMENT_ERROR; |
77 success = LE_ILLEGAL_ARGUMENT_ERROR; |
77 return 0; |
78 return 0; |
78 } |
79 } |
79 |
80 |
80 le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough |
81 le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough |
94 return 0; |
95 return 0; |
95 } |
96 } |
96 |
97 |
97 // NOTE: assumes this allocates featureTags... |
98 // NOTE: assumes this allocates featureTags... |
98 // (probably better than doing the worst case stuff here...) |
99 // (probably better than doing the worst case stuff here...) |
99 le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, |
100 le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage); |
100 fScriptCode, outChars, glyphStorage); |
|
101 |
101 |
102 glyphStorage.adoptGlyphCount(outCharCount); |
102 glyphStorage.adoptGlyphCount(outCharCount); |
103 return outCharCount; |
103 return outCharCount; |
104 } |
104 } |
|
105 |
|
106 U_NAMESPACE_END |