|
1 /* |
|
2 ******************************************************************************* |
|
3 * |
|
4 * Copyright (C) 1999-2004, International Business Machines |
|
5 * Corporation and others. All Rights Reserved. |
|
6 * |
|
7 ******************************************************************************* |
|
8 * file name: LEFontInstance.cpp |
|
9 * |
|
10 * created on: 02/06/2003 |
|
11 * created by: Eric R. Mader |
|
12 */ |
|
13 |
|
14 #include "LETypes.h" |
|
15 #include "LEScripts.h" |
|
16 #include "LEFontInstance.h" |
|
17 #include "LEGlyphStorage.h" |
|
18 |
|
19 U_NAMESPACE_BEGIN |
|
20 |
|
21 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(LEFontInstance) |
|
22 |
|
23 const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, |
|
24 le_int32 script, LEErrorCode &success) const |
|
25 { |
|
26 if (LE_FAILURE(success)) { |
|
27 return NULL; |
|
28 } |
|
29 |
|
30 if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) { |
|
31 success = LE_ILLEGAL_ARGUMENT_ERROR; |
|
32 return NULL; |
|
33 } |
|
34 |
|
35 *offset = limit; |
|
36 return this; |
|
37 } |
|
38 |
|
39 void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, |
|
40 le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const |
|
41 { |
|
42 le_int32 i, out = 0, dir = 1; |
|
43 |
|
44 if (reverse) { |
|
45 out = count - 1; |
|
46 dir = -1; |
|
47 } |
|
48 |
|
49 for (i = offset; i < offset + count; i += 1, out += dir) { |
|
50 LEUnicode16 high = chars[i]; |
|
51 LEUnicode32 code = high; |
|
52 |
|
53 if (i < offset + count - 1 && high >= 0xD800 && high <= 0xDBFF) { |
|
54 LEUnicode16 low = chars[i + 1]; |
|
55 |
|
56 if (low >= 0xDC00 && low <= 0xDFFF) { |
|
57 code = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000; |
|
58 } |
|
59 } |
|
60 |
|
61 glyphStorage[out] = mapCharToGlyph(code, mapper); |
|
62 |
|
63 if (code >= 0x10000) { |
|
64 i += 1; |
|
65 glyphStorage[out += dir] = 0xFFFF; |
|
66 } |
|
67 } |
|
68 } |
|
69 |
|
70 LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const |
|
71 { |
|
72 LEUnicode32 mappedChar = mapper->mapChar(ch); |
|
73 |
|
74 if (mappedChar == 0xFFFE || mappedChar == 0xFFFF) { |
|
75 return 0xFFFF; |
|
76 } |
|
77 |
|
78 if (mappedChar == 0x200C/* || mappedChar == 0x200D*/) { //1922 mlyl --> commented 200D for chillu --> |
|
79 return 1; |
|
80 } |
|
81 |
|
82 return mapCharToGlyph(mappedChar); |
|
83 } |
|
84 U_NAMESPACE_END |
|
85 |