Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions make/modules/java.desktop/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,7 @@ else
ifeq ($(call isTargetOs, linux macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
ifeq ($(call isTargetOs, macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_CORETEXT
endif

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

Expand Down
6 changes: 6 additions & 0 deletions src/java.desktop/macosx/classes/sun/font/CFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ private CompositeFont createCompositeFont() {
PhysicalFont[] fonts = new PhysicalFont[numFonts];
fonts[0] = this;
int idx = 1;
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().info("Cascading list for " + this + " :");
}
for (String s : listOfString) {
if (FontUtilities.isLogging()) {
FontUtilities.getLogger().info("Fallback:" + s);
}
if (s.equals(".AppleSymbolsFB")) {
// Don't know why we get the weird name above .. replace.
s = "AppleSymbols";
Expand Down
34 changes: 3 additions & 31 deletions src/java.desktop/share/classes/sun/font/SunLayoutEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,34 +151,9 @@ private SunLayoutEngine(LayoutEngineKey key) {
this.key = key;
}

static WeakHashMap<Font2D, Boolean> aatInfo = new WeakHashMap<>();
private static final WeakHashMap<Font2D, FaceRef> facePtr =
new WeakHashMap<>();

private static boolean isAAT(Font2D font) {
Boolean aatObj;
synchronized (aatInfo) {
aatObj = aatInfo.get(font);
}
if (aatObj != null) {
return aatObj.booleanValue();
}
boolean aat = false;
if (font instanceof TrueTypeFont) {
TrueTypeFont ttf = (TrueTypeFont)font;
aat = ttf.getDirectoryEntry(TrueTypeFont.morxTag) != null ||
ttf.getDirectoryEntry(TrueTypeFont.mortTag) != null;
} else if (font instanceof PhysicalFont) {
PhysicalFont pf = (PhysicalFont)font;
aat = pf.getTableBytes(TrueTypeFont.morxTag) != null ||
pf.getTableBytes(TrueTypeFont.mortTag) != null;
}
synchronized (aatInfo) {
aatInfo.put(font, Boolean.valueOf(aat));
}
return aat;
}

private long getFacePtr(Font2D font2D) {
FaceRef ref;
synchronized (facePtr) {
Expand All @@ -192,11 +167,9 @@ public void layout(FontStrikeDesc desc, float[] mat, float ptSize, int gmask,
Point2D.Float pt, GVData data) {
Font2D font = key.font();
FontStrike strike = font.getStrike(desc);
long pNativeFont = font.getPlatformNativeFontPtr(); // used on OSX
long pFace = getFacePtr(font);
if (pFace != 0) {
shape(font, strike, ptSize, mat, pNativeFont,
pFace, isAAT(font),
shape(font, strike, ptSize, mat, pFace,
tr.text, data, key.script(),
tr.start, tr.limit, baseIndex, pt,
typo_flags, gmask);
Expand All @@ -206,13 +179,12 @@ pFace, isAAT(font),
/* Native method to invoke harfbuzz layout engine */
private static native boolean
shape(Font2D font, FontStrike strike, float ptSize, float[] mat,
long pNativeFont, long pFace, boolean aat,
long pFace,
char[] chars, GVData data,
int script, int offset, int limit,
int baseIndex, Point2D.Float pt, int typo_flags, int slot);

private static native long createFace(Font2D font,
boolean aat,
long platformNativeFontPtr);

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

private synchronized long getNativePtr() {
if (facePtr == null) {
facePtr = createFace(font, isAAT(font),
facePtr = createFace(font,
font.getPlatformNativeFontPtr());
if (facePtr != 0) {
Disposer.addObjectRecord(font, this);
Expand Down
16 changes: 3 additions & 13 deletions src/java.desktop/share/native/libfontmanager/HBShaper.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#include "hb.h"
#include "hb-jdk.h"
#include "hb-ot.h"
#ifdef MACOSX
#include "hb-coretext.h"
#endif
#include "scriptMapping.h"

static jclass gvdClass = 0;
Expand Down Expand Up @@ -201,9 +198,7 @@ JDKFontInfo*
jobject font2D,
jobject fontStrike,
jfloat ptSize,
jlong pNativeFont,
jfloatArray matrix,
jboolean aat) {
jfloatArray matrix) {


JDKFontInfo *fi = (JDKFontInfo*)malloc(sizeof(JDKFontInfo));
Expand All @@ -213,13 +208,11 @@ JDKFontInfo*
fi->env = env; // this is valid only for the life of this JNI call.
fi->font2D = font2D;
fi->fontStrike = fontStrike;
fi->nativeFont = pNativeFont;
fi->aat = aat;
(*env)->GetFloatArrayRegion(env, matrix, 0, 4, fi->matrix);
fi->ptSize = ptSize;
fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
if (!aat && (getenv("HB_NODEVTX") != NULL)) {
if (getenv("HB_NODEVTX") != NULL) {
fi->devScale = fi->xPtSize / fi->ptSize;
} else {
fi->devScale = 1.0f;
Expand All @@ -238,9 +231,7 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
jobject fontStrike,
jfloat ptSize,
jfloatArray matrix,
jlong pNativeFont,
jlong pFace,
jboolean aat,
jcharArray text,
jobject gvdata,
jint script,
Expand Down Expand Up @@ -268,8 +259,7 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape
unsigned int buflen;

JDKFontInfo *jdkFontInfo =
createJDKFontInfo(env, font2D, fontStrike, ptSize,
pNativeFont, matrix, aat);
createJDKFontInfo(env, font2D, fontStrike, ptSize, matrix);
if (!jdkFontInfo) {
return JNI_FALSE;
}
Expand Down
18 changes: 2 additions & 16 deletions src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@

#include "hb.h"
#include "hb-jdk.h"
#ifdef MACOSX
#include "hb-coretext.h"
#endif
#include <stdlib.h>

#if defined(__GNUC__) && __GNUC__ >= 4
Expand Down Expand Up @@ -366,19 +363,12 @@ extern "C" {
/*
* Class: sun_font_SunLayoutEngine
* Method: createFace
* Signature: (Lsun/font/Font2D;ZJJ)J
* Signature: (Lsun/font/Font2D;JJ)J
*/
JNIEXPORT jlong JNICALL Java_sun_font_SunLayoutEngine_createFace(JNIEnv *env,
jclass cls,
jobject font2D,
jboolean aat,
jlong platformFontPtr) {
#ifdef MACOSX
if (aat && platformFontPtr) {
hb_face_t *face = hb_coretext_face_create((CGFontRef)platformFontPtr);
return ptr_to_jlong(face);
}
#endif
Font2DPtr *fi = (Font2DPtr*)malloc(sizeof(Font2DPtr));
if (!fi) {
return 0;
Expand Down Expand Up @@ -442,10 +432,6 @@ static hb_font_t* _hb_jdk_ct_font_create(hb_face_t* face,
hb_font_t* hb_jdk_font_create(hb_face_t* hbFace,
JDKFontInfo *jdkFontInfo,
hb_destroy_func_t destroy) {
#ifdef MACOSX
if (jdkFontInfo->aat && jdkFontInfo->nativeFont) {
return _hb_jdk_ct_font_create(hbFace, jdkFontInfo);
}
#endif

return _hb_jdk_font_create(hbFace, jdkFontInfo, destroy);
}
2 changes: 0 additions & 2 deletions src/java.desktop/share/native/libfontmanager/hb-jdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ typedef struct JDKFontInfo_Struct {
JNIEnv* env;
jobject font2D;
jobject fontStrike;
long nativeFont;
float matrix[4];
float ptSize;
float xPtSize;
float yPtSize;
float devScale; // How much applying the full glyph tx scales x distance.
jboolean aat;
} JDKFontInfo;


Expand Down
Loading