42 |
42 |
43 import java.util.*; |
43 import java.util.*; |
44 import java.util.logging.*; |
44 import java.util.logging.*; |
45 |
45 |
46 import sun.awt.motif.MFontConfiguration; |
46 import sun.awt.motif.MFontConfiguration; |
|
47 import sun.font.FcFontConfiguration; |
47 import sun.font.Font2D; |
48 import sun.font.Font2D; |
48 import sun.font.FontManager; |
49 import sun.font.FontManager; |
49 import sun.font.NativeFont; |
50 import sun.font.NativeFont; |
50 import sun.java2d.SunGraphicsEnvironment; |
51 import sun.java2d.SunGraphicsEnvironment; |
51 import sun.java2d.SurfaceManagerFactory; |
52 import sun.java2d.SurfaceManagerFactory; |
348 * and returns the name of the corresponding physical font. |
349 * and returns the name of the corresponding physical font. |
349 * This code is used to resolve font configuration fonts, and expects |
350 * This code is used to resolve font configuration fonts, and expects |
350 * only to get called for these fonts. |
351 * only to get called for these fonts. |
351 */ |
352 */ |
352 public String getFileNameFromPlatformName(String platName) { |
353 public String getFileNameFromPlatformName(String platName) { |
|
354 |
|
355 /* If the FontConfig file doesn't use xlfds, or its |
|
356 * FcFontConfiguration, this may be already a file name. |
|
357 */ |
|
358 if (platName.startsWith("/")) { |
|
359 return platName; |
|
360 } |
|
361 |
353 String fileName = null; |
362 String fileName = null; |
354 String fontID = specificFontIDForName(platName); |
363 String fontID = specificFontIDForName(platName); |
355 |
364 |
356 /* If the font filename has been explicitly assigned in the |
365 /* If the font filename has been explicitly assigned in the |
357 * font configuration file, use it. This avoids accessing |
366 * font configuration file, use it. This avoids accessing |
903 fontNameMap = new HashMap(1); |
912 fontNameMap = new HashMap(1); |
904 } |
913 } |
905 |
914 |
906 // Implements SunGraphicsEnvironment.createFontConfiguration. |
915 // Implements SunGraphicsEnvironment.createFontConfiguration. |
907 protected FontConfiguration createFontConfiguration() { |
916 protected FontConfiguration createFontConfiguration() { |
908 return new MFontConfiguration(this); |
917 |
|
918 /* The logic here decides whether to use a preconfigured |
|
919 * fontconfig.properties file, or synthesise one using platform APIs. |
|
920 * On Solaris (as opposed to OpenSolaris) we try to use the |
|
921 * pre-configured ones, but if the files it specifies are missing |
|
922 * we fail-safe to synthesising one. This might happen if Solaris |
|
923 * changes its fonts. |
|
924 * For OpenSolaris I don't expect us to ever create fontconfig files, |
|
925 * so it will always synthesise. Note that if we misidentify |
|
926 * OpenSolaris as Solaris, then the test for the presence of |
|
927 * Solaris-only font files will correct this. |
|
928 * For Linux we require an exact match of distro and version to |
|
929 * use the preconfigured file, and also that it points to |
|
930 * existent fonts. |
|
931 * If synthesising fails, we fall back to any preconfigured file |
|
932 * and do the best we can. For the commercial JDK this will be |
|
933 * fine as it includes the Lucida fonts. OpenJDK should not hit |
|
934 * this as the synthesis should always work on its platforms. |
|
935 */ |
|
936 FontConfiguration mFontConfig = new MFontConfiguration(this); |
|
937 if (isOpenSolaris || |
|
938 (isLinux && |
|
939 (!mFontConfig.foundOsSpecificFile() || |
|
940 !mFontConfig.fontFilesArePresent()) || |
|
941 (isSolaris && !mFontConfig.fontFilesArePresent()))) { |
|
942 FcFontConfiguration fcFontConfig = |
|
943 new FcFontConfiguration(this); |
|
944 if (fcFontConfig.init()) { |
|
945 return fcFontConfig; |
|
946 } |
|
947 } |
|
948 mFontConfig.init(); |
|
949 return mFontConfig; |
909 } |
950 } |
910 public FontConfiguration |
951 public FontConfiguration |
911 createFontConfiguration(boolean preferLocaleFonts, |
952 createFontConfiguration(boolean preferLocaleFonts, |
912 boolean preferPropFonts) { |
953 boolean preferPropFonts) { |
|
954 |
|
955 FontConfiguration config = getFontConfiguration(); |
|
956 if (config instanceof FcFontConfiguration) { |
|
957 // Doesn't need to implement the alternate support. |
|
958 return config; |
|
959 } |
913 |
960 |
914 return new MFontConfiguration(this, |
961 return new MFontConfiguration(this, |
915 preferLocaleFonts, preferPropFonts); |
962 preferLocaleFonts, preferPropFonts); |
916 } |
963 } |
917 |
964 |
919 * Returns face name for default font, or null if |
966 * Returns face name for default font, or null if |
920 * no face names are used for CompositeFontDescriptors |
967 * no face names are used for CompositeFontDescriptors |
921 * for this platform. |
968 * for this platform. |
922 */ |
969 */ |
923 public String getDefaultFontFaceName() { |
970 public String getDefaultFontFaceName() { |
|
971 |
924 return null; |
972 return null; |
925 } |
973 } |
926 |
974 |
927 private static native boolean pRunningXinerama(); |
975 private static native boolean pRunningXinerama(); |
928 private static native Point getXineramaCenterPoint(); |
976 private static native Point getXineramaCenterPoint(); |