< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WFontConfiguration.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -150,18 +150,22 @@
         return getFileNameFromPlatformName(componentFontName);
     }
 
     /**
      * Returns the component font name (face name plus charset) of the
-     * font that should be used for AWT text components. May return null.
+     * font that should be used for AWT text components.
      */
     public String getTextComponentFontName(String familyName, int style) {
         FontDescriptor[] fontDescriptors = getFontDescriptors(familyName, style);
         String fontName = findFontWithCharset(fontDescriptors, textInputCharset);
-        if (fontName == null) {
+        if ((fontName == null) && !textInputCharset.equals("DEFAULT_CHARSET")) {
             fontName = findFontWithCharset(fontDescriptors, "DEFAULT_CHARSET");
         }
+        if (fontName == null) {
+            fontName = (fontDescriptors.length > 0) ? fontDescriptors[0].getNativeName()
+                                                    : "Arial.ANSI_CHARSET";
+        }
         return fontName;
     }
 
     private String findFontWithCharset(FontDescriptor[] fontDescriptors, String charset) {
         String fontName = null;
< prev index next >