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/DelegateStrike.java
32287 views
1
/*
2
* Copyright (c) 2003, 2012, 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.geom.GeneralPath;
29
import java.awt.geom.Point2D;
30
import java.awt.Rectangle;
31
import java.awt.geom.Rectangle2D;
32
33
/* Returned instead of a NativeStrike.
34
* It can intercept any request it wants, but mostly
35
* passes them on to its delegate strike. It is important that
36
* it override all the inherited FontStrike methods to delegate them
37
* appropriately.
38
*/
39
40
class DelegateStrike extends NativeStrike {
41
42
private FontStrike delegateStrike;
43
44
DelegateStrike(NativeFont nativeFont, FontStrikeDesc desc,
45
FontStrike delegate) {
46
super(nativeFont, desc);
47
this.delegateStrike = delegate;
48
}
49
50
/* We want the native font to be responsible for reporting the
51
* font metrics, even if it often delegates to another font.
52
* The code here isn't yet implementing exactly that. If the glyph
53
* transform was something native couldn't handle, there's no native
54
* context from which to obtain metrics. Need to revise this to obtain
55
* the metrics and transform them. But currently in such a case it
56
* gets the metrics from a different font - its glyph delegate font.
57
*/
58
StrikeMetrics getFontMetrics() {
59
if (strikeMetrics == null) {
60
if (pScalerContext != 0) {
61
strikeMetrics = super.getFontMetrics();
62
}
63
if (strikeMetrics == null) {
64
strikeMetrics = delegateStrike.getFontMetrics();
65
}
66
}
67
return strikeMetrics;
68
}
69
70
void getGlyphImagePtrs(int[] glyphCodes, long[] images,int len) {
71
delegateStrike.getGlyphImagePtrs(glyphCodes, images, len);
72
}
73
74
long getGlyphImagePtr(int glyphCode) {
75
return delegateStrike.getGlyphImagePtr(glyphCode);
76
}
77
78
void getGlyphImageBounds(int glyphCode,
79
Point2D.Float pt, Rectangle result) {
80
delegateStrike.getGlyphImageBounds(glyphCode, pt, result);
81
}
82
83
Point2D.Float getGlyphMetrics(int glyphCode) {
84
return delegateStrike.getGlyphMetrics(glyphCode);
85
}
86
87
float getGlyphAdvance(int glyphCode) {
88
return delegateStrike.getGlyphAdvance(glyphCode);
89
}
90
91
Point2D.Float getCharMetrics(char ch) {
92
return delegateStrike.getCharMetrics(ch);
93
}
94
95
float getCodePointAdvance(int cp) {
96
if (cp < 0 || cp >= 0x10000) {
97
cp = 0xffff;
98
}
99
return delegateStrike.getGlyphAdvance(cp);
100
}
101
102
Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
103
return delegateStrike.getGlyphOutlineBounds(glyphCode);
104
}
105
106
GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
107
return delegateStrike.getGlyphOutline(glyphCode, x, y);
108
}
109
110
GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {
111
return delegateStrike.getGlyphVectorOutline(glyphs, x, y);
112
}
113
114
}
115
116