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/FontInstanceAdapter.h
38829 views
1
/*
2
* Copyright (c) 1999, 2013, 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
27
/*
28
* (C) Copyright IBM Corp. 1998-2001 - All Rights Reserved
29
*
30
* The original version of this source code and documentation is
31
* copyrighted and owned by IBM. These materials are provided
32
* under terms of a License Agreement between IBM and Sun.
33
* This technology is protected by multiple US and International
34
* patents. This notice and attribution to IBM may not be removed.
35
*/
36
37
#ifndef __FONTINSTANCEADAPTER_H
38
#define __FONTINSTANCEADAPTER_H
39
40
#include "LETypes.h"
41
#include "LEFontInstance.h"
42
#include "jni.h"
43
#include "sunfontids.h"
44
#include "fontscalerdefs.h"
45
#include <jni_util.h>
46
47
U_NAMESPACE_BEGIN
48
49
class FontInstanceAdapter : public LEFontInstance {
50
private:
51
JNIEnv *env;
52
jobject font2D;
53
jobject fontStrike;
54
55
float xppem;
56
float yppem;
57
58
float xScaleUnitsToPoints;
59
float yScaleUnitsToPoints;
60
61
float xScalePixelsToUnits;
62
float yScalePixelsToUnits;
63
64
le_int32 upem;
65
float xPointSize, yPointSize;
66
float txMat[4];
67
68
float euclidianDistance(float a, float b);
69
70
/* Table format is the same as defined in the truetype spec.
71
Pointer can be NULL (e.g. for Type1 fonts). */
72
TTLayoutTableCache* layoutTables;
73
74
public:
75
FontInstanceAdapter(JNIEnv *env,
76
jobject theFont2D, jobject theFontStrike,
77
float *matrix, le_int32 xRes, le_int32 yRes,
78
le_int32 theUPEM, TTLayoutTableCache *ltables);
79
80
virtual ~FontInstanceAdapter() { };
81
82
virtual const LEFontInstance *getSubFont(const LEUnicode chars[],
83
le_int32 *offset, le_int32 limit,
84
le_int32 script, LEErrorCode &success) const {
85
return this;
86
}
87
88
// tables are cached with the native font scaler data
89
// only supports gsub, gpos, gdef, mort tables at present
90
virtual const void *getFontTable(LETag tableTag) const;
91
virtual const void *getFontTable(LETag tableTag, size_t &len) const;
92
93
virtual void *getKernPairs() const {
94
return layoutTables->kernPairs;
95
}
96
virtual void setKernPairs(void *pairs) const {
97
layoutTables->kernPairs = pairs;
98
}
99
100
virtual le_bool canDisplay(LEUnicode32 ch) const
101
{
102
return (le_bool)env->CallBooleanMethod(font2D,
103
sunFontIDs.canDisplayMID, ch);
104
};
105
106
virtual le_int32 getUnitsPerEM() const {
107
return upem;
108
};
109
110
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch, const LECharMapper *mapper) const;
111
112
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
113
114
virtual void mapCharsToWideGlyphs(const LEUnicode chars[],
115
le_int32 offset, le_int32 count, le_bool reverse,
116
const LECharMapper *mapper, le_uint32 glyphs[]) const;
117
118
virtual le_uint32 mapCharToWideGlyph(LEUnicode32 ch,
119
const LECharMapper *mapper) const;
120
121
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
122
123
virtual void getKerningAdjustment(LEPoint &adjustment) const;
124
125
virtual void getWideGlyphAdvance(le_uint32 glyph, LEPoint &advance) const;
126
127
virtual le_bool getGlyphPoint(LEGlyphID glyph,
128
le_int32 pointNumber, LEPoint &point) const;
129
130
float getXPixelsPerEm() const
131
{
132
return xppem;
133
};
134
135
float getYPixelsPerEm() const
136
{
137
return yppem;
138
};
139
140
float xUnitsToPoints(float xUnits) const
141
{
142
return xUnits * xScaleUnitsToPoints;
143
};
144
145
float yUnitsToPoints(float yUnits) const
146
{
147
return yUnits * yScaleUnitsToPoints;
148
};
149
150
void unitsToPoints(LEPoint &units, LEPoint &points) const
151
{
152
points.fX = xUnitsToPoints(units.fX);
153
points.fY = yUnitsToPoints(units.fY);
154
}
155
156
float xPixelsToUnits(float xPixels) const
157
{
158
return xPixels * xScalePixelsToUnits;
159
};
160
161
float yPixelsToUnits(float yPixels) const
162
{
163
return yPixels * yScalePixelsToUnits;
164
};
165
166
void pixelsToUnits(LEPoint &pixels, LEPoint &units) const
167
{
168
units.fX = xPixelsToUnits(pixels.fX);
169
units.fY = yPixelsToUnits(pixels.fY);
170
};
171
172
virtual float getScaleFactorX() const {
173
return xScalePixelsToUnits;
174
};
175
176
virtual float getScaleFactorY() const {
177
return yScalePixelsToUnits;
178
};
179
180
void transformFunits(float xFunits, float yFunits, LEPoint &pixels) const;
181
182
virtual le_int32 getAscent() const { return 0; }; // not used
183
virtual le_int32 getDescent() const { return 0; }; // not used
184
virtual le_int32 getLeading() const { return 0; }; // not used
185
};
186
187
#endif
188
189
U_NAMESPACE_END
190
191