2
|
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. Sun designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
21 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
22 |
* have any questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
* HanLayoutEngine.cpp: OpenType processing for Han fonts.
|
|
29 |
*
|
|
30 |
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved.
|
|
31 |
*/
|
|
32 |
|
|
33 |
#include "LETypes.h"
|
|
34 |
#include "LEScripts.h"
|
|
35 |
#include "LELanguages.h"
|
|
36 |
|
|
37 |
#include "LayoutEngine.h"
|
|
38 |
#include "OpenTypeLayoutEngine.h"
|
|
39 |
#include "HanLayoutEngine.h"
|
|
40 |
#include "ScriptAndLanguageTags.h"
|
|
41 |
#include "LEGlyphStorage.h"
|
|
42 |
#include "OpenTypeTables.h"
|
|
43 |
|
|
44 |
#define loclFeatureTag LE_LOCL_FEATURE_TAG
|
|
45 |
#define smplFeatureTag LE_SMPL_FEATURE_TAG
|
|
46 |
#define tradFeatureTag LE_TRAD_FEATURE_TAG
|
|
47 |
|
|
48 |
#define loclFeatureMask 0x80000000UL
|
|
49 |
#define smplFeatureMask 0x40000000UL
|
|
50 |
#define tradFeatureMask 0x20000000UL
|
|
51 |
|
|
52 |
static const FeatureMap featureMap[] =
|
|
53 |
{
|
|
54 |
{loclFeatureTag, loclFeatureMask},
|
|
55 |
{smplFeatureTag, smplFeatureMask},
|
|
56 |
{tradFeatureTag, tradFeatureMask}
|
|
57 |
};
|
|
58 |
|
|
59 |
static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
|
|
60 |
|
|
61 |
#define features (loclFeatureMask)
|
|
62 |
|
|
63 |
HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
|
|
64 |
le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags,
|
|
65 |
const GlyphSubstitutionTableHeader *gsubTable)
|
|
66 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
|
|
67 |
{
|
|
68 |
fFeatureMap = featureMap;
|
|
69 |
fFeatureMapCount = featureMapCount;
|
|
70 |
}
|
|
71 |
|
|
72 |
HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
|
|
73 |
{
|
|
74 |
// nothing to do
|
|
75 |
}
|
|
76 |
|
|
77 |
le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[],
|
|
78 |
le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
|
|
79 |
LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
|
|
80 |
{
|
|
81 |
if (LE_FAILURE(success)) {
|
|
82 |
return 0;
|
|
83 |
}
|
|
84 |
|
|
85 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
|
86 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
87 |
return 0;
|
|
88 |
}
|
|
89 |
|
|
90 |
glyphStorage.allocateGlyphArray(count, FALSE, success);
|
|
91 |
glyphStorage.allocateAuxData(success);
|
|
92 |
|
|
93 |
if (LE_FAILURE(success)) {
|
|
94 |
return 0;
|
|
95 |
}
|
|
96 |
|
|
97 |
// FIXME: do we want to add the 'trad' feature for 'ZHT' and the
|
|
98 |
// 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
|
|
99 |
// flag from the language tag lookups, so we can use these features
|
|
100 |
// with the default LangSys...
|
|
101 |
for (le_int32 i = 0; i < count; i += 1) {
|
|
102 |
glyphStorage.setAuxData(i, features, success);
|
|
103 |
}
|
|
104 |
|
|
105 |
return count;
|
|
106 |
}
|