1 /*
2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
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 java.nio.charset.Charset;
29 import java.util.HashMap;
30 import sun.awt.FontConfiguration;
31 import sun.font.CompositeFontDescriptor;
32 import sun.font.SunFontManager;
33 
34 class CFontConfiguration extends FontConfiguration {
35 
36     private static CompositeFontDescriptor[] emptyDescriptors =
37         new CompositeFontDescriptor[0];
38     private static String[] emptyStrings = new String[0];
39 
CFontConfiguration(SunFontManager fm)40     public CFontConfiguration(SunFontManager fm) {
41         super(fm);
42     }
43 
CFontConfiguration(SunFontManager fm, boolean preferLocaleFonts, boolean preferPropFonts)44     public CFontConfiguration(SunFontManager fm,
45                               boolean preferLocaleFonts,
46                               boolean preferPropFonts)
47     {
48         super(fm, preferLocaleFonts, preferPropFonts);
49     }
50 
51     /*
52      * On Mac OS X we essentially ignore the font.properties file, and do
53      * it all programatically.  The intention is end users will use things
54      * like the Font Book to manage fonts. Plus our fonts automatically do
55      * unicode substitution, so a localized font is not required.
56      *
57      * The following methods therefore act like stubs and return empty values.
58      */
59 
60     @Override
getNumberCoreFonts()61     public int getNumberCoreFonts() {
62         return 0;
63     }
64 
65     @Override
getPlatformFontNames()66     public String[] getPlatformFontNames() {
67         return emptyStrings;
68     }
69 
70     @Override
get2DCompositeFontInfo()71     public CompositeFontDescriptor[] get2DCompositeFontInfo() {
72         return emptyDescriptors;
73     }
74 
75     @Override
mapFileName(String fileName)76     protected String mapFileName(String fileName) {
77         return "";
78     }
79 
80     @Override
getDefaultFontCharset(String fontName)81     protected Charset getDefaultFontCharset(String fontName) {
82         return Charset.forName("ISO8859_1");
83     }
84 
85     @Override
getEncoding(String awtFontName, String charSubsetName)86     protected String getEncoding(String awtFontName, String charSubsetName) {
87         return "default";
88     }
89 
90     @Override
getFaceNameFromComponentFontName(String compFontName)91     protected String getFaceNameFromComponentFontName(String compFontName) {
92         return compFontName;
93     }
94 
95     @Override
getFileNameFromComponentFontName(String compFontName)96     protected String getFileNameFromComponentFontName(String compFontName) {
97         return compFontName;
98     }
99 
100     @Override
getFallbackFamilyName(String fontName, String defaultFallback)101     public String getFallbackFamilyName(String fontName,
102                                         String defaultFallback)
103     {
104         return defaultFallback;
105     }
106 
107     @Override
initReorderMap()108     protected void initReorderMap() {
109         reorderMap = new HashMap<>();
110     }
111 }
112