2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Sun designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Sun in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
21 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
22 |
* have any questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
*******************************************************************************
|
|
29 |
*
|
|
30 |
* Copyright (C) 1999-2005, International Business Machines
|
|
31 |
* Corporation and others. All Rights Reserved.
|
|
32 |
*
|
|
33 |
*******************************************************************************
|
|
34 |
* file name: LEFontInstance.cpp
|
|
35 |
*
|
|
36 |
* created on: 02/06/2003
|
|
37 |
* created by: Eric R. Mader
|
|
38 |
*/
|
|
39 |
|
|
40 |
#include "LETypes.h"
|
|
41 |
#include "LEScripts.h"
|
|
42 |
#include "LEFontInstance.h"
|
|
43 |
#include "LEGlyphStorage.h"
|
|
44 |
|
|
45 |
const LEFontInstance *LEFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit,
|
|
46 |
le_int32 script, LEErrorCode &success) const
|
|
47 |
{
|
|
48 |
if (LE_FAILURE(success)) {
|
|
49 |
return NULL;
|
|
50 |
}
|
|
51 |
|
|
52 |
if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) {
|
|
53 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
54 |
return NULL;
|
|
55 |
}
|
|
56 |
|
|
57 |
*offset = limit;
|
|
58 |
return this;
|
|
59 |
}
|
|
60 |
|
|
61 |
void LEFontInstance::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count,
|
|
62 |
le_bool reverse, const LECharMapper *mapper, LEGlyphStorage &glyphStorage) const
|
|
63 |
{
|
|
64 |
le_int32 i, out = 0, dir = 1;
|
|
65 |
|
|
66 |
if (reverse) {
|
|
67 |
out = count - 1;
|
|
68 |
dir = -1;
|
|
69 |
}
|
|
70 |
|
|
71 |
for (i = offset; i < offset + count; i += 1, out += dir) {
|
|
72 |
LEUnicode16 high = chars[i];
|
|
73 |
LEUnicode32 code = high;
|
|
74 |
|
|
75 |
if (i < offset + count - 1 && high >= 0xD800 && high <= 0xDBFF) {
|
|
76 |
LEUnicode16 low = chars[i + 1];
|
|
77 |
|
|
78 |
if (low >= 0xDC00 && low <= 0xDFFF) {
|
|
79 |
code = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
|
|
80 |
}
|
|
81 |
}
|
|
82 |
|
|
83 |
glyphStorage[out] = mapCharToGlyph(code, mapper);
|
|
84 |
|
|
85 |
if (code >= 0x10000) {
|
|
86 |
i += 1;
|
|
87 |
glyphStorage[out += dir] = 0xFFFF;
|
|
88 |
}
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
LEGlyphID LEFontInstance::mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const
|
|
93 |
{
|
|
94 |
LEUnicode32 mappedChar = mapper->mapChar(ch);
|
|
95 |
|
|
96 |
if (mappedChar == 0xFFFE || mappedChar == 0xFFFF ||
|
|
97 |
mappedChar == 0x200C || mappedChar == 0x200D) {
|
|
98 |
return 0xFFFF;
|
|
99 |
}
|
|
100 |
|
|
101 |
return mapCharToGlyph(mappedChar);
|
|
102 |
}
|