Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit b1b3260

Browse files
author
Yuri Nesterenko
committed
8256372: [macos] Unexpected symbol was displayed on JTextField with Monospaced font
Reviewed-by: bae Backport-of: 005d8a7fca8b4d9519d2bde0a7cdbbece1cd3981
1 parent 5f9ed3b commit b1b3260

File tree

9 files changed

+73
-1360
lines changed

9 files changed

+73
-1360
lines changed

make/modules/java.desktop/lib/Awt2dLibraries.gmk

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,7 @@ else
451451
ifeq ($(call isTargetOs, linux macosx), true)
452452
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
453453
endif
454-
ifeq ($(call isTargetOs, macosx), true)
455-
HARFBUZZ_CFLAGS += -DHAVE_CORETEXT
456-
endif
457454

458-
ifeq ($(call isTargetOs, macosx), false)
459-
LIBFONTMANAGER_EXCLUDE_FILES += libharfbuzz/hb-coretext.cc
460-
endif
461455
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
462456
LIBFONTMANAGER_EXCLUDE_FILES += libharfbuzz/hb-ft.cc
463457

src/java.desktop/macosx/classes/sun/font/CFont.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,13 @@ private CompositeFont createCompositeFont() {
211211
PhysicalFont[] fonts = new PhysicalFont[numFonts];
212212
fonts[0] = this;
213213
int idx = 1;
214+
if (FontUtilities.isLogging()) {
215+
FontUtilities.getLogger().info("Cascading list for " + this + " :");
216+
}
214217
for (String s : listOfString) {
218+
if (FontUtilities.isLogging()) {
219+
FontUtilities.getLogger().info("Fallback:" + s);
220+
}
215221
if (s.equals(".AppleSymbolsFB")) {
216222
// Don't know why we get the weird name above .. replace.
217223
s = "AppleSymbols";

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

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -151,34 +151,9 @@ private SunLayoutEngine(LayoutEngineKey key) {
151151
this.key = key;
152152
}
153153

154-
static WeakHashMap<Font2D, Boolean> aatInfo = new WeakHashMap<>();
155154
private static final WeakHashMap<Font2D, FaceRef> facePtr =
156155
new WeakHashMap<>();
157156

158-
private static boolean isAAT(Font2D font) {
159-
Boolean aatObj;
160-
synchronized (aatInfo) {
161-
aatObj = aatInfo.get(font);
162-
}
163-
if (aatObj != null) {
164-
return aatObj.booleanValue();
165-
}
166-
boolean aat = false;
167-
if (font instanceof TrueTypeFont) {
168-
TrueTypeFont ttf = (TrueTypeFont)font;
169-
aat = ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
170-
ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null;
171-
} else if (font instanceof PhysicalFont) {
172-
PhysicalFont pf = (PhysicalFont)font;
173-
aat = pf.getTableBytes(TrueTypeFont.morxTag) != null ||
174-
pf.getTableBytes(TrueTypeFont.mortTag) != null;
175-
}
176-
synchronized (aatInfo) {
177-
aatInfo.put(font, Boolean.valueOf(aat));
178-
}
179-
return aat;
180-
}
181-
182157
private long getFacePtr(Font2D font2D) {
183158
FaceRef ref;
184159
synchronized (facePtr) {
@@ -192,11 +167,9 @@ public void layout(FontStrikeDesc desc, float[] mat, float ptSize, int gmask,
192167
Point2D.Float pt, GVData data) {
193168
Font2D font = key.font();
194169
FontStrike strike = font.getStrike(desc);
195-
long pNativeFont = font.getPlatformNativeFontPtr(); // used on OSX
196170
long pFace = getFacePtr(font);
197171
if (pFace != 0) {
198-
shape(font, strike, ptSize, mat, pNativeFont,
199-
pFace, isAAT(font),
172+
shape(font, strike, ptSize, mat, pFace,
200173
tr.text, data, key.script(),
201174
tr.start, tr.limit, baseIndex, pt,
202175
typo_flags, gmask);
@@ -206,13 +179,12 @@ pFace, isAAT(font),
206179
/* Native method to invoke harfbuzz layout engine */
207180
private static native boolean
208181
shape(Font2D font, FontStrike strike, float ptSize, float[] mat,
209-
long pNativeFont, long pFace, boolean aat,
182+
long pFace,
210183
char[] chars, GVData data,
211184
int script, int offset, int limit,
212185
int baseIndex, Point2D.Float pt, int typo_flags, int slot);
213186

214187
private static native long createFace(Font2D font,
215-
boolean aat,
216188
long platformNativeFontPtr);
217189

218190
private static native void disposeFace(long facePtr);
@@ -227,7 +199,7 @@ private FaceRef(Font2D font) {
227199

228200
private synchronized long getNativePtr() {
229201
if (facePtr == null) {
230-
facePtr = createFace(font, isAAT(font),
202+
facePtr = createFace(font,
231203
font.getPlatformNativeFontPtr());
232204
if (facePtr != 0) {
233205
Disposer.addObjectRecord(font, this);

src/java.desktop/share/native/libfontmanager/HBShaper.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#include "hb.h"
2929
#include "hb-jdk.h"
3030
#include "hb-ot.h"
31-
#ifdef MACOSX
32-
#include "hb-coretext.h"
33-
#endif
3431
#include "scriptMapping.h"
3532

3633
static jclass gvdClass = 0;
@@ -201,9 +198,7 @@ JDKFontInfo*
201198
jobject font2D,
202199
jobject fontStrike,
203200
jfloat ptSize,
204-
jlong pNativeFont,
205-
jfloatArray matrix,
206-
jboolean aat) {
201+
jfloatArray matrix) {
207202

208203

209204
JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
@@ -213,13 +208,11 @@ JDKFontInfo*
213208
fi->env = env; // this is valid only for the life of this JNI call.
214209
fi->font2D = font2D;
215210
fi->fontStrike = fontStrike;
216-
fi->nativeFont = pNativeFont;
217-
fi->aat = aat;
218211
(*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
219212
fi->ptSize = ptSize;
220213
fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
221214
fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
222-
if (!aat && (getenv("HB_NODEVTX") != NULL)) {
215+
if (getenv("HB_NODEVTX") != NULL) {
223216
fi->devScale = fi->xPtSize / fi->ptSize;
224217
} else {
225218
fi->devScale = 1.0f;
@@ -238,9 +231,7 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
238231
jobject fontStrike,
239232
jfloat ptSize,
240233
jfloatArray matrix,
241-
jlong pNativeFont,
242234
jlong pFace,
243-
jboolean aat,
244235
jcharArray text,
245236
jobject gvdata,
246237
jint script,
@@ -268,8 +259,7 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
268259
unsigned int buflen;
269260

270261
JDKFontInfo *jdkFontInfo =
271-
createJDKFontInfo(env, font2D, fontStrike, ptSize,
272-
pNativeFont, matrix, aat);
262+
createJDKFontInfo(env, font2D, fontStrike, ptSize, matrix);
273263
if (!jdkFontInfo) {
274264
return JNI_FALSE;
275265
}

src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828

2929
#include "hb.h"
3030
#include "hb-jdk.h"
31-
#ifdef MACOSX
32-
#include "hb-coretext.h"
33-
#endif
3431
#include <stdlib.h>
3532

3633
#if defined(__GNUC__) && __GNUC__ >= 4
@@ -366,19 +363,12 @@ extern "C" {
366363
/*
367364
* Class: sun_font_SunLayoutEngine
368365
* Method: createFace
369-
* Signature: (Lsun/font/Font2D;ZJJ)J
366+
* Signature: (Lsun/font/Font2D;JJ)J
370367
*/
371368
JNIEXPORT jlong JNICALL Java_sun_font_SunLayoutEngine_createFace(JNIEnv *env,
372369
jclass cls,
373370
jobject font2D,
374-
jboolean aat,
375371
jlong platformFontPtr) {
376-
#ifdef MACOSX
377-
if (aat && platformFontPtr) {
378-
hb_face_t *face = hb_coretext_face_create((CGFontRef)platformFontPtr);
379-
return ptr_to_jlong(face);
380-
}
381-
#endif
382372
Font2DPtr *fi = (Font2DPtr*)malloc(sizeof(Font2DPtr));
383373
if (!fi) {
384374
return 0;
@@ -442,10 +432,6 @@ static hb_font_t* _hb_jdk_ct_font_create(hb_face_t* face,
442432
hb_font_t* hb_jdk_font_create(hb_face_t* hbFace,
443433
JDKFontInfo *jdkFontInfo,
444434
hb_destroy_func_t destroy) {
445-
#ifdef MACOSX
446-
if (jdkFontInfo->aat && jdkFontInfo->nativeFont) {
447-
return _hb_jdk_ct_font_create(hbFace, jdkFontInfo);
448-
}
449-
#endif
435+
450436
return _hb_jdk_font_create(hbFace, jdkFontInfo, destroy);
451437
}

src/java.desktop/share/native/libfontmanager/hb-jdk.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ typedef struct JDKFontInfo_Struct {
3838
JNIEnv* env;
3939
jobject font2D;
4040
jobject fontStrike;
41-
long nativeFont;
4241
float matrix[4];
4342
float ptSize;
4443
float xPtSize;
4544
float yPtSize;
4645
float devScale; // How much applying the full glyph tx scales x distance.
47-
jboolean aat;
4846
} JDKFontInfo;
4947

5048

0 commit comments

Comments
 (0)