os/textandloc/fontservices/textshaperplugin/IcuSource/layout/HanLayoutEngine.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 * HanLayoutEngine.cpp: OpenType processing for Han fonts.
sl@0
     3
 *
sl@0
     4
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved.
sl@0
     5
 */
sl@0
     6
sl@0
     7
#include "LETypes.h"
sl@0
     8
#include "LEScripts.h"
sl@0
     9
#include "LELanguages.h"
sl@0
    10
sl@0
    11
#include "LayoutEngine.h"
sl@0
    12
#include "OpenTypeLayoutEngine.h"
sl@0
    13
#include "HanLayoutEngine.h"
sl@0
    14
#include "ScriptAndLanguageTags.h"
sl@0
    15
#include "LEGlyphStorage.h"
sl@0
    16
sl@0
    17
U_NAMESPACE_BEGIN
sl@0
    18
sl@0
    19
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(HanOpenTypeLayoutEngine)
sl@0
    20
sl@0
    21
HanOpenTypeLayoutEngine::HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0
    22
                        le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
sl@0
    23
    : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
sl@0
    24
{
sl@0
    25
    // nothing else to do...
sl@0
    26
}
sl@0
    27
sl@0
    28
HanOpenTypeLayoutEngine::~HanOpenTypeLayoutEngine()
sl@0
    29
{
sl@0
    30
    // nothing to do
sl@0
    31
}
sl@0
    32
sl@0
    33
static const LETag emptyTag = 0x00000000;
sl@0
    34
sl@0
    35
static const LETag loclFeatureTag = LE_LOCL_FEATURE_TAG;
sl@0
    36
static const LETag smplFeatureTag = LE_SMPL_FEATURE_TAG;
sl@0
    37
static const LETag tradFeatureTag = LE_TRAD_FEATURE_TAG;
sl@0
    38
sl@0
    39
static const LETag features[] = {loclFeatureTag, emptyTag};
sl@0
    40
sl@0
    41
le_int32 HanOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/,
sl@0
    42
        LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
sl@0
    43
{
sl@0
    44
    if (LE_FAILURE(success)) {
sl@0
    45
        return 0;
sl@0
    46
    }
sl@0
    47
sl@0
    48
    if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
sl@0
    49
        success = LE_ILLEGAL_ARGUMENT_ERROR;
sl@0
    50
        return 0;
sl@0
    51
    }
sl@0
    52
sl@0
    53
    glyphStorage.allocateGlyphArray(count, FALSE, success);
sl@0
    54
    glyphStorage.allocateAuxData(success);
sl@0
    55
sl@0
    56
    if (LE_FAILURE(success)) {
sl@0
    57
        return 0;
sl@0
    58
    }
sl@0
    59
sl@0
    60
    // FIXME: do we want to add the 'trad' feature for 'ZHT' and the
sl@0
    61
    // 'smpl' feature for 'ZHS'? If we do this, we can remove the exact
sl@0
    62
    // flag from the language tag lookups, so we can use these features
sl@0
    63
    // with the default LangSys...
sl@0
    64
    for (le_int32 i = 0; i < count; i += 1) {
sl@0
    65
        glyphStorage.setAuxData(i, (void *) features, success);
sl@0
    66
    }
sl@0
    67
sl@0
    68
    return count;
sl@0
    69
}
sl@0
    70
sl@0
    71
U_NAMESPACE_END