50 logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
51 }
52 initTables();
53 }
54
55
56 public MFontConfiguration(SunFontManager fm,
57 boolean preferLocaleFonts,
58 boolean preferPropFonts) {
59 super(fm, preferLocaleFonts, preferPropFonts);
60 if (FontUtilities.debugFonts()) {
61 logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
62 }
63 initTables();
64 }
65
66 /* Needs to be kept in sync with updates in the languages used in
67 * the fontconfig files.
68 */
69 protected void initReorderMap() {
70 reorderMap = new HashMap();
71 if (osName == null) { /* null means SunOS */
72 initReorderMapForSolaris();
73 } else {
74 initReorderMapForLinux();
75 }
76 }
77
78 private void initReorderMapForSolaris() {
79 /* Don't create a no-op entry, so we can optimize this case
80 * i.e. we don't need to do anything so can avoid slower paths in
81 * the code.
82 */
83 // reorderMap.put("UTF-8", "latin-1");
84 reorderMap.put("UTF-8.hi", "devanagari"); // NB is in Lucida.
85 reorderMap.put("UTF-8.ja",
86 split("japanese-x0201,japanese-x0208,japanese-x0212"));
87 reorderMap.put("UTF-8.ko", "korean-johab");
88 reorderMap.put("UTF-8.th", "thai");
89 reorderMap.put("UTF-8.zh.TW", "chinese-big5");
90 reorderMap.put("UTF-8.zh.HK", split("chinese-big5,chinese-hkscs"));
223
224 protected String getEncoding(String awtFontName,
225 String characterSubsetName) {
226 // extract encoding field from XLFD
227 int beginIndex = 0;
228 int fieldNum = 13; // charset registry field
229 while (fieldNum-- > 0 && beginIndex >= 0) {
230 beginIndex = awtFontName.indexOf("-", beginIndex) + 1;
231 }
232 if (beginIndex == -1) {
233 return "default";
234 }
235 String xlfdEncoding = awtFontName.substring(beginIndex);
236 if (xlfdEncoding.indexOf("fontspecific") > 0) {
237 if (awtFontName.indexOf("dingbats") > 0) {
238 return "sun.awt.motif.X11Dingbats";
239 } else if (awtFontName.indexOf("symbol") > 0) {
240 return "sun.awt.Symbol";
241 }
242 }
243 String encoding = (String) encodingMap.get(xlfdEncoding);
244 if (encoding == null) {
245 encoding = "default";
246 }
247 return encoding;
248 }
249
250 protected Charset getDefaultFontCharset(String fontName) {
251 return Charset.forName("ISO8859_1");
252 }
253
254 protected String getFaceNameFromComponentFontName(String componentFontName) {
255 return null;
256 }
257
258 protected String getFileNameFromComponentFontName(String componentFontName) {
259 // for X11, component font name is XLFD
260 // if we have a file name already, just use it; otherwise let's see
261 // what the graphics environment can provide
262 String fileName = getFileNameFromPlatformName(componentFontName);
263 if (fileName != null && fileName.charAt(0) == '/' &&
271 HashSet<String> fontDirs = new HashSet<String>();
272 short[] scripts = getCoreScripts(0);
273 for (int i = 0; i< scripts.length; i++) {
274 String path = getString(table_awtfontpaths[scripts[i]]);
275 if (path != null) {
276 int start = 0;
277 int colon = path.indexOf(':');
278 while (colon >= 0) {
279 fontDirs.add(path.substring(start, colon));
280 start = colon + 1;
281 colon = path.indexOf(':', start);
282 }
283 fontDirs.add((start == 0) ? path : path.substring(start));
284 }
285 }
286 return fontDirs;
287 }
288
289 /* methods for table setup ***********************************************/
290
291 private static HashMap encodingMap = new HashMap();
292
293 private void initTables() {
294 // encodingMap maps XLFD encoding component to
295 // name of corresponding java.nio charset
296 encodingMap.put("iso8859-1", "ISO-8859-1");
297 encodingMap.put("iso8859-2", "ISO-8859-2");
298 encodingMap.put("iso8859-4", "ISO-8859-4");
299 encodingMap.put("iso8859-5", "ISO-8859-5");
300 encodingMap.put("iso8859-6", "ISO-8859-6");
301 encodingMap.put("iso8859-7", "ISO-8859-7");
302 encodingMap.put("iso8859-8", "ISO-8859-8");
303 encodingMap.put("iso8859-9", "ISO-8859-9");
304 encodingMap.put("iso8859-13", "ISO-8859-13");
305 encodingMap.put("iso8859-15", "ISO-8859-15");
306 encodingMap.put("gb2312.1980-0", "sun.awt.motif.X11GB2312");
307 if (osName == null) {
308 // use standard converter on Solaris
309 encodingMap.put("gbk-0", "GBK");
310 } else {
311 encodingMap.put("gbk-0", "sun.awt.motif.X11GBK");
|
50 logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
51 }
52 initTables();
53 }
54
55
56 public MFontConfiguration(SunFontManager fm,
57 boolean preferLocaleFonts,
58 boolean preferPropFonts) {
59 super(fm, preferLocaleFonts, preferPropFonts);
60 if (FontUtilities.debugFonts()) {
61 logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
62 }
63 initTables();
64 }
65
66 /* Needs to be kept in sync with updates in the languages used in
67 * the fontconfig files.
68 */
69 protected void initReorderMap() {
70 reorderMap = new HashMap<>();
71 if (osName == null) { /* null means SunOS */
72 initReorderMapForSolaris();
73 } else {
74 initReorderMapForLinux();
75 }
76 }
77
78 private void initReorderMapForSolaris() {
79 /* Don't create a no-op entry, so we can optimize this case
80 * i.e. we don't need to do anything so can avoid slower paths in
81 * the code.
82 */
83 // reorderMap.put("UTF-8", "latin-1");
84 reorderMap.put("UTF-8.hi", "devanagari"); // NB is in Lucida.
85 reorderMap.put("UTF-8.ja",
86 split("japanese-x0201,japanese-x0208,japanese-x0212"));
87 reorderMap.put("UTF-8.ko", "korean-johab");
88 reorderMap.put("UTF-8.th", "thai");
89 reorderMap.put("UTF-8.zh.TW", "chinese-big5");
90 reorderMap.put("UTF-8.zh.HK", split("chinese-big5,chinese-hkscs"));
223
224 protected String getEncoding(String awtFontName,
225 String characterSubsetName) {
226 // extract encoding field from XLFD
227 int beginIndex = 0;
228 int fieldNum = 13; // charset registry field
229 while (fieldNum-- > 0 && beginIndex >= 0) {
230 beginIndex = awtFontName.indexOf("-", beginIndex) + 1;
231 }
232 if (beginIndex == -1) {
233 return "default";
234 }
235 String xlfdEncoding = awtFontName.substring(beginIndex);
236 if (xlfdEncoding.indexOf("fontspecific") > 0) {
237 if (awtFontName.indexOf("dingbats") > 0) {
238 return "sun.awt.motif.X11Dingbats";
239 } else if (awtFontName.indexOf("symbol") > 0) {
240 return "sun.awt.Symbol";
241 }
242 }
243 String encoding = encodingMap.get(xlfdEncoding);
244 if (encoding == null) {
245 encoding = "default";
246 }
247 return encoding;
248 }
249
250 protected Charset getDefaultFontCharset(String fontName) {
251 return Charset.forName("ISO8859_1");
252 }
253
254 protected String getFaceNameFromComponentFontName(String componentFontName) {
255 return null;
256 }
257
258 protected String getFileNameFromComponentFontName(String componentFontName) {
259 // for X11, component font name is XLFD
260 // if we have a file name already, just use it; otherwise let's see
261 // what the graphics environment can provide
262 String fileName = getFileNameFromPlatformName(componentFontName);
263 if (fileName != null && fileName.charAt(0) == '/' &&
271 HashSet<String> fontDirs = new HashSet<String>();
272 short[] scripts = getCoreScripts(0);
273 for (int i = 0; i< scripts.length; i++) {
274 String path = getString(table_awtfontpaths[scripts[i]]);
275 if (path != null) {
276 int start = 0;
277 int colon = path.indexOf(':');
278 while (colon >= 0) {
279 fontDirs.add(path.substring(start, colon));
280 start = colon + 1;
281 colon = path.indexOf(':', start);
282 }
283 fontDirs.add((start == 0) ? path : path.substring(start));
284 }
285 }
286 return fontDirs;
287 }
288
289 /* methods for table setup ***********************************************/
290
291 private static HashMap<String, String> encodingMap = new HashMap<>();
292
293 private void initTables() {
294 // encodingMap maps XLFD encoding component to
295 // name of corresponding java.nio charset
296 encodingMap.put("iso8859-1", "ISO-8859-1");
297 encodingMap.put("iso8859-2", "ISO-8859-2");
298 encodingMap.put("iso8859-4", "ISO-8859-4");
299 encodingMap.put("iso8859-5", "ISO-8859-5");
300 encodingMap.put("iso8859-6", "ISO-8859-6");
301 encodingMap.put("iso8859-7", "ISO-8859-7");
302 encodingMap.put("iso8859-8", "ISO-8859-8");
303 encodingMap.put("iso8859-9", "ISO-8859-9");
304 encodingMap.put("iso8859-13", "ISO-8859-13");
305 encodingMap.put("iso8859-15", "ISO-8859-15");
306 encodingMap.put("gb2312.1980-0", "sun.awt.motif.X11GB2312");
307 if (osName == null) {
308 // use standard converter on Solaris
309 encodingMap.put("gbk-0", "GBK");
310 } else {
311 encodingMap.put("gbk-0", "sun.awt.motif.X11GBK");
|