Skip to content

Commit fe746c5

Browse files
committed
8191512: T2K font rasterizer code removal
Reviewed-by: serb, erikj
1 parent 4800622 commit fe746c5

7 files changed

Lines changed: 17 additions & 109 deletions

File tree

make/scripts/compare_exceptions.sh.incl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "x86_64" ];
179179
./lib/libsplashscreen.so
180180
./lib/libsunec.so
181181
./lib/libsunwjdga.so
182-
./lib/libt2k.so
183182
./lib/libunpack.so
184183
./lib/libverify.so
185184
./lib/libzip.so
@@ -290,7 +289,6 @@ if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "sparcv9" ]
290289
./lib/libsplashscreen.so
291290
./lib/libsunec.so
292291
./lib/libsunwjdga.so
293-
./lib/libt2k.so
294292
./lib/libunpack.so
295293
./lib/libverify.so
296294
./lib/libzip.so

src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/* remember that the API requires a Font use a
2929
* consistent glyph id. for a code point, and this is a
3030
* problem if a particular strike uses native scaler sometimes
31-
* and T2K others. That needs to be dealt with somewhere, but
31+
* and the JDK scaler others. That needs to be dealt with somewhere, but
3232
* here we can just always get the same glyph code without
3333
* needing a strike.
3434
*

src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ top of freetype library (that is used in binary form).
5050
To avoid link error we have to load freetype explicitly
5151
before we load fontmanager.
5252
53-
Note that we do not need to do this for T2K because
54-
fontmanager.dll does not depend on t2k.dll.
55-
5653
NB: consider moving freetype wrapper part to separate
5754
shared library in order to avoid dependency. */
5855
System.loadLibrary("freetype");

src/java.desktop/share/classes/sun/font/FontScaler.java

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.awt.geom.Point2D;
3030
import java.awt.geom.Rectangle2D;
3131
import java.lang.ref.WeakReference;
32-
import java.lang.reflect.Constructor;
3332

