Skip to content

Commit 40e99a1

Browse files
committed
8285308: Win: Japanese logical fonts are drawn with wrong size
Reviewed-by: kizune, naoto
1 parent 890771e commit 40e99a1

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public WFontConfiguration(SunFontManager fm,
5252

5353
@Override
5454
protected void initReorderMap() {
55-
if (encoding.equalsIgnoreCase("windows-31j")) {
55+
if (encoding.equalsIgnoreCase("windows-31j") ||
56+
(encoding.equalsIgnoreCase("UTF-8") &&
57+
startupLocale.getLanguage().equals("ja")))
58+
{
5659
localeMap = new Hashtable<>();
5760
/* Substitute Mincho for Gothic in this one case.
5861
* Note the windows fontconfig files already contain the mapping:
@@ -173,14 +176,15 @@ private String findFontWithCharset(FontDescriptor[] fontDescriptors, String char
173176
String componentFontName = fontDescriptors[i].getNativeName();
174177
if (componentFontName.endsWith(charset)) {
175178
fontName = componentFontName;
179+
break;
176180
}
177181
}
178182
return fontName;
179183
}
180184

181185
private static HashMap<String, String> subsetCharsetMap = new HashMap<>();
182186
private static HashMap<String, String> subsetEncodingMap = new HashMap<>();
183-
private static String textInputCharset;
187+
private static String textInputCharset = "DEFAULT_CHARSET";
184188

185189
private void initTables(String defaultEncoding) {
186190
subsetCharsetMap.put("alphabetic", "ANSI_CHARSET");
@@ -237,8 +241,6 @@ private void initTables(String defaultEncoding) {
237241
textInputCharset = "CHINESEBIG5_CHARSET";
238242
} else if ("windows-1251".equals(defaultEncoding)) {
239243
textInputCharset = "RUSSIAN_CHARSET";
240-
} else if ("UTF-8".equals(defaultEncoding)) {
241-
textInputCharset = "DEFAULT_CHARSET";
242244
} else if ("windows-1253".equals(defaultEncoding)) {
243245
textInputCharset = "GREEK_CHARSET";
244246
} else if ("windows-1255".equals(defaultEncoding)) {
@@ -249,8 +251,25 @@ private void initTables(String defaultEncoding) {
249251
textInputCharset = "HANGEUL_CHARSET";
250252
} else if ("x-windows-874".equals(defaultEncoding)) {
251253
textInputCharset = "THAI_CHARSET";
252-
} else {
253-
textInputCharset = "DEFAULT_CHARSET";
254+
} else if (defaultEncoding.startsWith("UTF-8")) {
255+
String lang = startupLocale.getLanguage();
256+
String country = startupLocale.getCountry();
257+
textInputCharset = switch(lang) {
258+
case "ar" -> "ARABIC_CHARSET";
259+
case "zh" -> {
260+
yield switch(country) {
261+
case "TW", "HK" -> "CHINESEBIG5_CHARSET";
262+
default -> "GB2312_CHARSET";
263+
};
264+
}
265+
case "ru" -> "RUSSIAN_CHARSET";
266+
case "el" -> "GREEK_CHARSET";
267+
case "iw", "he" -> "HEBREW_CHARSET";
268+
case "ja" -> "SHIFTJIS_CHARSET";
269+
case "ko" -> "HANGEUL_CHARSET";
270+
case "th" -> "THAI_CHARSET";
271+
default -> "DEFAULT_CHARSET";
272+
};
254273
}
255274
}
256275
}

0 commit comments

Comments
 (0)