Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk13u-dev Public archive

Commit 8c39504

Browse files
Olga MikhaltsovaYuri Nesterenko
Olga Mikhaltsova
authored and
Yuri Nesterenko
committed
8273358: macOS Monterey does not have the font Times needed by Serif
Reviewed-by: yan Backport-of: efe3ed1e705a6f3785761e64f7187de809daa731
1 parent c96f1a0 commit 8c39504

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
@@ -223,7 +223,7 @@ public Object run() {
223223
String defaultFallback = "Lucida Grande";
224224

225225
setupLogicalFonts("Dialog", defaultFont, defaultFallback);
226-
setupLogicalFonts("Serif", "Times", "Times");
226+
setupLogicalFonts("Serif", "Times", "Times New Roman");
227227
setupLogicalFonts("SansSerif", defaultFont, defaultFallback);
228228
setupLogicalFonts("Monospaced", "Menlo", "Courier");
229229
setupLogicalFonts("DialogInput", defaultFont, defaultFallback);
@@ -249,7 +249,13 @@ protected FontFamily getFontFamilyWithExtraTry(String logicalName, String realNa
249249
family = getFontFamily(realName, fallbackName);
250250
if (family != null) return family;
251251

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

@@ -259,7 +265,12 @@ protected FontFamily getFontFamily(String realName, String fallbackName){
259265

260266
family = FontFamily.getFamily(fallbackName);
261267
if (family != null){
262-
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.");
268+
if (FontUtilities.debugFonts()) {
269+
FontUtilities.getLogger().warning(
270+
"The font \"" + realName + "\" is not available, so \"" + fallbackName +
271+
"\" has been substituted, but may have unexpected appearance or behavor. Re-enable the \"" +
272+
realName +"\" font to remove this warning.");
273+
}
263274
return family;
264275
}
265276

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)