3433
import sun.java2d.Disposer;
3534
import sun.java2d.DisposerRecord;
@@ -82,51 +81,16 @@
8281
public abstract class FontScaler implements DisposerRecord {
8382

8483
private static FontScaler nullScaler = null;
85-
private static Constructor<? extends FontScaler> scalerConstructor = null;
8684

8785
//Find preferred font scaler
8886
//
8987
//NB: we can allow property based preferences
9088
// (theoretically logic can be font type specific)
91-
static {
92-
Class<? extends FontScaler> scalerClass = null;
93-
Class<?>[] arglst = new Class<?>[] {Font2D.class, int.class,
94-
boolean.class, int.class};
95-
96-
try {
97-
@SuppressWarnings("unchecked")
98-
Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
99-
((!FontUtilities.useT2K && !FontUtilities.useLegacy) ?
100-
Class.forName("sun.font.FreetypeFontScaler") :
101-
Class.forName("sun.font.T2KFontScaler"));
102-
scalerClass = tmp;
103-
} catch (ClassNotFoundException e) {
104-
try {
105-
@SuppressWarnings("unchecked")
106-
Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
107-
Class.forName("sun.font.FreetypeFontScaler");
108-
scalerClass = tmp;
109-
} catch (ClassNotFoundException e1) {
110-
scalerClass = NullFontScaler.class;
111-
}
112-
} finally {
113-
if (FontUtilities.debugFonts()) {
114-
System.out.println("Scaler class="+scalerClass);
115-
}
116-
}
117-
118-
//NB: rewrite using factory? constructor is ugly way
119-
try {
120-
scalerConstructor = scalerClass.getConstructor(arglst);
121-
} catch (NoSuchMethodException e) {
122-
//should not happen
123-
}
124-
}
12589

12690
/* This is the only place to instantiate new FontScaler.
12791
* Therefore this is very convinient place to register
128-
* scaler with Disposer as well as trigger deregistring bad font
129-
* in case when scaler reports this.
92+
* scaler with Disposer as well as trigger deregistering a bad font
93+
* when the scaler reports this.
13094
*/
13195
public static FontScaler getScaler(Font2D font,
13296
int indexInCollection,
@@ -135,14 +99,13 @@ public static FontScaler getScaler(Font2D font,
13599
FontScaler scaler = null;
136100

137101
try {
138-
Object args[] = new Object[] {font, indexInCollection,
139-
supportsCJK, filesize};
140-
scaler = scalerConstructor.newInstance(args);
102+
scaler = new FreetypeFontScaler(font, indexInCollection,
103+
supportsCJK, filesize);
141104
Disposer.addObjectRecord(font, scaler);
142105
} catch (Throwable e) {
143-
scaler = nullScaler;
106+
scaler = getNullScaler();
144107

145-
//if we can not instantiate scaler assume bad font
108+
//if we can not instantiate scaler assume a bad font
146109
//NB: technically it could be also because of internal scaler
147110
// error but here we are assuming scaler is ok.
148111
FontManager fm = FontManagerFactory.getInstance();

src/java.desktop/share/classes/sun/font/FontUtilities.java

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ public final class FontUtilities {
5252

5353
public static boolean useJDKScaler;
5454

55-
public static boolean useT2K;
56-
// useLegacy is a short-term debugging transition aid.
57-
public static boolean useLegacy;
58-
5955
public static boolean isWindows;
6056

6157
private static boolean debugFonts = false;
@@ -76,33 +72,16 @@ public Object run() {
7672

7773
isMacOSX = osName.contains("OS X"); // TODO: MacOSX
7874

79-
/* Support a value of "t2k" as meaning use the JDK internal
80-
* scaler over the platform scaler whether or not t2k is
81-
* actually available.
82-
* This can be considered transitional support for some
83-
* level of compatibility, as in it avoids the native scaler
84-
* as before but cannot guarantee rendering equivalence
85-
* with T2K.
86-
* It will also use t2k instead of freetype if t2k is
87-
* available - this is the same as before.
88-
* The new value of "jdk" means even if t2k is available,
89-
* the decision as to whether to use that or freetype is
90-
* not affected by this setting.
75+
/* If set to "jdk", use the JDK's scaler rather than
76+
* the platform one. This may be a no-op on platforms where
77+
* JDK has been configured so that it always relies on the
78+
* platform scaler. The principal case where it has an
79+
* effect is that on Windows, 2D will never use GDI.
9180
*/
9281
String scalerStr = System.getProperty("sun.java2d.font.scaler");
9382
if (scalerStr != null) {
94-
useT2K = "t2k".equals(scalerStr);
95-
if (useT2K) {
96-
System.out.println("WARNING: t2k will be removed in JDK 11.");
97-
}
98-
useLegacy = "legacy".equals(scalerStr);
99-
if (useLegacy) {
100-
System.out.println("WARNING: legacy behavior will be removed in JDK 11.");
101-
}
102-
useJDKScaler = useT2K || "jdk".equals(scalerStr);
83+
useJDKScaler = "jdk".equals(scalerStr);
10384
} else {
104-
useT2K = false;
105-
useLegacy = false;
10685
useJDKScaler = false;
10786
}
10887
isWindows = osName.startsWith("Windows");

src/java.desktop/share/classes/sun/font/SunFontManager.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ public boolean accept(File dir, String name) {
132132
public static final int FONTFORMAT_NONE = -1;
133133
public static final int FONTFORMAT_TRUETYPE = 0;
134134
public static final int FONTFORMAT_TYPE1 = 1;
135-
public static final int FONTFORMAT_T2K = 2;
136-
public static final int FONTFORMAT_TTC = 3;
137-
public static final int FONTFORMAT_COMPOSITE = 4;
138-
public static final int FONTFORMAT_NATIVE = 5;
135+
public static final int FONTFORMAT_TTC = 2;
136+
public static final int FONTFORMAT_COMPOSITE = 3;
137+
public static final int FONTFORMAT_NATIVE = 4;
139138

140139
/* Pool of 20 font file channels chosen because some UTF-8 locale
141140
* composite fonts can use up to 16 platform fonts (including the
@@ -353,7 +352,7 @@ public Object run() {
353352
* handle two fonts of the same name, so the JRE one
354353
* must be the first one registered. Pass "true" to
355354
* registerFonts method as on-screen these JRE fonts
356-
* always go through the T2K rasteriser.
355+
* always go through the JDK rasteriser.
357356
*/
358357
if (FontUtilities.isLinux) {
359358
/* Linux font configuration uses these fonts */

src/java.desktop/share/native/common/font/fontscalerdefs.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
extern "C" {
3333
#endif
3434

35-
#define kPosInfinity16 (32767)
36-
#define kNegInfinity16 (-32768)
37-
38-
#define kPosInfinity32 (0x7fffffff)
39-
#define kNegInfinity32 (0x80000000)
40-
41-
4235
#ifdef _LP64
4336
typedef unsigned int UInt32;
4437
typedef int Int32;
@@ -65,27 +58,6 @@ typedef UInt32 Bool32;
6558
#endif
6659
#endif
6760

68-
#define kPosInfinity32 (0x7fffffff)
69-
#define kNegInfinity32 (0x80000000)
70-
71-
#define F26Dot6ToFixed(n) ((n) << 10)
72-
#define F26Dot6ToScalar(n) (((t2kScalar)(n)) / (t2kScalar)64)
73-
74-
/* t2kFixed is the same as F16Dot16 format although T2K also uses 26.6 */
75-
typedef Int32 t2kFixed;
76-
typedef float t2kScalar;
77-
78-
#define t2kIntToFixed(x) ((t2kFixed)(x) << 16)
79-
#define t2kFixedToInt(x) ((x) >> 16)
80-
81-
#define t2kFixedRound(x) (((x) + 0x8000) >> 16)
82-
#define t2kFixed1 t2kIntToFixed(1)
83-
84-
#define t2kFloatToFixed(f) (t2kFixed)((f) * (float)(t2kFixed1))
85-
#define t2kFixedToFloat(x) ((x) / (float)(65536))
86-
87-
#define t2kScalarAverage(a, b) (((a) + (b)) / (t2kScalar)(2))
88-
8961
/* managed: 1 means the glyph has a hardware cached
9062
* copy, and its freeing is managed by the usual
9163
* 2D disposer code.

0 commit comments

Comments
 (0)