6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.awt.motif;
27
28 import sun.awt.FontConfiguration;
29 import sun.awt.X11FontManager;
30 import sun.font.FontUtilities;
31 import sun.font.SunFontManager;
32 import sun.util.logging.PlatformLogger;
33
34 import java.io.File;
35 import java.io.FileInputStream;
36 import java.nio.charset.Charset;
37 import java.util.HashMap;
38 import java.util.HashSet;
39 import java.util.Properties;
40 import java.util.Scanner;
41
42 public class MFontConfiguration extends FontConfiguration {
43
44 private static FontConfiguration fontConfig = null;
45 private static PlatformLogger logger;
46
218 if (compatibilityName != null) {
219 return compatibilityName;
220 }
221 return defaultFallback;
222 }
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) {
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");
312 }
313 encodingMap.put("gb18030.2000-0", "sun.awt.motif.X11GB18030_0");
314 encodingMap.put("gb18030.2000-1", "sun.awt.motif.X11GB18030_1");
315 encodingMap.put("cns11643-1", "sun.awt.motif.X11CNS11643P1");
316 encodingMap.put("cns11643-2", "sun.awt.motif.X11CNS11643P2");
317 encodingMap.put("cns11643-3", "sun.awt.motif.X11CNS11643P3");
318 encodingMap.put("big5-1", "Big5");
319 encodingMap.put("big5-0", "Big5");
320 encodingMap.put("hkscs-1", "Big5-HKSCS");
321 encodingMap.put("ansi-1251", "windows-1251");
322 encodingMap.put("koi8-r", "KOI8-R");
323 encodingMap.put("jisx0201.1976-0", "sun.awt.motif.X11JIS0201");
324 encodingMap.put("jisx0208.1983-0", "sun.awt.motif.X11JIS0208");
325 encodingMap.put("jisx0212.1990-0", "sun.awt.motif.X11JIS0212");
326 encodingMap.put("ksc5601.1987-0", "sun.awt.motif.X11KSC5601");
327 encodingMap.put("ksc5601.1992-3", "sun.awt.motif.X11Johab");
328 encodingMap.put("tis620.2533-0", "TIS-620");
329 encodingMap.put("iso10646-1", "UTF-16BE");
330 }
331
332 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.font;
27
28 import sun.awt.FontConfiguration;
29 import sun.awt.X11FontManager;
30 import sun.font.FontUtilities;
31 import sun.font.SunFontManager;
32 import sun.util.logging.PlatformLogger;
33
34 import java.io.File;
35 import java.io.FileInputStream;
36 import java.nio.charset.Charset;
37 import java.util.HashMap;
38 import java.util.HashSet;
39 import java.util.Properties;
40 import java.util.Scanner;
41
42 public class MFontConfiguration extends FontConfiguration {
43
44 private static FontConfiguration fontConfig = null;
45 private static PlatformLogger logger;
46
218 if (compatibilityName != null) {
219 return compatibilityName;
220 }
221 return defaultFallback;
222 }
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.font.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) {
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.font.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.font.X11GBK");
312 }
313 encodingMap.put("gb18030.2000-0", "sun.font.X11GB18030_0");
314 encodingMap.put("gb18030.2000-1", "sun.font.X11GB18030_1");
315 encodingMap.put("cns11643-1", "sun.font.X11CNS11643P1");
316 encodingMap.put("cns11643-2", "sun.font.X11CNS11643P2");
317 encodingMap.put("cns11643-3", "sun.font.X11CNS11643P3");
318 encodingMap.put("big5-1", "Big5");
319 encodingMap.put("big5-0", "Big5");
320 encodingMap.put("hkscs-1", "Big5-HKSCS");
321 encodingMap.put("ansi-1251", "windows-1251");
322 encodingMap.put("koi8-r", "KOI8-R");
323 encodingMap.put("jisx0201.1976-0", "JIS0201");
324 encodingMap.put("jisx0208.1983-0", "JIS0208");
325 encodingMap.put("jisx0212.1990-0", "JIS0212");
326 encodingMap.put("ksc5601.1987-0", "sun.font.X11KSC5601");
327 encodingMap.put("ksc5601.1992-3", "sun.font.X11Johab");
328 encodingMap.put("tis620.2533-0", "TIS-620");
329 encodingMap.put("iso10646-1", "UTF-16BE");
330 }
331
332 }
|