Skip to content

Commit

Permalink
8285308: Win: Japanese logical fonts are drawn with wrong size
Browse files Browse the repository at this point in the history
Reviewed-by: kizune, naoto
  • Loading branch information
prrace committed May 19, 2022
1 parent 890771e commit 40e99a1
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public WFontConfiguration(SunFontManager fm,

@Override
protected void initReorderMap() {
if (encoding.equalsIgnoreCase("windows-31j")) {
if (encoding.equalsIgnoreCase("windows-31j") ||
(encoding.equalsIgnoreCase("UTF-8") &&
startupLocale.getLanguage().equals("ja")))
{
localeMap = new Hashtable<>();
/* Substitute Mincho for Gothic in this one case.
* Note the windows fontconfig files already contain the mapping:
Expand Down Expand Up @@ -173,14 +176,15 @@ private String findFontWithCharset(FontDescriptor[] fontDescriptors, String char
String componentFontName = fontDescriptors[i].getNativeName();
if (componentFontName.endsWith(charset)) {
fontName = componentFontName;
break;
}
}
return fontName;
}

private static HashMap<String, String> subsetCharsetMap = new HashMap<>();
private static HashMap<String, String> subsetEncodingMap = new HashMap<>();
private static String textInputCharset;
private static String textInputCharset = "DEFAULT_CHARSET";

private void initTables(String defaultEncoding) {
subsetCharsetMap.put("alphabetic", "ANSI_CHARSET");
Expand Down Expand Up @@ -237,8 +241,6 @@ private void initTables(String defaultEncoding) {
textInputCharset = "CHINESEBIG5_CHARSET";
} else if ("windows-1251".equals(defaultEncoding)) {
textInputCharset = "RUSSIAN_CHARSET";
} else if ("UTF-8".equals(defaultEncoding)) {
textInputCharset = "DEFAULT_CHARSET";
} else if ("windows-1253".equals(defaultEncoding)) {
textInputCharset = "GREEK_CHARSET";
} else if ("windows-1255".equals(defaultEncoding)) {
Expand All @@ -249,8 +251,25 @@ private void initTables(String defaultEncoding) {
textInputCharset = "HANGEUL_CHARSET";
} else if ("x-windows-874".equals(defaultEncoding)) {
textInputCharset = "THAI_CHARSET";
} else {
textInputCharset = "DEFAULT_CHARSET";
} else if (defaultEncoding.startsWith("UTF-8")) {
String lang = startupLocale.getLanguage();
String country = startupLocale.getCountry();
textInputCharset = switch(lang) {
case "ar" -> "ARABIC_CHARSET";
case "zh" -> {
yield switch(country) {
case "TW", "HK" -> "CHINESEBIG5_CHARSET";
default -> "GB2312_CHARSET";
};
}
case "ru" -> "RUSSIAN_CHARSET";
case "el" -> "GREEK_CHARSET";
case "iw", "he" -> "HEBREW_CHARSET";
case "ja" -> "SHIFTJIS_CHARSET";
case "ko" -> "HANGEUL_CHARSET";
case "th" -> "THAI_CHARSET";
default -> "DEFAULT_CHARSET";
};
}
}
}

1 comment on commit 40e99a1

@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.