author | prr |
Thu, 12 Jun 2008 13:17:33 -0700 | |
changeset 883 | c3e81f0acd3d |
child 2372 | 229b2c88d29c |
permissions | -rw-r--r-- |
883
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
1 |
/* |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
4 |
* |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Sun designates this |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
10 |
* |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
15 |
* accompanied this code). |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
16 |
* |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
18 |
* along with this work; if not, write to the Free Software Foundation, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
20 |
* |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
23 |
* have any questions. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
24 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
25 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
26 |
package sun.font; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
27 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
28 |
import java.awt.Font; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
29 |
import java.io.File; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
30 |
import java.io.FileInputStream; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
31 |
import java.io.FileOutputStream; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
32 |
import java.io.IOException; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
33 |
import java.net.InetAddress; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
34 |
import java.net.UnknownHostException; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
35 |
import java.nio.charset.Charset; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
36 |
import java.util.HashMap; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
37 |
import java.util.HashSet; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
38 |
import java.util.logging.Logger; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
39 |
import java.util.Properties; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
40 |
import java.util.Scanner; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
41 |
import sun.awt.FontConfiguration; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
42 |
import sun.awt.FontDescriptor; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
43 |
import sun.awt.SunToolkit; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
44 |
import sun.font.CompositeFontDescriptor; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
45 |
import sun.font.FontManager; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
46 |
import sun.font.FontManager.FontConfigInfo; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
47 |
import sun.font.FontManager.FcCompFont; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
48 |
import sun.font.FontManager.FontConfigFont; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
49 |
import sun.java2d.SunGraphicsEnvironment; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
50 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
51 |
public class FcFontConfiguration extends FontConfiguration { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
52 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
53 |
/** Version of the cache file format understood by this code. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
54 |
* Its part of the file name so that we can rev this at |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
55 |
* any time, even in a minor JDK update. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
56 |
* It is stored as the value of the "version" property. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
57 |
* This is distinct from the version of "libfontconfig" that generated |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
58 |
* the cached results, and which is the "fcversion" property in the file. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
59 |
* {@code FontConfiguration.getVersion()} also returns a version string, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
60 |
* and has meant the version of the fontconfiguration.properties file |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
61 |
* that was read. Since this class doesn't use such files, then what |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
62 |
* that really means is whether the methods on this class return |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
63 |
* values that are compatible with the classes that do directly read |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
64 |
* from such files. It is a compatible subset of version "1". |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
65 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
66 |
private static final String fileVersion = "1"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
67 |
private String fcInfoFileName = null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
68 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
69 |
private FcCompFont[] fcCompFonts = null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
70 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
71 |
public FcFontConfiguration(SunGraphicsEnvironment environment) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
72 |
super(environment); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
73 |
init(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
74 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
75 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
76 |
/* This isn't called but is needed to satisfy super-class contract. */ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
77 |
public FcFontConfiguration(SunGraphicsEnvironment environment, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
78 |
boolean preferLocaleFonts, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
79 |
boolean preferPropFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
80 |
super(environment, preferLocaleFonts, preferPropFonts); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
81 |
init(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
82 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
83 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
84 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
85 |
public synchronized boolean init() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
86 |
if (fcCompFonts != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
87 |
return true; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
88 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
89 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
90 |
readFcInfo(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
91 |
if (fcCompFonts == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
92 |
fcCompFonts = FontManager.loadFontConfig(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
93 |
if (fcCompFonts != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
94 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
95 |
writeFcInfo(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
96 |
} catch (Exception e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
97 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
98 |
Logger logger = |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
99 |
Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
100 |
logger.warning("Exception writing fcInfo " + e); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
101 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
102 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
103 |
} else if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
104 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
105 |
logger.warning("Failed to get info from libfontconfig"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
106 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
107 |
} else { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
108 |
FontManager.populateFontConfig(fcCompFonts); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
109 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
110 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
111 |
if (fcCompFonts == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
112 |
return false; // couldn't load fontconfig. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
113 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
114 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
115 |
// NB already in a privileged block from SGE |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
116 |
String javaHome = System.getProperty("java.home"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
117 |
if (javaHome == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
118 |
throw new Error("java.home property not set"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
119 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
120 |
String javaLib = javaHome + File.separator + "lib"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
121 |
getInstalledFallbackFonts(javaLib); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
122 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
123 |
return true; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
124 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
125 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
126 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
127 |
public String getFallbackFamilyName(String fontName, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
128 |
String defaultFallback) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
129 |
// maintain compatibility with old font.properties files, which either |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
130 |
// had aliases for TimesRoman & Co. or defined mappings for them. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
131 |
String compatibilityName = getCompatibilityFamilyName(fontName); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
132 |
if (compatibilityName != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
133 |
return compatibilityName; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
134 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
135 |
return defaultFallback; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
136 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
137 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
138 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
139 |
protected String |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
140 |
getFaceNameFromComponentFontName(String componentFontName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
141 |
return null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
142 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
143 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
144 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
145 |
protected String |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
146 |
getFileNameFromComponentFontName(String componentFontName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
147 |
return null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
148 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
149 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
150 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
151 |
public String getFileNameFromPlatformName(String platformName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
152 |
/* Platform name is the file name, but rather than returning |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
153 |
* the arg, return null*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
154 |
return null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
155 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
156 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
157 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
158 |
protected Charset getDefaultFontCharset(String fontName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
159 |
return Charset.forName("ISO8859_1"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
160 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
161 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
162 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
163 |
protected String getEncoding(String awtFontName, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
164 |
String characterSubsetName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
165 |
return "default"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
166 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
167 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
168 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
169 |
protected void initReorderMap() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
170 |
reorderMap = new HashMap(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
171 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
172 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
173 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
174 |
public FontDescriptor[] getFontDescriptors(String fontName, int style) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
175 |
throw new InternalError("Not implemented"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
176 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
177 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
178 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
179 |
public int getNumberCoreFonts() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
180 |
return 1; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
181 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
182 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
183 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
184 |
public String[] getPlatformFontNames() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
185 |
HashSet<String> nameSet = new HashSet<String>(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
186 |
FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
187 |
for (int i=0; i<fcCompFonts.length; i++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
188 |
for (int j=0; j<fcCompFonts[i].allFonts.length; j++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
189 |
nameSet.add(fcCompFonts[i].allFonts[j].fontFile); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
190 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
191 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
192 |
return nameSet.toArray(new String[0]); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
193 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
194 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
195 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
196 |
public String getExtraFontPath() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
197 |
return null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
198 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
199 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
200 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
201 |
public boolean needToSearchForFile(String fileName) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
202 |
return false; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
203 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
204 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
205 |
private FontConfigFont[] getFcFontList(FcCompFont[] fcFonts, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
206 |
String fontname, int style) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
207 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
208 |
if (fontname.equals("dialog")) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
209 |
fontname = "sansserif"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
210 |
} else if (fontname.equals("dialoginput")) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
211 |
fontname = "monospaced"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
212 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
213 |
for (int i=0; i<fcFonts.length; i++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
214 |
if (fontname.equals(fcFonts[i].jdkName) && |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
215 |
style == fcFonts[i].style) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
216 |
return fcFonts[i].allFonts; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
217 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
218 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
219 |
return fcFonts[0].allFonts; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
220 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
221 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
222 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
223 |
public CompositeFontDescriptor[] get2DCompositeFontInfo() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
224 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
225 |
FcCompFont[] fcCompFonts = FontManager.loadFontConfig(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
226 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
227 |
CompositeFontDescriptor[] result = |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
228 |
new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
229 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
230 |
for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
231 |
String fontName = publicFontNames[fontIndex]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
232 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
233 |
for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
234 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
235 |
String faceName = fontName + "." + styleNames[styleIndex]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
236 |
FontConfigFont[] fcFonts = |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
237 |
getFcFontList(fcCompFonts, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
238 |
fontNames[fontIndex], styleIndex); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
239 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
240 |
int numFonts = fcFonts.length; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
241 |
// fall back fonts listed in the lib/fonts/fallback directory |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
242 |
if (installedFallbackFontFiles != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
243 |
numFonts += installedFallbackFontFiles.length; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
244 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
245 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
246 |
String[] fileNames = new String[numFonts]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
247 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
248 |
int index; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
249 |
for (index = 0; index < fcFonts.length; index++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
250 |
fileNames[index] = fcFonts[index].fontFile; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
251 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
252 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
253 |
if (installedFallbackFontFiles != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
254 |
System.arraycopy(fileNames, index, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
255 |
installedFallbackFontFiles, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
256 |
0, installedFallbackFontFiles.length); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
257 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
258 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
259 |
result[fontIndex * NUM_STYLES + styleIndex] |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
260 |
= new CompositeFontDescriptor( |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
261 |
faceName, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
262 |
1, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
263 |
null, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
264 |
fileNames, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
265 |
null, null); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
266 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
267 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
268 |
return result; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
269 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
270 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
271 |
/** |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
272 |
* Gets the OS version string from a Linux release-specific file. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
273 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
274 |
private String getVersionString(File f){ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
275 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
276 |
Scanner sc = new Scanner(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
277 |
return sc.findInLine("(\\d)+((\\.)(\\d)+)*"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
278 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
279 |
catch (Exception e){ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
280 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
281 |
return null; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
282 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
283 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
284 |
/** |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
285 |
* Sets the OS name and version from environment information. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
286 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
287 |
@Override |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
288 |
protected void setOsNameAndVersion() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
289 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
290 |
super.setOsNameAndVersion(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
291 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
292 |
if (!osName.equals("Linux")) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
293 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
294 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
295 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
296 |
File f; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
297 |
if ((f = new File("/etc/lsb-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
298 |
/* Ubuntu and (perhaps others) use only lsb-release. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
299 |
* Syntax and encoding is compatible with java properties. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
300 |
* For Ubuntu the ID is "Ubuntu". |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
301 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
302 |
Properties props = new Properties(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
303 |
props.load(new FileInputStream(f)); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
304 |
osName = props.getProperty("DISTRIB_ID"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
305 |
osVersion = props.getProperty("DISTRIB_RELEASE"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
306 |
} else if ((f = new File("/etc/redhat-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
307 |
osName = "RedHat"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
308 |
osVersion = getVersionString(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
309 |
} else if ((f = new File("/etc/SuSE-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
310 |
osName = "SuSE"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
311 |
osVersion = getVersionString(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
312 |
} else if ((f = new File("/etc/turbolinux-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
313 |
osName = "Turbo"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
314 |
osVersion = getVersionString(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
315 |
} else if ((f = new File("/etc/fedora-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
316 |
osName = "Fedora"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
317 |
osVersion = getVersionString(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
318 |
} else if ((f = new File("/etc/sun-release")).canRead()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
319 |
osName = "Sun"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
320 |
osVersion = getVersionString(f); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
321 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
322 |
} catch (Exception e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
323 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
324 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
325 |
logger.warning("Exception identifying Linux distro."); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
326 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
327 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
328 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
329 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
330 |
private File getFcInfoFile() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
331 |
if (fcInfoFileName == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
332 |
// NB need security permissions to get true IP address, and |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
333 |
// we should have those as the whole initialisation is in a |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
334 |
// doPrivileged block. But in this case no exception is thrown, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
335 |
// and it returns the loop back address, and so we end up with |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
336 |
// "localhost" |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
337 |
String hostname; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
338 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
339 |
hostname = InetAddress.getLocalHost().getHostName(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
340 |
} catch (UnknownHostException e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
341 |
hostname = "localhost"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
342 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
343 |
String userDir = System.getProperty("user.home"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
344 |
String version = System.getProperty("java.version"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
345 |
String fs = File.separator; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
346 |
String dir = userDir+fs+".java"+fs+"fonts"+fs+version; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
347 |
String lang = SunToolkit.getStartupLocale().getLanguage(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
348 |
String name = "fcinfo-"+fileVersion+"-"+hostname+"-"+ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
349 |
osName+"-"+osVersion+"-"+lang+".properties"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
350 |
fcInfoFileName = dir+fs+name; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
351 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
352 |
return new File(fcInfoFileName); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
353 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
354 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
355 |
private void writeFcInfo() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
356 |
Properties props = new Properties(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
357 |
props.setProperty("version", fileVersion); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
358 |
FontConfigInfo fcInfo = FontManager.getFontConfigInfo(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
359 |
props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion)); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
360 |
if (fcInfo.cacheDirs != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
361 |
for (int i=0;i<fcInfo.cacheDirs.length;i++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
362 |
if (fcInfo.cacheDirs[i] != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
363 |
props.setProperty("cachedir."+i, fcInfo.cacheDirs[i]); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
364 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
365 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
366 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
367 |
for (int i=0; i<fcCompFonts.length; i++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
368 |
FcCompFont fci = fcCompFonts[i]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
369 |
String styleKey = fci.jdkName+"."+fci.style; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
370 |
props.setProperty(styleKey+".length", |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
371 |
Integer.toString(fci.allFonts.length)); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
372 |
for (int j=0; j<fci.allFonts.length; j++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
373 |
props.setProperty(styleKey+"."+j+".family", |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
374 |
fci.allFonts[j].familyName); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
375 |
props.setProperty(styleKey+"."+j+".file", |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
376 |
fci.allFonts[j].fontFile); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
377 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
378 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
379 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
380 |
/* This writes into a temp file then renames when done. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
381 |
* Since the rename is an atomic action within the same |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
382 |
* directory no client will ever see a partially written file. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
383 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
384 |
File fcInfoFile = getFcInfoFile(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
385 |
File dir = fcInfoFile.getParentFile(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
386 |
dir.mkdirs(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
387 |
File tempFile = File.createTempFile("fcinfo", null, dir); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
388 |
FileOutputStream fos = new FileOutputStream(tempFile); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
389 |
props.store(fos, |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
390 |
"JDK Font Configuration Generated File: *Do Not Edit*"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
391 |
fos.close(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
392 |
boolean renamed = tempFile.renameTo(fcInfoFile); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
393 |
if (!renamed && SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
394 |
System.out.println("rename failed"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
395 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
396 |
logger.warning("Failed renaming file to "+ getFcInfoFile()); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
397 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
398 |
} catch (Exception e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
399 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
400 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
401 |
logger.warning("IOException writing to "+ getFcInfoFile()); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
402 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
403 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
404 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
405 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
406 |
/* We want to be able to use this cache instead of invoking |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
407 |
* fontconfig except when we can detect the system cache has changed. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
408 |
* But there doesn't seem to be a way to find the location of |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
409 |
* the system cache. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
410 |
*/ |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
411 |
private void readFcInfo() { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
412 |
File fcFile = getFcInfoFile(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
413 |
if (!fcFile.exists()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
414 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
415 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
416 |
Properties props = new Properties(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
417 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
418 |
FileInputStream fis = new FileInputStream(fcFile); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
419 |
props.load(fis); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
420 |
fis.close(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
421 |
} catch (IOException e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
422 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
423 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
424 |
logger.warning("IOException reading from "+fcFile.toString()); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
425 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
426 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
427 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
428 |
String version = (String)props.get("version"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
429 |
if (version == null || !version.equals(fileVersion)) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
430 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
431 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
432 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
433 |
// If there's a new, different fontconfig installed on the |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
434 |
// system, we invalidate our fontconfig file. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
435 |
String fcVersionStr = (String)props.get("fcversion"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
436 |
if (fcVersionStr != null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
437 |
int fcVersion; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
438 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
439 |
fcVersion = Integer.parseInt(fcVersionStr); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
440 |
if (fcVersion != 0 && |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
441 |
fcVersion != FontManager.getFontConfigVersion()) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
442 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
443 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
444 |
} catch (Exception e) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
445 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
446 |
Logger logger = |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
447 |
Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
448 |
logger.warning("Exception parsing version " + |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
449 |
fcVersionStr); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
450 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
451 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
452 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
453 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
454 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
455 |
// If we can locate the fontconfig cache dirs, then compare the |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
456 |
// time stamp of those with our properties file. If we are out |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
457 |
// of date then re-generate. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
458 |
long lastModified = fcFile.lastModified(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
459 |
int cacheDirIndex = 0; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
460 |
while (cacheDirIndex<4) { // should never be more than 2 anyway. |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
461 |
String dir = (String)props.get("cachedir."+cacheDirIndex); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
462 |
if (dir == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
463 |
break; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
464 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
465 |
File dirFile = new File(dir); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
466 |
if (dirFile.exists() && dirFile.lastModified() > lastModified) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
467 |
return; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
468 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
469 |
cacheDirIndex++; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
470 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
471 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
472 |
String[] names = { "sansserif", "serif", "monospaced" }; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
473 |
String[] fcnames = { "sans", "serif", "monospace" }; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
474 |
int namesLen = names.length; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
475 |
int numStyles = 4; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
476 |
FcCompFont[] fci = new FcCompFont[namesLen*numStyles]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
477 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
478 |
try { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
479 |
for (int i=0; i<namesLen; i++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
480 |
for (int s=0; s<numStyles; s++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
481 |
int index = i*numStyles+s; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
482 |
fci[index] = new FcCompFont(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
483 |
String key = names[i]+"."+s; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
484 |
fci[index].jdkName = names[i]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
485 |
fci[index].fcFamily = fcnames[i]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
486 |
fci[index].style = s; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
487 |
String lenStr = (String)props.get(key+".length"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
488 |
int nfonts = Integer.parseInt(lenStr); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
489 |
if (nfonts <= 0) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
490 |
return; // bad file |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
491 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
492 |
fci[index].allFonts = new FontConfigFont[nfonts]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
493 |
for (int f=0; f<nfonts; f++) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
494 |
fci[index].allFonts[f] = new FontConfigFont(); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
495 |
String fkey = key+"."+f+".family"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
496 |
String family = (String)props.get(fkey); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
497 |
fci[index].allFonts[f].familyName = family; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
498 |
fkey = key+"."+f+".file"; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
499 |
String file = (String)props.get(fkey); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
500 |
if (file == null) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
501 |
return; // bad file |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
502 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
503 |
fci[index].allFonts[f].fontFile = file; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
504 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
505 |
fci[index].firstFont = fci[index].allFonts[0]; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
506 |
|
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
507 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
508 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
509 |
fcCompFonts = fci; |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
510 |
} catch (Throwable t) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
511 |
if (SunGraphicsEnvironment.debugFonts) { |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
512 |
Logger logger = Logger.getLogger("sun.awt.FontConfiguration"); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
513 |
logger.warning(t.toString()); |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
514 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
515 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
516 |
} |
c3e81f0acd3d
6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
prr
parents:
diff
changeset
|
517 |
} |