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/Features.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
*
29
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
30
*
31
*/
32
33
#include "LETypes.h"
34
#include "OpenTypeUtilities.h"
35
#include "OpenTypeTables.h"
36
#include "ICUFeatures.h"
37
#include "LESwaps.h"
38
39
U_NAMESPACE_BEGIN
40
41
LEReferenceTo<FeatureTable> FeatureListTable::getFeatureTable(const LETableReference &base, le_uint16 featureIndex, LETag *featureTag, LEErrorCode &success) const
42
{
43
LEReferenceToArrayOf<FeatureRecord>
44
featureRecordArrayRef(base, success, featureRecordArray, SWAPW(featureCount));
45
46
if (featureIndex >= SWAPW(featureCount) || LE_FAILURE(success)) {
47
success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
48
return LEReferenceTo<FeatureTable>();
49
}
50
51
Offset featureTableOffset = featureRecordArray[featureIndex].featureTableOffset;
52
53
*featureTag = SWAPT(featureRecordArray[featureIndex].featureTag);
54
55
return LEReferenceTo<FeatureTable>(base, success, SWAPW(featureTableOffset));
56
}
57
58
#if 0
59
/*
60
* Note: according to the OpenType Spec. v 1.4, the entries in the Feature
61
* List Table are sorted alphabetically by feature tag; however, there seem
62
* to be some fonts which have an unsorted list; that's why the binary search
63
* is #if 0'd out and replaced by a linear search.
64
*
65
* Also note: as of ICU 2.6, this method isn't called anyhow...
66
*/
67
const FeatureTable *FeatureListTable::getFeatureTable(LETag featureTag) const
68
{
69
#if 0
70
Offset featureTableOffset =
71
OpenTypeUtilities::getTagOffset(featureTag, (TagAndOffsetRecord *) featureRecordArray, SWAPW(featureCount));
72
73
if (featureTableOffset == 0) {
74
return 0;
75
}
76
77
return (const FeatureTable *) ((char *) this + SWAPW(featureTableOffset));
78
#else
79
int count = SWAPW(featureCount);
80
81
for (int i = 0; i < count; i += 1) {
82
if (SWAPT(featureRecordArray[i].featureTag) == featureTag) {
83
return (const FeatureTable *) ((char *) this + SWAPW(featureRecordArray[i].featureTableOffset));
84
}
85
}
86
87
return 0;
88
#endif
89
}
90
#endif
91
92
U_NAMESPACE_END
93
94