Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/font/NativeGlyphMapper.java
32287 views
1
/*
2
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.font;
27
28
import java.awt.FontFormatException;
29
import java.awt.font.FontRenderContext;
30
import java.awt.geom.GeneralPath;
31
import java.awt.geom.Rectangle2D;
32
import java.util.HashMap;
33
import java.util.Locale;
34
35
/*
36
* This needs work to distinguish between XMap's translation from unicode
37
* to the encoding used to access the X font, and whether a particular
38
* code point is in the font.
39
* ie a GlyphMapper ought to be able to say if a code point maps to a glyph
40
* IN THIS FONT, not just in this encoding.
41
* Because of the current lack of distinction the NativeGlyphMapper and
42
* XMap classes could be merged, however its cleaner to make them separate
43
* classes so we can build caches for a particular font.
44
*/
45
public class NativeGlyphMapper extends CharToGlyphMapper {
46
47
NativeFont font;
48
XMap xmapper;
49
int numGlyphs;
50
51
NativeGlyphMapper(NativeFont f) {
52
font = f;
53
xmapper = XMap.getXMapper(font.encoding);
54
numGlyphs = f.getNumGlyphs();
55
missingGlyph = 0;
56
}
57
58
public int getNumGlyphs() {
59
return numGlyphs;
60
}
61
62
public int charToGlyph(char unicode) {
63
if (unicode >= xmapper.convertedGlyphs.length) {
64
return 0;
65
} else {
66
return xmapper.convertedGlyphs[unicode];
67
}
68
}
69
70
public int charToGlyph(int unicode) {
71
if (unicode >= xmapper.convertedGlyphs.length) {
72
return 0;
73
} else {
74
return xmapper.convertedGlyphs[unicode];
75
}
76
}
77
78
public void charsToGlyphs(int count, char[] unicodes, int[] glyphs) {
79
for (int i=0; i<count; i++) {
80
char code = unicodes[i];
81
if (code >= xmapper.convertedGlyphs.length) {
82
glyphs[i] = 0;
83
} else {
84
glyphs[i] = xmapper.convertedGlyphs[code];
85
}
86
}
87
}
88
89
public boolean charsToGlyphsNS(int count, char[] unicodes, int[] glyphs) {
90
charsToGlyphs(count, unicodes, glyphs);
91
return false;
92
}
93
94
public void charsToGlyphs(int count, int[] unicodes, int[] glyphs) {
95
for (int i=0; i<count; i++) {
96
char code = (char)unicodes[i];
97
if (code >= xmapper.convertedGlyphs.length) {
98
glyphs[i] = 0;
99
} else {
100
glyphs[i] = xmapper.convertedGlyphs[code];
101
}
102
}
103
}
104
105
}
106
107