2 * HanLayoutEngine.cpp: OpenType processing for Han fonts.
4 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved.
9 #include "LELanguages.h"
11 #include "LayoutEngine.h"
12 #include "OpenTypeLayoutEngine.h"
13 #include "HanLayoutEngine.h"
14 #include "ScriptAndLanguageTags.h"
15 #include "LEGlyphStorage.h"
16 #include "OpenTypeTables.h"
20 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
22 #define loclFeatureTag LE_LOCL_FEATURE_TAG
23 #define smplFeatureTag LE_SMPL_FEATURE_TAG
24 #define tradFeatureTag LE_TRAD_FEATURE_TAG
26 #define loclFeatureMask 0x80000000UL
27 #define smplFeatureMask 0x40000000UL
28 #define tradFeatureMask 0x20000000UL
30 static const FeatureMap featureMap[] =
32 {loclFeatureTag, loclFeatureMask},
33 {smplFeatureTag, smplFeatureMask},
34 {tradFeatureTag, tradFeatureMask}
37 static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
39 #define features (loclFeatureMask)
41 HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
42 le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success)
43 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success)
45 fFeatureMap = featureMap;
46 fFeatureMapCount = featureMapCount;
49 HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
54 le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
55 LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
57 if (LE_FAILURE(success)) {
61 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
62 success = LE_ILLEGAL_ARGUMENT_ERROR;
66 glyphStorage.allocateGlyphArray(count, FALSE, success);
67 glyphStorage.allocateAuxData(success);
69 if (LE_FAILURE(success)) {
73 // FIXME: do we want to add the 'trad' feature for 'ZHT' and the
74 // 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
75 // flag from the language tag lookups, so we can use these features
76 // with the default LangSys...
77 for (le_int32 i = 0; i < count; i += 1) {
78 glyphStorage.setAuxData(i, features, success);