Skip to content

Commit

Permalink
8301246: NPE in FcFontManager.getDefaultPlatformFont() on Linux witho…
Browse files Browse the repository at this point in the history
…ut installed fontconfig

Reviewed-by: serb
  • Loading branch information
Alexander Scherbatiy committed Feb 17, 2023
1 parent b3e2380 commit ca0a6be
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions jdk/src/solaris/classes/sun/awt/FcFontManager.java
Expand Up @@ -73,20 +73,22 @@ protected String[] getDefaultPlatformFont() {
getFontConfigManager().initFontConfigFonts(false);
FontConfigManager.FcCompFont[] fontConfigFonts =
getFontConfigManager().getFontConfigFonts();
for (int i=0; i<fontConfigFonts.length; i++) {
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
0 == fontConfigFonts[i].style) {
info[0] = fontConfigFonts[i].firstFont.familyName;
info[1] = fontConfigFonts[i].firstFont.fontFile;
break;
if (fontConfigFonts != null) {
for (int i = 0; i < fontConfigFonts.length; i++) {
if ("sans".equals(fontConfigFonts[i].fcFamily) &&
0 == fontConfigFonts[i].style) {
info[0] = fontConfigFonts[i].firstFont.familyName;
info[1] = fontConfigFonts[i].firstFont.fontFile;
break;
}
}
}
/* Absolute last ditch attempt in the face of fontconfig problems.
* If we didn't match, pick the first, or just make something
* up so we don't NPE.
*/
if (info[0] == null) {
if (fontConfigFonts.length > 0 &&
if (fontConfigFonts != null && fontConfigFonts.length > 0 &&
fontConfigFonts[0].firstFont.fontFile != null) {
info[0] = fontConfigFonts[0].firstFont.familyName;
info[1] = fontConfigFonts[0].firstFont.fontFile;
Expand Down

1 comment on commit ca0a6be

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.