]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/HanLayoutEngine.cpp
ICU-6.2.4.tar.gz
[apple/icu.git] / icuSources / layout / HanLayoutEngine.cpp
1 /*
2 * HanLayoutEngine.cpp: OpenType processing for Han fonts.
3 *
4 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved.
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"
15 #include "LEGlyphStorage.h"
16
17 U_NAMESPACE_BEGIN
18
19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
20
21 HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
22 const GlyphSubstitutionTableHeader *gsubTable)
23 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable)
24 {
25 // nothing else to do...
26 }
27
28 HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
29 {
30 // nothing to do
31 }
32
33 static const LETag emptyTag = 0x00000000;
34
35 static const LETag loclFeatureTag = LE_LOCL_FEATURE_TAG;
36 static const LETag smplFeatureTag = LE_SMPL_FEATURE_TAG;
37 static const LETag tradFeatureTag = LE_TRAD_FEATURE_TAG;
38
39 static const LETag features[] = {loclFeatureTag, emptyTag};
40
41 le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
42 LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
43 {
44 if (LE_FAILURE(success)) {
45 return 0;
46 }
47
48 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
49 success = LE_ILLEGAL_ARGUMENT_ERROR;
50 return 0;
51 }
52
53 glyphStorage.allocateGlyphArray(count, FALSE, success);
54 glyphStorage.allocateAuxData(success);
55
56 if (LE_FAILURE(success)) {
57 return 0;
58 }
59
60 // FIXME: do we want to add the 'trad' feature for 'ZHT' and the
61 // 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
62 // flag from the language tag lookups, so we can use these features
63 // with the default LangSys...
64 for (le_int32 i = 0; i < count; i += 1) {
65 glyphStorage.setAuxData(i, (void *) features, success);
66 }
67
68 return count;
69 }
70
71 U_NAMESPACE_END