提交 e6aa8195 编写于 作者: R robm

Merge

...@@ -242,7 +242,7 @@ SUNWprivate_1.1 { ...@@ -242,7 +242,7 @@ SUNWprivate_1.1 {
getDefaultConfig; getDefaultConfig;
Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_FcFontManager_getFontPathNative;
Java_sun_font_SunFontManager_populateFontFileNameMap; Java_sun_font_SunFontManager_populateFontFileNameMap;
# CDE private entry point # CDE private entry point
......
...@@ -270,7 +270,7 @@ SUNWprivate_1.1 { ...@@ -270,7 +270,7 @@ SUNWprivate_1.1 {
getDefaultConfig; getDefaultConfig;
Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_FcFontManager_getFontPathNative;
Java_sun_font_SunFontManager_populateFontFileNameMap; Java_sun_font_SunFontManager_populateFontFileNameMap;
# CDE private entry point # CDE private entry point
......
...@@ -65,7 +65,7 @@ SUNWprivate_1.1 { ...@@ -65,7 +65,7 @@ SUNWprivate_1.1 {
Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontConfigManager_getFontConfigVersion; Java_sun_font_FontConfigManager_getFontConfigVersion;
Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_FcFontManager_getFontPathNative;
Java_sun_awt_FontDescriptor_initIDs; Java_sun_awt_FontDescriptor_initIDs;
Java_sun_awt_PlatformFont_initIDs; Java_sun_awt_PlatformFont_initIDs;
......
...@@ -188,7 +188,7 @@ SUNWprivate_1.1 { ...@@ -188,7 +188,7 @@ SUNWprivate_1.1 {
Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfig;
Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigAASettings;
Java_sun_font_FontConfigManager_getFontConfigVersion; Java_sun_font_FontConfigManager_getFontConfigVersion;
Java_sun_awt_X11FontManager_getFontPathNative; Java_sun_awt_FcFontManager_getFontPathNative;
Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initDisplay;
Java_sun_awt_X11GraphicsEnvironment_initGLX; Java_sun_awt_X11GraphicsEnvironment_initGLX;
Java_sun_awt_X11GraphicsEnvironment_initXRender; Java_sun_awt_X11GraphicsEnvironment_initXRender;
......
/*
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.awt;
import sun.font.FcFontConfiguration;
import sun.font.FontConfigManager;
import sun.font.SunFontManager;
/**
* A {@link sun.font.FontManager} that uses fontconfig to find system fonts.
*/
public class FcFontManager extends SunFontManager {
private FontConfigManager fcManager = null;
public synchronized FontConfigManager getFontConfigManager() {
if (fcManager == null) {
fcManager = new FontConfigManager();
}
return fcManager;
}
@Override
protected FontConfiguration createFontConfiguration() {
FcFontConfiguration fcFontConfig = new FcFontConfiguration(this);
if (fcFontConfig.init()) {
return fcFontConfig;
} else {
throw new InternalError("failed to initialize fontconfig");
}
}
@Override
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
boolean preferPropFonts) {
FcFontConfiguration fcFontConfig =
new FcFontConfiguration(this, preferLocaleFonts, preferPropFonts);
if (fcFontConfig.init()) {
return fcFontConfig;
} else {
throw new InternalError("failed to initialize fontconfig");
}
}
@Override
protected String[] getDefaultPlatformFont() {
final String[] info = new String[2];
getFontConfigManager().initFontConfigFonts(false);
FontConfigManager.FcCompFont[] fontConfigFonts =
getFontConfigManager().getFontConfigFonts();
for (int i=0; i<fontConfigFonts.length; i++) {
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
0 == fontConfigFonts[i].style) {
info[0] = fontConfigFonts[i].firstFont.familyName;
info[1] = fontConfigFonts[i].firstFont.fontFile;
break;
}
}
/* Absolute last ditch attempt in the face of fontconfig problems.
* If we didn't match, pick the first, or just make something
* up so we don't NPE.
*/
if (info[0] == null) {
if (fontConfigFonts.length > 0 &&
fontConfigFonts[0].firstFont.fontFile != null) {
info[0] = fontConfigFonts[0].firstFont.familyName;
info[1] = fontConfigFonts[0].firstFont.fontFile;
} else {
info[0] = "Dialog";
info[1] = "/dialog.ttf";
}
}
return info;
}
protected native String getFontPathNative(boolean noType1Fonts,
boolean isX11GE);
protected synchronized String getFontPath(boolean noType1Fonts) {
return getFontPathNative(noType1Fonts, false);
}
}
...@@ -54,7 +54,7 @@ import sun.util.logging.PlatformLogger; ...@@ -54,7 +54,7 @@ import sun.util.logging.PlatformLogger;
/** /**
* The X11 implementation of {@link FontManager}. * The X11 implementation of {@link FontManager}.
*/ */
public final class X11FontManager extends SunFontManager { public final class X11FontManager extends FcFontManager {
// constants identifying XLFD and font ID fields // constants identifying XLFD and font ID fields
private static final int FOUNDRY_FIELD = 1; private static final int FOUNDRY_FIELD = 1;
...@@ -154,8 +154,6 @@ public final class X11FontManager extends SunFontManager { ...@@ -154,8 +154,6 @@ public final class X11FontManager extends SunFontManager {
*/ */
private static String[] fontdirs = null; private static String[] fontdirs = null;
private FontConfigManager fcManager = null;
public static X11FontManager getInstance() { public static X11FontManager getInstance() {
return (X11FontManager) SunFontManager.getInstance(); return (X11FontManager) SunFontManager.getInstance();
} }
...@@ -784,51 +782,9 @@ public final class X11FontManager extends SunFontManager { ...@@ -784,51 +782,9 @@ public final class X11FontManager extends SunFontManager {
preferLocaleFonts, preferPropFonts); preferLocaleFonts, preferPropFonts);
} }
public synchronized native String getFontPathNative(boolean noType1Fonts);
protected synchronized String getFontPath(boolean noType1Fonts) { protected synchronized String getFontPath(boolean noType1Fonts) {
isHeadless(); // make sure GE is inited, as its the X11 lock. isHeadless(); // make sure GE is inited, as its the X11 lock.
return getFontPathNative(noType1Fonts); return getFontPathNative(noType1Fonts, true);
}
@Override
protected String[] getDefaultPlatformFont() {
final String[] info = new String[2];
getFontConfigManager().initFontConfigFonts(false);
FontConfigManager.FcCompFont[] fontConfigFonts =
getFontConfigManager().getFontConfigFonts();
for (int i=0; i<fontConfigFonts.length; i++) {
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
0 == fontConfigFonts[i].style) {
info[0] = fontConfigFonts[i].firstFont.familyName;
info[1] = fontConfigFonts[i].firstFont.fontFile;
break;
}
}
/* Absolute last ditch attempt in the face of fontconfig problems.
* If we didn't match, pick the first, or just make something
* up so we don't NPE.
*/
if (info[0] == null) {
if (fontConfigFonts.length > 0 &&
fontConfigFonts[0].firstFont.fontFile != null) {
info[0] = fontConfigFonts[0].firstFont.familyName;
info[1] = fontConfigFonts[0].firstFont.fontFile;
} else {
info[0] = "Dialog";
info[1] = "/dialog.ttf";
}
}
return info;
}
public synchronized FontConfigManager getFontConfigManager() {
if (fcManager == null) {
fcManager = new FontConfigManager();
}
return fcManager;
} }
@Override @Override
......
...@@ -39,10 +39,10 @@ import java.util.HashMap; ...@@ -39,10 +39,10 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import java.util.Scanner; import java.util.Scanner;
import sun.awt.FcFontManager;
import sun.awt.FontConfiguration; import sun.awt.FontConfiguration;
import sun.awt.FontDescriptor; import sun.awt.FontDescriptor;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.awt.X11FontManager;
import sun.font.CompositeFontDescriptor; import sun.font.CompositeFontDescriptor;
import sun.font.FontManager; import sun.font.FontManager;
import sun.font.FontConfigManager.FontConfigInfo; import sun.font.FontConfigManager.FontConfigInfo;
...@@ -92,7 +92,7 @@ public class FcFontConfiguration extends FontConfiguration { ...@@ -92,7 +92,7 @@ public class FcFontConfiguration extends FontConfiguration {
setFontConfiguration(); setFontConfiguration();
readFcInfo(); readFcInfo();
X11FontManager fm = (X11FontManager) fontManager; FcFontManager fm = (FcFontManager) fontManager;
FontConfigManager fcm = fm.getFontConfigManager(); FontConfigManager fcm = fm.getFontConfigManager();
if (fcCompFonts == null) { if (fcCompFonts == null) {
fcCompFonts = fcm.loadFontConfig(); fcCompFonts = fcm.loadFontConfig();
...@@ -194,7 +194,7 @@ public class FcFontConfiguration extends FontConfiguration { ...@@ -194,7 +194,7 @@ public class FcFontConfiguration extends FontConfiguration {
@Override @Override
public String[] getPlatformFontNames() { public String[] getPlatformFontNames() {
HashSet<String> nameSet = new HashSet<String>(); HashSet<String> nameSet = new HashSet<String>();
X11FontManager fm = (X11FontManager) fontManager; FcFontManager fm = (FcFontManager) fontManager;
FontConfigManager fcm = fm.getFontConfigManager(); FontConfigManager fcm = fm.getFontConfigManager();
FcCompFont[] fcCompFonts = fcm.loadFontConfig(); FcCompFont[] fcCompFonts = fcm.loadFontConfig();
for (int i=0; i<fcCompFonts.length; i++) { for (int i=0; i<fcCompFonts.length; i++) {
...@@ -235,7 +235,7 @@ public class FcFontConfiguration extends FontConfiguration { ...@@ -235,7 +235,7 @@ public class FcFontConfiguration extends FontConfiguration {
@Override @Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() { public CompositeFontDescriptor[] get2DCompositeFontInfo() {
X11FontManager fm = (X11FontManager) fontManager; FcFontManager fm = (FcFontManager) fontManager;
FontConfigManager fcm = fm.getFontConfigManager(); FontConfigManager fcm = fm.getFontConfigManager();
FcCompFont[] fcCompFonts = fcm.loadFontConfig(); FcCompFont[] fcCompFonts = fcm.loadFontConfig();
...@@ -368,7 +368,7 @@ public class FcFontConfiguration extends FontConfiguration { ...@@ -368,7 +368,7 @@ public class FcFontConfiguration extends FontConfiguration {
private void writeFcInfo() { private void writeFcInfo() {
Properties props = new Properties(); Properties props = new Properties();
props.setProperty("version", fileVersion); props.setProperty("version", fileVersion);
X11FontManager fm = (X11FontManager) fontManager; FcFontManager fm = (FcFontManager) fontManager;
FontConfigManager fcm = fm.getFontConfigManager(); FontConfigManager fcm = fm.getFontConfigManager();
FontConfigInfo fcInfo = fcm.getFontConfigInfo(); FontConfigInfo fcInfo = fcm.getFontConfigInfo();
props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
...@@ -427,7 +427,7 @@ public class FcFontConfiguration extends FontConfiguration { ...@@ -427,7 +427,7 @@ public class FcFontConfiguration extends FontConfiguration {
return; return;
} }
Properties props = new Properties(); Properties props = new Properties();
X11FontManager fm = (X11FontManager) fontManager; FcFontManager fm = (FcFontManager) fontManager;
FontConfigManager fcm = fm.getFontConfigManager(); FontConfigManager fcm = fm.getFontConfigManager();
try { try {
FileInputStream fis = new FileInputStream(fcFile); FileInputStream fis = new FileInputStream(fcFile);
......
...@@ -497,7 +497,7 @@ static char* mergePaths(char **p1, char **p2, char **p3, jboolean noType1) { ...@@ -497,7 +497,7 @@ static char* mergePaths(char **p1, char **p2, char **p3, jboolean noType1) {
* This also frees us from X11 APIs as JRE is required to function in * This also frees us from X11 APIs as JRE is required to function in
* a "headless" mode where there is no Xserver. * a "headless" mode where there is no Xserver.
*/ */
static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1, jboolean isX11) {
char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL; char **fcdirs = NULL, **x11dirs = NULL, **knowndirs = NULL, *path = NULL;
...@@ -519,6 +519,7 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { ...@@ -519,6 +519,7 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
* be initialised. * be initialised.
*/ */
#ifndef HEADLESS #ifndef HEADLESS
if (isX11) { // The following only works in an x11 environment.
#if defined(__linux__) #if defined(__linux__)
/* There's no headless build on linux ... */ /* There's no headless build on linux ... */
if (!AWTIsHeadless()) { /* .. so need to call a function to check */ if (!AWTIsHeadless()) { /* .. so need to call a function to check */
...@@ -538,6 +539,7 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { ...@@ -538,6 +539,7 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
#if defined(__linux__) #if defined(__linux__)
} }
#endif #endif
}
#endif /* !HEADLESS */ #endif /* !HEADLESS */
path = mergePaths(fcdirs, x11dirs, knowndirs, noType1); path = mergePaths(fcdirs, x11dirs, knowndirs, noType1);
if (fcdirs != NULL) { if (fcdirs != NULL) {
...@@ -555,13 +557,13 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) { ...@@ -555,13 +557,13 @@ static char *getPlatformFontPathChars(JNIEnv *env, jboolean noType1) {
return path; return path;
} }
JNIEXPORT jstring JNICALL Java_sun_awt_X11FontManager_getFontPathNative JNIEXPORT jstring JNICALL Java_sun_awt_FcFontManager_getFontPathNative
(JNIEnv *env, jobject thiz, jboolean noType1) { (JNIEnv *env, jobject thiz, jboolean noType1, jboolean isX11) {
jstring ret; jstring ret;
static char *ptr = NULL; /* retain result across calls */ static char *ptr = NULL; /* retain result across calls */
if (ptr == NULL) { if (ptr == NULL) {
ptr = getPlatformFontPathChars(env, noType1); ptr = getPlatformFontPathChars(env, noType1, isX11);
} }
ret = (*env)->NewStringUTF(env, ptr); ret = (*env)->NewStringUTF(env, ptr);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册