1 /*
2 * Copyright (c) 2015, 2019, 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
72 final String[] info = new String[2];
73 getFontConfigManager().initFontConfigFonts(false);
74 FontConfigManager.FcCompFont[] fontConfigFonts =
75 getFontConfigManager().getFontConfigFonts();
76 if (fontConfigFonts != null) {
77 for (int i=0; i<fontConfigFonts.length; i++) {
78 if ("sans".equals(fontConfigFonts[i].fcFamily) &&
79 0 == fontConfigFonts[i].style) {
80 info[0] = fontConfigFonts[i].firstFont.fullName;
81 info[1] = fontConfigFonts[i].firstFont.fontFile;
82 break;
83 }
84 }
85 }
86 /* Absolute last ditch attempt in the face of fontconfig problems.
87 * If we didn't match, pick the first, or just make something
88 * up so we don't NPE.
89 */
90 if (info[0] == null) {
91 if (fontConfigFonts != null && fontConfigFonts.length > 0 &&
92 fontConfigFonts[0].firstFont.fontFile != null) {
93 info[0] = fontConfigFonts[0].firstFont.fullName;
94 info[1] = fontConfigFonts[0].firstFont.fontFile;
95 } else {
96 info[0] = "Dialog";
97 info[1] = "/dialog.ttf";
98 }
99 }
100 return info;
101 }
102
103 native String getFontPathNative(boolean noType1Fonts, boolean isX11GE);
104
105 protected synchronized String getFontPath(boolean noType1Fonts) {
106 return getFontPathNative(noType1Fonts, false);
107 }
108
109 }
|
1 /*
2 * Copyright (c) 2015, 2020, 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
72 final String[] info = new String[2];
73 getFontConfigManager().initFontConfigFonts(false);
74 FontConfigManager.FcCompFont[] fontConfigFonts =
75 getFontConfigManager().getFontConfigFonts();
76 if (fontConfigFonts != null) {
77 for (int i=0; i<fontConfigFonts.length; i++) {
78 if ("sans".equals(fontConfigFonts[i].fcFamily) &&
79 0 == fontConfigFonts[i].style) {
80 info[0] = fontConfigFonts[i].firstFont.fullName;
81 info[1] = fontConfigFonts[i].firstFont.fontFile;
82 break;
83 }
84 }
85 }
86 /* Absolute last ditch attempt in the face of fontconfig problems.
87 * If we didn't match, pick the first, or just make something
88 * up so we don't NPE.
89 */
90 if (info[0] == null) {
91 if (fontConfigFonts != null && fontConfigFonts.length > 0 &&
92 fontConfigFonts[0].firstFont.fontFile != null &&
93 fontConfigFonts[0].firstFont.fullName != null) {
94 info[0] = fontConfigFonts[0].firstFont.fullName;
95 info[1] = fontConfigFonts[0].firstFont.fontFile;
96 } else {
97 info[0] = "Dialog";
98 info[1] = "/dialog.ttf";
99 }
100 }
101 return info;
102 }
103
104 native String getFontPathNative(boolean noType1Fonts, boolean isX11GE);
105
106 protected synchronized String getFontPath(boolean noType1Fonts) {
107 return getFontPathNative(noType1Fonts, false);
108 }
109
110 }
|