]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | * HanLayoutEngine.cpp: OpenType processing for Han fonts. | |
3 | * | |
73c04bcf | 4 | * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved. |
b75a7d8f A |
5 | */ |
6 | ||
7 | #include "LETypes.h" | |
8 | #include "LEScripts.h" | |
9 | #include "LELanguages.h" | |
10 | ||
11 | #include "LayoutEngine.h" | |
12 | #include "OpenTypeLayoutEngine.h" | |
13 | #include "HanLayoutEngine.h" | |
14 | #include "ScriptAndLanguageTags.h" | |
374ca955 | 15 | #include "LEGlyphStorage.h" |
73c04bcf | 16 | #include "OpenTypeTables.h" |
374ca955 A |
17 | |
18 | U_NAMESPACE_BEGIN | |
b75a7d8f | 19 | |
374ca955 | 20 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine) |
b75a7d8f | 21 | |
73c04bcf A |
22 | #define loclFeatureTag LE_LOCL_FEATURE_TAG |
23 | #define smplFeatureTag LE_SMPL_FEATURE_TAG | |
24 | #define tradFeatureTag LE_TRAD_FEATURE_TAG | |
25 | ||
26 | #define loclFeatureMask 0x80000000UL | |
27 | #define smplFeatureMask 0x40000000UL | |
28 | #define tradFeatureMask 0x20000000UL | |
29 | ||
30 | static const FeatureMap featureMap[] = | |
31 | { | |
32 | {loclFeatureTag, loclFeatureMask}, | |
33 | {smplFeatureTag, smplFeatureMask}, | |
34 | {tradFeatureTag, tradFeatureMask} | |
35 | }; | |
36 | ||
37 | static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap); | |
38 | ||
39 | #define features (loclFeatureMask) | |
40 | ||
b75a7d8f | 41 | HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, |
73c04bcf A |
42 | le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable) |
43 | : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable) | |
b75a7d8f | 44 | { |
73c04bcf A |
45 | fFeatureMap = featureMap; |
46 | fFeatureMapCount = featureMapCount; | |
b75a7d8f A |
47 | } |
48 | ||
49 | HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine() | |
50 | { | |
51 | // nothing to do | |
52 | } | |
53 | ||
b75a7d8f | 54 | le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/, |
374ca955 | 55 | LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
b75a7d8f A |
56 | { |
57 | if (LE_FAILURE(success)) { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { | |
62 | success = LE_ILLEGAL_ARGUMENT_ERROR; | |
63 | return 0; | |
64 | } | |
65 | ||
374ca955 A |
66 | glyphStorage.allocateGlyphArray(count, FALSE, success); |
67 | glyphStorage.allocateAuxData(success); | |
b75a7d8f | 68 | |
374ca955 | 69 | if (LE_FAILURE(success)) { |
b75a7d8f A |
70 | return 0; |
71 | } | |
72 | ||
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) { | |
73c04bcf | 78 | glyphStorage.setAuxData(i, features, success); |
b75a7d8f A |
79 | } |
80 | ||
81 | return count; | |
82 | } | |
374ca955 A |
83 | |
84 | U_NAMESPACE_END |