First public contribution.
2 *******************************************************************************
4 * Copyright (C) 1999-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: LEFontInstance.cpp
10 * created on: 02/06/2003
11 * created by: Eric R. Mader
15 #include "LEScripts.h"
16 #include "LEFontInstance.h"
17 #include "LEGlyphStorage.h"
21 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEFontInstance)
23 const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit,
24 le_int32 script, LEErrorCode &success) const
26 if (LE_FAILURE(success)) {
30 if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) {
31 success = LE_ILLEGAL_ARGUMENT_ERROR;
39 void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
40 le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
42 le_int32 i, out = 0, dir = 1;
49 for (i = offset; i < offset + count; i += 1, out += dir) {
50 LEUnicode16 high = chars[i];
51 LEUnicode32 code = high;
53 if (i < offset + count - 1 && high >= 0xD800 && high <= 0xDBFF) {
54 LEUnicode16 low = chars[i + 1];
56 if (low >= 0xDC00 && low <= 0xDFFF) {
57 code = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
61 glyphStorage[out] = mapCharToGlyph(code, mapper);
63 if (code >= 0x10000) {
65 glyphStorage[out += dir] = 0xFFFF;
70 LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
72 LEUnicode32 mappedChar = mapper->mapChar(ch);
74 if (mappedChar == 0xFFFE || mappedChar == 0xFFFF) {
78 if (mappedChar == 0x200C/* || mappedChar == 0x200D*/) { //1922 mlyl --> commented 200D for chillu -->
82 return mapCharToGlyph(mappedChar);