1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 * |
|
4 * This code is free software; you can redistribute it and/or modify it |
|
5 * under the terms of the GNU General Public License version 2 only, as |
|
6 * published by the Free Software Foundation. Oracle designates this |
|
7 * particular file as subject to the "Classpath" exception as provided |
|
8 * by Oracle in the LICENSE file that accompanied this code. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 * |
|
24 */ |
|
25 |
|
26 /* |
|
27 * HanLayoutEngine.cpp: OpenType processing for Han fonts. |
|
28 * |
|
29 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved. |
|
30 */ |
|
31 |
|
32 #include "LETypes.h" |
|
33 #include "LEScripts.h" |
|
34 #include "LELanguages.h" |
|
35 |
|
36 #include "LayoutEngine.h" |
|
37 #include "OpenTypeLayoutEngine.h" |
|
38 #include "HanLayoutEngine.h" |
|
39 #include "ScriptAndLanguageTags.h" |
|
40 #include "LEGlyphStorage.h" |
|
41 #include "OpenTypeTables.h" |
|
42 |
|
43 U_NAMESPACE_BEGIN |
|
44 |
|
45 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine) |
|
46 |
|
47 #define loclFeatureTag LE_LOCL_FEATURE_TAG |
|
48 #define smplFeatureTag LE_SMPL_FEATURE_TAG |
|
49 #define tradFeatureTag LE_TRAD_FEATURE_TAG |
|
50 |
|
51 #define loclFeatureMask 0x80000000UL |
|
52 #define smplFeatureMask 0x40000000UL |
|
53 #define tradFeatureMask 0x20000000UL |
|
54 |
|
55 static const FeatureMap featureMap[] = |
|
56 { |
|
57 {loclFeatureTag, loclFeatureMask}, |
|
58 {smplFeatureTag, smplFeatureMask}, |
|
59 {tradFeatureTag, tradFeatureMask} |
|
60 }; |
|
61 |
|
62 static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap); |
|
63 |
|
64 #define features (loclFeatureMask) |
|
65 |
|
66 HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, |
|
67 le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success) |
|
68 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success) |
|
69 { |
|
70 fFeatureMap = featureMap; |
|
71 fFeatureMapCount = featureMapCount; |
|
72 } |
|
73 |
|
74 HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine() |
|
75 { |
|
76 // nothing to do |
|
77 } |
|
78 |
|
79 le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/, |
|
80 LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
|
81 { |
|
82 if (LE_FAILURE(success)) { |
|
83 return 0; |
|
84 } |
|
85 |
|
86 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { |
|
87 success = LE_ILLEGAL_ARGUMENT_ERROR; |
|
88 return 0; |
|
89 } |
|
90 |
|
91 glyphStorage.allocateGlyphArray(count, FALSE, success); |
|
92 glyphStorage.allocateAuxData(success); |
|
93 |
|
94 if (LE_FAILURE(success)) { |
|
95 return 0; |
|
96 } |
|
97 |
|
98 // FIXME: do we want to add the 'trad' feature for 'ZHT' and the |
|
99 // 'smpl' feature for 'ZHS'? If we do this, we can remove the exact |
|
100 // flag from the language tag lookups, so we can use these features |
|
101 // with the default LangSys... |
|
102 for (le_int32 i = 0; i < count; i += 1) { |
|
103 glyphStorage.setAuxData(i, features, success); |
|
104 } |
|
105 |
|
106 return count; |
|
107 } |
|
108 |
|
109 U_NAMESPACE_END |
|