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
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
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 |
*
|
5506
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
2
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
|
|
32 |
#include "LETypes.h"
|
|
33 |
#include "OpenTypeTables.h"
|
|
34 |
#include "OpenTypeUtilities.h"
|
|
35 |
#include "ClassDefinitionTables.h"
|
|
36 |
#include "LESwaps.h"
|
|
37 |
|
3935
|
38 |
U_NAMESPACE_BEGIN
|
|
39 |
|
16891
|
40 |
le_int32 ClassDefinitionTable::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2
|
41 |
{
|
16891
|
42 |
LEReferenceTo<ClassDefinitionTable> thisRef(base, success);
|
|
43 |
if (LE_FAILURE(success)) return 0;
|
|
44 |
|
|
45 |
switch(SWAPW(classFormat)) {
|
|
46 |
case 0:
|
|
47 |
return 0;
|
|
48 |
|
|
49 |
case 1:
|
|
50 |
{
|
|
51 |
const LEReferenceTo<ClassDefFormat1Table> f1Table(thisRef, success);
|
|
52 |
return f1Table->getGlyphClass(f1Table, glyphID, success);
|
|
53 |
}
|
|
54 |
|
|
55 |
case 2:
|
|
56 |
{
|
|
57 |
const LEReferenceTo<ClassDefFormat2Table> f2Table(thisRef, success);
|
|
58 |
return f2Table->getGlyphClass(f2Table, glyphID, success);
|
|
59 |
}
|
|
60 |
|
|
61 |
default:
|
|
62 |
return 0;
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
le_bool ClassDefinitionTable::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
|
67 |
{
|
|
68 |
LEReferenceTo<ClassDefinitionTable> thisRef(base, success);
|
|
69 |
if (LE_FAILURE(success)) return 0;
|
|
70 |
|
2
|
71 |
switch(SWAPW(classFormat)) {
|
|
72 |
case 0:
|
|
73 |
return 0;
|
|
74 |
|
|
75 |
case 1:
|
|
76 |
{
|
16891
|
77 |
const LEReferenceTo<ClassDefFormat1Table> f1Table(thisRef, success);
|
|
78 |
return f1Table->hasGlyphClass(f1Table, glyphClass, success);
|
2
|
79 |
}
|
|
80 |
|
|
81 |
case 2:
|
|
82 |
{
|
16891
|
83 |
const LEReferenceTo<ClassDefFormat2Table> f2Table(thisRef, success);
|
|
84 |
return f2Table->hasGlyphClass(f2Table, glyphClass, success);
|
2
|
85 |
}
|
|
86 |
|
|
87 |
default:
|
|
88 |
return 0;
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
16891
|
92 |
le_int32 ClassDefFormat1Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2
|
93 |
{
|
16891
|
94 |
if(LE_FAILURE(success)) return 0;
|
2
|
95 |
|
16891
|
96 |
le_uint16 count = SWAPW(glyphCount);
|
|
97 |
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
|
2
|
98 |
TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
|
|
99 |
TTGlyphID firstGlyph = SWAPW(startGlyph);
|
16891
|
100 |
TTGlyphID lastGlyph = firstGlyph + count;
|
2
|
101 |
|
16891
|
102 |
if (LE_SUCCESS(success) && ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) {
|
|
103 |
return SWAPW( classValueArrayRef(ttGlyphID - firstGlyph, success) );
|
2
|
104 |
}
|
|
105 |
|
|
106 |
return 0;
|
|
107 |
}
|
|
108 |
|
16891
|
109 |
le_bool ClassDefFormat1Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
2
|
110 |
{
|
16891
|
111 |
if(LE_FAILURE(success)) return 0;
|
|
112 |
le_uint16 count = SWAPW(glyphCount);
|
|
113 |
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
|
2
|
114 |
int i;
|
|
115 |
|
16891
|
116 |
for (i = 0; LE_SUCCESS(success)&& (i < count); i += 1) {
|
|
117 |
if (SWAPW(classValueArrayRef(i,success)) == glyphClass) {
|
2
|
118 |
return TRUE;
|
|
119 |
}
|
|
120 |
}
|
|
121 |
|
|
122 |
return FALSE;
|
|
123 |
}
|
|
124 |
|
16891
|
125 |
le_int32 ClassDefFormat2Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2
|
126 |
{
|
16891
|
127 |
if(LE_FAILURE(success)) return 0;
|
2
|
128 |
TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphID);
|
|
129 |
le_uint16 rangeCount = SWAPW(classRangeCount);
|
16891
|
130 |
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
|
2
|
131 |
le_int32 rangeIndex =
|
16891
|
132 |
OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArrayRef, success);
|
2
|
133 |
|
16891
|
134 |
if (rangeIndex < 0 || LE_FAILURE(success)) {
|
2
|
135 |
return 0;
|
|
136 |
}
|
|
137 |
|
16891
|
138 |
return SWAPW(classRangeRecordArrayRef(rangeIndex, success).rangeValue);
|
2
|
139 |
}
|
|
140 |
|
16891
|
141 |
le_bool ClassDefFormat2Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
2
|
142 |
{
|
16891
|
143 |
if(LE_FAILURE(success)) return 0;
|
2
|
144 |
le_uint16 rangeCount = SWAPW(classRangeCount);
|
16891
|
145 |
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
|
2
|
146 |
int i;
|
|
147 |
|
16891
|
148 |
for (i = 0; i < rangeCount && LE_SUCCESS(success); i += 1) {
|
|
149 |
if (SWAPW(classRangeRecordArrayRef(i,success).rangeValue) == glyphClass) {
|
2
|
150 |
return TRUE;
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
return FALSE;
|
|
155 |
}
|
3935
|
156 |
|
|
157 |
U_NAMESPACE_END
|