Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/ClassDefinitionTables.cpp
38918 views
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. Oracle designates this
7
* particular file as subject to the "Classpath" exception as provided
8
* by Oracle 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 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.
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
38
U_NAMESPACE_BEGIN
39
40
le_int32 ClassDefinitionTable::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
41
{
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
71
switch(SWAPW(classFormat)) {
72
case 0:
73
return 0;
74
75
case 1:
76
{
77
const LEReferenceTo<ClassDefFormat1Table> f1Table(thisRef, success);
78
return f1Table->hasGlyphClass(f1Table, glyphClass, success);
79
}
80
81
case 2:
82
{
83
const LEReferenceTo<ClassDefFormat2Table> f2Table(thisRef, success);
84
return f2Table->hasGlyphClass(f2Table, glyphClass, success);
85
}
86
87
default:
88
return 0;
89
}
90
}
91
92
le_int32 ClassDefFormat1Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
93
{
94
if(LE_FAILURE(success)) return 0;
95
96
le_uint16 count = SWAPW(glyphCount);
97
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
98
TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
99
TTGlyphID firstGlyph = SWAPW(startGlyph);
100
TTGlyphID lastGlyph = firstGlyph + count;
101
102
if (LE_SUCCESS(success) && ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) {
103
return SWAPW( classValueArrayRef(ttGlyphID - firstGlyph, success) );
104
}
105
106
return 0;
107
}
108
109
le_bool ClassDefFormat1Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
110
{
111
if(LE_FAILURE(success)) return 0;
112
le_uint16 count = SWAPW(glyphCount);
113
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
114
int i;
115
116
for (i = 0; LE_SUCCESS(success)&& (i < count); i += 1) {
117
if (SWAPW(classValueArrayRef(i,success)) == glyphClass) {
118
return TRUE;
119
}
120
}
121
122
return FALSE;
123
}
124
125
le_int32 ClassDefFormat2Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
126
{
127
if(LE_FAILURE(success)) return 0;
128
TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphID);
129
le_uint16 rangeCount = SWAPW(classRangeCount);
130
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
131
le_int32 rangeIndex =
132
OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArrayRef, success);
133
134
if (rangeIndex < 0 || LE_FAILURE(success)) {
135
return 0;
136
}
137
138
return SWAPW(classRangeRecordArrayRef(rangeIndex, success).rangeValue);
139
}
140
141
le_bool ClassDefFormat2Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
142
{
143
if(LE_FAILURE(success)) return 0;
144
le_uint16 rangeCount = SWAPW(classRangeCount);
145
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
146
int i;
147
148
for (i = 0; i < rangeCount && LE_SUCCESS(success); i += 1) {
149
if (SWAPW(classRangeRecordArrayRef(i,success).rangeValue) == glyphClass) {
150
return TRUE;
151
}
152
}
153
154
return FALSE;
155
}
156
157
U_NAMESPACE_END
158
159