1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/HanLayoutEngine.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,71 @@
1.4 +/*
1.5 + * HanLayoutEngine.cpp: OpenType processing for Han fonts.
1.6 + *
1.7 + * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved.
1.8 + */
1.9 +
1.10 +#include "LETypes.h"
1.11 +#include "LEScripts.h"
1.12 +#include "LELanguages.h"
1.13 +
1.14 +#include "LayoutEngine.h"
1.15 +#include "OpenTypeLayoutEngine.h"
1.16 +#include "HanLayoutEngine.h"
1.17 +#include "ScriptAndLanguageTags.h"
1.18 +#include "LEGlyphStorage.h"
1.19 +
1.20 +U_NAMESPACE_BEGIN
1.21 +
1.22 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
1.23 +
1.24 +HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
1.25 + le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
1.26 + : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
1.27 +{
1.28 + // nothing else to do...
1.29 +}
1.30 +
1.31 +HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
1.32 +{
1.33 + // nothing to do
1.34 +}
1.35 +
1.36 +static const LETag emptyTag = 0x00000000;
1.37 +
1.38 +static const LETag loclFeatureTag = LE_LOCL_FEATURE_TAG;
1.39 +static const LETag smplFeatureTag = LE_SMPL_FEATURE_TAG;
1.40 +static const LETag tradFeatureTag = LE_TRAD_FEATURE_TAG;
1.41 +
1.42 +static const LETag features[] = {loclFeatureTag, emptyTag};
1.43 +
1.44 +le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
1.45 + LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
1.46 +{
1.47 + if (LE_FAILURE(success)) {
1.48 + return 0;
1.49 + }
1.50 +
1.51 + if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
1.52 + success = LE_ILLEGAL_ARGUMENT_ERROR;
1.53 + return 0;
1.54 + }
1.55 +
1.56 + glyphStorage.allocateGlyphArray(count, FALSE, success);
1.57 + glyphStorage.allocateAuxData(success);
1.58 +
1.59 + if (LE_FAILURE(success)) {
1.60 + return 0;
1.61 + }
1.62 +
1.63 + // FIXME: do we want to add the 'trad' feature for 'ZHT' and the
1.64 + // 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
1.65 + // flag from the language tag lookups, so we can use these features
1.66 + // with the default LangSys...
1.67 + for (le_int32 i = 0; i < count; i += 1) {
1.68 + glyphStorage.setAuxData(i, (void *) features, success);
1.69 + }
1.70 +
1.71 + return count;
1.72 +}
1.73 +
1.74 +U_NAMESPACE_END