author | serb |
Fri, 03 Apr 2015 17:17:36 +0300 | |
changeset 29922 | 7b9c1e1532cf |
parent 29730 | eab36f5cc7ac |
child 31653 | d88ff422c7fb |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
12047 | 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.awt.*; |
|
29 |
import java.io.File; |
|
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
30 |
import java.security.AccessController; |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
31 |
import java.security.PrivilegedAction; |
12047 | 32 |
import java.util.ArrayList; |
33 |
import java.util.HashMap; |
|
34 |
import java.util.Hashtable; |
|
35 |
import java.util.Locale; |
|
36 |
import java.util.TreeMap; |
|
37 |
import java.util.Vector; |
|
38 |
||
39 |
import javax.swing.plaf.FontUIResource; |
|
40 |
||
41 |
import sun.awt.FontConfiguration; |
|
13767
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
42 |
import sun.awt.HeadlessToolkit; |
24520
e8afd90fcb69
8035169: Move ThreadGroupUtils from the sun.misc package
pchelko
parents:
23900
diff
changeset
|
43 |
import sun.awt.util.ThreadGroupUtils; |
12047 | 44 |
import sun.lwawt.macosx.*; |
29922 | 45 |
import sun.misc.InnocuousThread; |
12047 | 46 |
|
26007
dba8f49653ce
8035165: Expose internal representation in sun.awt.X11
serb
parents:
24520
diff
changeset
|
47 |
public final class CFontManager extends SunFontManager { |
12047 | 48 |
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>(); |
49 |
||
50 |
@Override |
|
51 |
protected FontConfiguration createFontConfiguration() { |
|
52 |
FontConfiguration fc = new CFontConfiguration(this); |
|
53 |
fc.init(); |
|
54 |
return fc; |
|
55 |
} |
|
56 |
||
57 |
@Override |
|
58 |
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts, |
|
59 |
boolean preferPropFonts) |
|
60 |
{ |
|
61 |
return new CFontConfiguration(this, preferLocaleFonts, preferPropFonts); |
|
62 |
} |
|
63 |
||
64 |
/* |
|
65 |
* Returns an array of two strings. The first element is the |
|
66 |
* name of the font. The second element is the file name. |
|
67 |
*/ |
|
68 |
@Override |
|
26007
dba8f49653ce
8035165: Expose internal representation in sun.awt.X11
serb
parents:
24520
diff
changeset
|
69 |
protected String[] getDefaultPlatformFont() { |
dba8f49653ce
8035165: Expose internal representation in sun.awt.X11
serb
parents:
24520
diff
changeset
|
70 |
return new String[]{"Lucida Grande", |
dba8f49653ce
8035165: Expose internal representation in sun.awt.X11
serb
parents:
24520
diff
changeset
|
71 |
"/System/Library/Fonts/LucidaGrande.ttc"}; |
12047 | 72 |
} |
73 |
||
74 |
// This is a way to register any kind of Font2D, not just files and composites. |
|
75 |
public static Font2D[] getGenericFonts() { |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
76 |
return genericFonts.values().toArray(new Font2D[0]); |
12047 | 77 |
} |
78 |
||
79 |
public Font2D registerGenericFont(Font2D f) |
|
80 |
{ |
|
81 |
return registerGenericFont(f, false); |
|
82 |
} |
|
83 |
public Font2D registerGenericFont(Font2D f, boolean logicalFont) |
|
84 |
{ |
|
85 |
int rank = 4; |
|
86 |
||
87 |
String fontName = f.fullName; |
|
88 |
String familyName = f.familyName; |
|
89 |
||
90 |
if (fontName == null || "".equals(fontName)) { |
|
91 |
return null; |
|
92 |
} |
|
93 |
||
94 |
// logical fonts always need to be added to the family |
|
95 |
// plus they never need to be added to the generic font list |
|
96 |
// or the fullNameToFont table since they are covers for |
|
97 |
// already existing fonts in this list |
|
98 |
if (logicalFont || !genericFonts.containsKey(fontName)) { |
|
99 |
if (FontUtilities.debugFonts()) { |
|
100 |
FontUtilities.getLogger().info("Add to Family "+familyName + |
|
101 |
", Font " + fontName + " rank="+rank); |
|
102 |
} |
|
103 |
FontFamily family = FontFamily.getFamily(familyName); |
|
104 |
if (family == null) { |
|
105 |
family = new FontFamily(familyName, false, rank); |
|
106 |
family.setFont(f, f.style); |
|
107 |
} else if (family.getRank() >= rank) { |
|
108 |
family.setFont(f, f.style); |
|
109 |
} |
|
110 |
if (!logicalFont) |
|
111 |
{ |
|
112 |
genericFonts.put(fontName, f); |
|
113 |
fullNameToFont.put(fontName.toLowerCase(Locale.ENGLISH), f); |
|
114 |
} |
|
115 |
return f; |
|
116 |
} else { |
|
22584
eed64ee05369
8032733: Fix cast lint warnings in client libraries
darcy
parents:
21278
diff
changeset
|
117 |
return genericFonts.get(fontName); |
12047 | 118 |
} |
119 |
} |
|
120 |
||
121 |
@Override |
|
122 |
public Font2D[] getRegisteredFonts() { |
|
123 |
Font2D[] regFonts = super.getRegisteredFonts(); |
|
124 |
||
125 |
// Add in the Mac OS X native fonts |
|
126 |
Font2D[] genericFonts = getGenericFonts(); |
|
127 |
Font2D[] allFonts = new Font2D[regFonts.length+genericFonts.length]; |
|
128 |
System.arraycopy(regFonts, 0, allFonts, 0, regFonts.length); |
|
129 |
System.arraycopy(genericFonts, 0, allFonts, regFonts.length, genericFonts.length); |
|
130 |
||
131 |
return allFonts; |
|
132 |
} |
|
133 |
||
134 |
@Override |
|
135 |
protected void addNativeFontFamilyNames(TreeMap<String, String> familyNames, Locale requestedLocale) { |
|
136 |
Font2D[] genericfonts = getGenericFonts(); |
|
137 |
for (int i=0; i < genericfonts.length; i++) { |
|
138 |
if (!(genericfonts[i] instanceof NativeFont)) { |
|
139 |
String name = genericfonts[i].getFamilyName(requestedLocale); |
|
140 |
familyNames.put(name.toLowerCase(requestedLocale), name); |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
||
145 |
@Override |
|
146 |
public Font2D createFont2D(File fontFile, int fontFormat, boolean isCopy, CreatedFontTracker tracker) throws FontFormatException { |
|
147 |
||
148 |
String fontFilePath = fontFile.getPath(); |
|
149 |
Font2D font2D = null; |
|
150 |
final File fFile = fontFile; |
|
151 |
final CreatedFontTracker _tracker = tracker; |
|
152 |
try { |
|
153 |
switch (fontFormat) { |
|
154 |
case Font.TRUETYPE_FONT: |
|
155 |
font2D = new TrueTypeFont(fontFilePath, null, 0, true); |
|
156 |
break; |
|
157 |
case Font.TYPE1_FONT: |
|
158 |
font2D = new Type1Font(fontFilePath, null, isCopy); |
|
159 |
break; |
|
160 |
default: |
|
161 |
throw new FontFormatException("Unrecognised Font Format"); |
|
162 |
} |
|
163 |
} catch (FontFormatException e) { |
|
164 |
if (isCopy) { |
|
165 |
java.security.AccessController.doPrivileged( |
|
166 |
new java.security.PrivilegedAction<Object>() { |
|
167 |
public Object run() { |
|
168 |
if (_tracker != null) { |
|
169 |
_tracker.subBytes((int)fFile.length()); |
|
170 |
} |
|
171 |
fFile.delete(); |
|
172 |
return null; |
|
173 |
} |
|
174 |
}); |
|
175 |
} |
|
176 |
throw(e); |
|
177 |
} |
|
178 |
if (isCopy) { |
|
179 |
FileFont.setFileToRemove(font2D, fontFile, tracker); |
|
180 |
synchronized (FontManager.class) { |
|
181 |
||
182 |
if (tmpFontFiles == null) { |
|
183 |
tmpFontFiles = new Vector<File>(); |
|
184 |
} |
|
185 |
tmpFontFiles.add(fontFile); |
|
186 |
||
187 |
if (fileCloser == null) { |
|
188 |
final Runnable fileCloserRunnable = new Runnable() { |
|
189 |
public void run() { |
|
190 |
java.security.AccessController.doPrivileged( |
|
191 |
new java.security.PrivilegedAction<Object>() { |
|
192 |
public Object run() { |
|
193 |
||
194 |
for (int i=0;i<CHANNELPOOLSIZE;i++) { |
|
195 |
if (fontFileCache[i] != null) { |
|
196 |
try { |
|
197 |
fontFileCache[i].close(); |
|
198 |
} catch (Exception e) {} |
|
199 |
} |
|
200 |
} |
|
201 |
if (tmpFontFiles != null) { |
|
202 |
File[] files = new File[tmpFontFiles.size()]; |
|
203 |
files = tmpFontFiles.toArray(files); |
|
204 |
for (int f=0; f<files.length;f++) { |
|
205 |
try { |
|
206 |
files[f].delete(); |
|
207 |
} catch (Exception e) {} |
|
208 |
} |
|
209 |
} |
|
210 |
return null; |
|
211 |
} |
|
212 |
}); |
|
213 |
} |
|
214 |
}; |
|
29922 | 215 |
AccessController.doPrivileged((PrivilegedAction<Void>) () -> { |
216 |
if (System.getSecurityManager() == null) { |
|
217 |
/* The thread must be a member of a thread group |
|
218 |
* which will not get GCed before VM exit. |
|
219 |
* Make its parent the top-level thread group. |
|
220 |
*/ |
|
221 |
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup(); |
|
222 |
fileCloser = new Thread(rootTG, fileCloserRunnable); |
|
223 |
} else { |
|
224 |
/* InnocuousThread is a member of a correct TG by default */ |
|
225 |
fileCloser = new InnocuousThread(fileCloserRunnable); |
|
226 |
} |
|
23900
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
227 |
fileCloser.setContextClassLoader(null); |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
228 |
Runtime.getRuntime().addShutdownHook(fileCloser); |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
229 |
return null; |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
230 |
} |
fd98305f0d19
8031477: [macosx] Loading AWT native library fails
pchelko
parents:
22584
diff
changeset
|
231 |
); |
12047 | 232 |
} |
233 |
} |
|
234 |
} |
|
235 |
return font2D; |
|
236 |
} |
|
237 |
||
238 |
protected void registerFontsInDir(String dirName, boolean useJavaRasterizer, int fontRank, boolean defer, boolean resolveSymLinks) { |
|
239 |
loadNativeDirFonts(dirName); |
|
240 |
super.registerFontsInDir(dirName, useJavaRasterizer, fontRank, defer, resolveSymLinks); |
|
241 |
} |
|
242 |
||
243 |
private native void loadNativeDirFonts(String dirName); |
|
244 |
private native void loadNativeFonts(); |
|
245 |
||
246 |
void registerFont(String fontName, String fontFamilyName) { |
|
247 |
final CFont font = new CFont(fontName, fontFamilyName); |
|
248 |
||
249 |
registerGenericFont(font); |
|
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
250 |
} |
12047 | 251 |
|
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
252 |
void registerItalicDerived() { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
253 |
FontFamily[] famArr = FontFamily.getAllFontFamilies(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
254 |
for (int i=0; i<famArr.length; i++) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
255 |
FontFamily family = famArr[i]; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
256 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
257 |
Font2D f2dPlain = family.getFont(Font.PLAIN); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
258 |
if (f2dPlain != null && !(f2dPlain instanceof CFont)) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
259 |
Font2D f2dBold = family.getFont(Font.BOLD); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
260 |
if (f2dBold != null && !(f2dBold instanceof CFont)) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
261 |
Font2D f2dItalic = family.getFont(Font.ITALIC); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
262 |
if (f2dItalic != null && !(f2dItalic instanceof CFont)) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
263 |
Font2D f2dBoldItalic = family.getFont(Font.BOLD|Font.ITALIC); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
264 |
if (f2dBoldItalic != null && !(f2dBoldItalic instanceof CFont)) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
265 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
266 |
CFont plain = (CFont)f2dPlain; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
267 |
CFont bold = (CFont)f2dBold; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
268 |
CFont italic = (CFont)f2dItalic; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
269 |
CFont boldItalic = (CFont)f2dBoldItalic; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
270 |
|
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
271 |
if (bold == null) bold = plain; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
272 |
if (plain == null && bold == null) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
273 |
if (italic != null && boldItalic != null) continue; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
274 |
if (plain != null && italic == null) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
275 |
registerGenericFont(plain.createItalicVariant(), true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
276 |
} |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
277 |
if (bold != null && boldItalic == null) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
278 |
registerGenericFont(bold.createItalicVariant(), true); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
279 |
} |
12047 | 280 |
} |
281 |
} |
|
282 |
||
283 |
Object waitForFontsToBeLoaded = new Object(); |
|
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
284 |
private boolean loadedAllFonts = false; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
285 |
|
12047 | 286 |
public void loadFonts() |
287 |
{ |
|
288 |
synchronized(waitForFontsToBeLoaded) |
|
289 |
{ |
|
290 |
super.loadFonts(); |
|
291 |
java.security.AccessController.doPrivileged( |
|
292 |
new java.security.PrivilegedAction<Object>() { |
|
293 |
public Object run() { |
|
28996
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
294 |
if (!loadedAllFonts) { |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
295 |
loadNativeFonts(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
296 |
registerItalicDerived(); |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
297 |
loadedAllFonts = true; |
4d9228fac01a
8064833: [macosx] Native font lookup uses family+style, not full name/postscript name
prr
parents:
26037
diff
changeset
|
298 |
} |
12047 | 299 |
return null; |
300 |
} |
|
301 |
} |
|
302 |
); |
|
303 |
||
304 |
String defaultFont = "Lucida Grande"; |
|
305 |
String defaultFallback = "Lucida Sans"; |
|
306 |
||
307 |
setupLogicalFonts("Dialog", defaultFont, defaultFallback); |
|
308 |
setupLogicalFonts("Serif", "Times", "Lucida Bright"); |
|
309 |
setupLogicalFonts("SansSerif", defaultFont, defaultFallback); |
|
310 |
setupLogicalFonts("Monospaced", "Menlo", "Lucida Sans Typewriter"); |
|
311 |
setupLogicalFonts("DialogInput", defaultFont, defaultFallback); |
|
312 |
} |
|
313 |
} |
|
314 |
||
315 |
protected void setupLogicalFonts(String logicalName, String realName, String fallbackName) { |
|
316 |
FontFamily realFamily = getFontFamilyWithExtraTry(logicalName, realName, fallbackName); |
|
317 |
||
318 |
cloneStyledFont(realFamily, logicalName, Font.PLAIN); |
|
319 |
cloneStyledFont(realFamily, logicalName, Font.BOLD); |
|
320 |
cloneStyledFont(realFamily, logicalName, Font.ITALIC); |
|
321 |
cloneStyledFont(realFamily, logicalName, Font.BOLD | Font.ITALIC); |
|
322 |
} |
|
323 |
||
324 |
protected FontFamily getFontFamilyWithExtraTry(String logicalName, String realName, String fallbackName){ |
|
325 |
FontFamily family = getFontFamily(realName, fallbackName); |
|
326 |
if (family != null) return family; |
|
327 |
||
328 |
// at this point, we recognize that we probably needed a fallback font |
|
329 |
super.loadFonts(); |
|
330 |
||
331 |
family = getFontFamily(realName, fallbackName); |
|
332 |
if (family != null) return family; |
|
333 |
||
334 |
System.err.println("Warning: the fonts \"" + realName + "\" and \"" + fallbackName + "\" are not available for the Java logical font \"" + logicalName + "\", which may have unexpected appearance or behavior. Re-enable the \""+ realName +"\" font to remove this warning."); |
|
335 |
return null; |
|
336 |
} |
|
337 |
||
338 |
protected FontFamily getFontFamily(String realName, String fallbackName){ |
|
339 |
FontFamily family = FontFamily.getFamily(realName); |
|
340 |
if (family != null) return family; |
|
341 |
||
342 |
family = FontFamily.getFamily(fallbackName); |
|
343 |
if (family != null){ |
|
344 |
System.err.println("Warning: the font \"" + realName + "\" is not available, so \"" + fallbackName + "\" has been substituted, but may have unexpected appearance or behavor. Re-enable the \""+ realName +"\" font to remove this warning."); |
|
345 |
return family; |
|
346 |
} |
|
347 |
||
348 |
return null; |
|
349 |
} |
|
350 |
||
351 |
protected boolean cloneStyledFont(FontFamily realFamily, String logicalFamilyName, int style) { |
|
352 |
if (realFamily == null) return false; |
|
353 |
||
354 |
Font2D realFont = realFamily.getFontWithExactStyleMatch(style); |
|
355 |
if (realFont == null || !(realFont instanceof CFont)) return false; |
|
356 |
||
357 |
CFont newFont = new CFont((CFont)realFont, logicalFamilyName); |
|
358 |
registerGenericFont(newFont, true); |
|
359 |
||
360 |
return true; |
|
361 |
} |
|
362 |
||
363 |
@Override |
|
364 |
public String getFontPath(boolean noType1Fonts) { |
|
21278 | 365 |
// In the case of the Cocoa toolkit, since we go through NSFont, we don't need to register /Library/Fonts |
13767
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
366 |
Toolkit tk = Toolkit.getDefaultToolkit(); |
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
367 |
if (tk instanceof HeadlessToolkit) { |
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
368 |
tk = ((HeadlessToolkit)tk).getUnderlyingToolkit(); |
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
369 |
} |
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
370 |
if (tk instanceof LWCToolkit) { |
12047 | 371 |
return ""; |
372 |
} |
|
13767
5ea857776c3f
7181199: [macosx] Startup is much slower in headless mode for apps using Fonts
bae
parents:
12047
diff
changeset
|
373 |
|
12047 | 374 |
// X11 case |
375 |
return "/Library/Fonts"; |
|
376 |
} |
|
377 |
||
378 |
@Override |
|
379 |
protected FontUIResource getFontConfigFUIR( |
|
380 |
String family, int style, int size) |
|
381 |
{ |
|
382 |
String mappedName = FontUtilities.mapFcName(family); |
|
383 |
if (mappedName == null) { |
|
384 |
mappedName = "sansserif"; |
|
385 |
} |
|
386 |
return new FontUIResource(mappedName, style, size); |
|
387 |
} |
|
388 |
||
389 |
// Only implemented on Windows |
|
390 |
@Override |
|
391 |
protected void populateFontFileNameMap(HashMap<String, String> fontToFileMap, HashMap<String, String> fontToFamilyNameMap, |
|
392 |
HashMap<String, ArrayList<String>> familyToFontListMap, Locale locale) {} |
|
393 |
} |