Skip to content

Commit efe3ed1

Browse files
committed
8273358: macOS Monterey does not have the font Times needed by Serif
Reviewed-by: kizune, aivanov
1 parent e58c12e commit efe3ed1

File tree

2 files changed

+65
-3
lines changed

2 files changed

+65
-3
lines changed

src/java.desktop/macosx/classes/sun/font/CFontManager.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public Object run() {
225225
String defaultFallback = "Lucida Grande";
226226

227227
setupLogicalFonts("Dialog", defaultFont, defaultFallback);
228-
setupLogicalFonts("Serif", "Times", "Times");
228+
setupLogicalFonts("Serif", "Times", "Times New Roman");
229229
setupLogicalFonts("SansSerif", defaultFont, defaultFallback);
230230
setupLogicalFonts("Monospaced", "Menlo", "Courier");
231231
setupLogicalFonts("DialogInput", defaultFont, defaultFallback);
@@ -251,7 +251,13 @@ protected FontFamily getFontFamilyWithExtraTry(String logicalName, String realNa
251251
family = getFontFamily(realName, fallbackName);
252252
if (family != null) return family;
253253

254-
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.");
254+
if (FontUtilities.debugFonts()) {
255+
FontUtilities.logSevere(
256+
"The fonts \"" + realName + "\" and \"" + fallbackName +
257+
"\" are not available for the Java logical font \"" + logicalName +
258+
"\", which may have unexpected appearance or behavior. Re-enable the \""+
259+
realName +"\" font to remove this warning.");
260+
}
255261
return null;
256262
}
257263

@@ -261,7 +267,12 @@ protected FontFamily getFontFamily(String realName, String fallbackName){
261267

262268
family = FontFamily.getFamily(fallbackName);
263269
if (family != null){
264-
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.");
270+
if (FontUtilities.debugFonts()) {
271+
FontUtilities.logWarning(
272+
"The font \"" + realName + "\" is not available, so \"" + fallbackName +
273+
"\" has been substituted, but may have unexpected appearance or behavor. Re-enable the \"" +
274+
realName +"\" font to remove this warning.");
275+
}
265276
return family;
266277
}
267278

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2021, 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.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8273358
27+
* @summary Verify logical fonts are as expected.
28+
* @run main/othervm LogicalFontsTest
29+
*/
30+
31+
import java.awt.Font;
32+
33+
public class LogicalFontsTest {
34+
35+
public static void main(String[] args) {
36+
test(Font.SANS_SERIF);
37+
test(Font.SERIF);
38+
test(Font.MONOSPACED);
39+
test(Font.DIALOG);
40+
test(Font.DIALOG_INPUT);
41+
}
42+
43+
static void test(String fontName) {
44+
System.out.println("name="+fontName);
45+
Font font = new Font(fontName, Font.PLAIN, 12);
46+
System.out.println("font = " + font);
47+
if (!fontName.equalsIgnoreCase(font.getFamily())) {
48+
throw new RuntimeException("Requested " + fontName + " but got " + font);
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)