os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEFontInstance.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LEFontInstance.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,85 @@
     1.4 +/*
     1.5 + *******************************************************************************
     1.6 + *
     1.7 + *   Copyright (C) 1999-2004, International Business Machines
     1.8 + *   Corporation and others.  All Rights Reserved.
     1.9 + *
    1.10 + *******************************************************************************
    1.11 + *   file name:  LEFontInstance.cpp
    1.12 + *
    1.13 + *   created on: 02/06/2003
    1.14 + *   created by: Eric R. Mader
    1.15 + */
    1.16 +
    1.17 +#include "LETypes.h"
    1.18 +#include "LEScripts.h"
    1.19 +#include "LEFontInstance.h"
    1.20 +#include "LEGlyphStorage.h"
    1.21 +
    1.22 +U_NAMESPACE_BEGIN
    1.23 +
    1.24 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEFontInstance)
    1.25 +
    1.26 +const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit,
    1.27 +                                                       le_int32 script, LEErrorCode &success) const
    1.28 +{
    1.29 +    if (LE_FAILURE(success)) {
    1.30 +        return NULL;
    1.31 +    }
    1.32 +
    1.33 +    if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) {
    1.34 +        success = LE_ILLEGAL_ARGUMENT_ERROR;
    1.35 +        return NULL;
    1.36 +    }
    1.37 +
    1.38 +    *offset = limit;
    1.39 +    return this;
    1.40 +}
    1.41 +
    1.42 +void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
    1.43 +                                      le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
    1.44 +{
    1.45 +    le_int32 i, out = 0, dir = 1;
    1.46 +
    1.47 +    if (reverse) {
    1.48 +        out = count - 1;
    1.49 +        dir = -1;
    1.50 +    }
    1.51 +
    1.52 +    for (i = offset; i < offset + count; i += 1, out += dir) {
    1.53 +        LEUnicode16 high = chars[i];
    1.54 +        LEUnicode32 code = high;
    1.55 +
    1.56 +        if (i < offset + count - 1 && high >= 0xD800 && high <= 0xDBFF) {
    1.57 +            LEUnicode16 low = chars[i + 1];
    1.58 +
    1.59 +            if (low >= 0xDC00 && low <= 0xDFFF) {
    1.60 +                code = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
    1.61 +            }
    1.62 +        }
    1.63 +
    1.64 +        glyphStorage[out] = mapCharToGlyph(code, mapper);
    1.65 +
    1.66 +        if (code >= 0x10000) {
    1.67 +            i += 1;
    1.68 +            glyphStorage[out += dir] = 0xFFFF;
    1.69 +        }
    1.70 +    }
    1.71 +}
    1.72 +
    1.73 +LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
    1.74 +{
    1.75 +    LEUnicode32 mappedChar = mapper->mapChar(ch);
    1.76 +
    1.77 +    if (mappedChar == 0xFFFE || mappedChar == 0xFFFF) {
    1.78 +        return 0xFFFF;
    1.79 +    }
    1.80 +
    1.81 +    if (mappedChar == 0x200C/* || mappedChar == 0x200D*/) { //1922 mlyl --> commented 200D for chillu -->
    1.82 +        return 1;
    1.83 +    }
    1.84 +
    1.85 +    return mapCharToGlyph(mappedChar);
    1.86 +}
    1.87 +U_NAMESPACE_END
    1.88 +