1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
Index: libiscwt-java-5.3.20100629/src/de/intarsys/cwt/font/FontEnvironment.java
===================================================================
--- libiscwt-java-5.3.20100629.orig/src/de/intarsys/cwt/font/FontEnvironment.java 2013-07-03 03:10:21.395832976 +0800
+++ libiscwt-java-5.3.20100629/src/de/intarsys/cwt/font/FontEnvironment.java 2013-07-05 19:05:07.295469597 +0800
@@ -40,7 +40,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import sun.font.FontManager;
import de.intarsys.cwt.freetype.Face;
import de.intarsys.cwt.freetype.Freetype;
import de.intarsys.cwt.freetype.Library;
@@ -92,6 +91,56 @@
return fontFiles.toArray(new File[fontFiles.size()]);
}
+
+ // sun.font.FontManager openjdk6
+ // sun.font.SunFontManager openjdk7
+ static boolean mIsOpenJDK6;
+ static Class<?> mClass;
+ static java.lang.reflect.Method mMethod;
+ static Object mContext;
+ static {
+ try {
+ mClass=Class.forName("sun.font.SunFontManager");
+ mIsOpenJDK6=false;
+ } catch (ClassNotFoundException e) {
+ mIsOpenJDK6=true;
+ try {
+ mClass=Class.forName("sun.font.FontManager");
+ } catch (ClassNotFoundException e1) {
+ // should never go here
+ e1.printStackTrace();
+ }
+ }
+ if (mIsOpenJDK6){
+ //definition = FontManager.getFontPath(true);
+ try {
+ mMethod=mClass.getMethod("getFontPath", boolean.class);
+ mContext=null;
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ } else {
+ // definition = sun.font.SunFontManager.getInstance().getPlatformFontPath(true);
+ try {
+ mMethod=mClass.getMethod("getInstance");
+ mContext=mMethod.invoke(null);
+ mMethod=mClass.getMethod("getPlatformFontPath", boolean.class);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
/**
* This method determines the system's font directories.
*
@@ -102,7 +151,17 @@
String definition = null;
// force FontManager initialization
Font.decode("dummy").getFamily(); //$NON-NLS-1$
- definition = sun.font.SunFontManager.getInstance().getPlatformFontPath(true);
+ try {
+ definition=(String)mMethod.invoke(mContext, true);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (java.lang.reflect.InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (java.lang.ClassCastException e){
+ e.printStackTrace();
+ }
if (definition == null) {
return new File[0];
}
|