RFR: 8285308: Win: Japanese logical fonts are drawn with wrong size [v2]
Toshio Nakamura
tnakamura at openjdk.java.net
Mon May 2 05:43:41 UTC 2022
On Fri, 29 Apr 2022 00:12:53 GMT, Phil Race <prr at openjdk.org> wrote:
>> The following diff seems to choose the right font:
>>
>> --- a/src/java.desktop/windows/data/fontconfig/fontconfig.properties
>> +++ b/src/java.desktop/windows/data/fontconfig/fontconfig.properties
>> @@ -230,7 +230,7 @@ sequence.dialog.x-MS950-HKSCS-XP=alphabetic,chinese-ms950,ch
>> inese-hkscs,dingbats
>> sequence.dialoginput.x-MS950-HKSCS-XP=alphabetic,chinese-ms950,chinese-hkscs,di
>> ngbats,symbol,chinese-ms950-extb
>>
>> sequence.allfonts.UTF-8.hi=alphabetic/1252,devanagari,dingbats,symbol
>> -sequence.allfonts.UTF-8.ja=alphabetic,japanese,dingbats,symbol
>> +sequence.allfonts.UTF-8.ja=japanese,alphabetic,dingbats,symbol
>>
>> sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
>>
>> This diff intends to choose the `japanese` set before the `alphabetic` set, in case for `ja` locale in `UTF-8` file encoding. I am not saying this is the right fix, but could be a starting point.
>
>> The following diff seems to choose the right font:
>>
>> ```
>> --- a/src/java.desktop/windows/data/fontconfig/fontconfig.properties
>> +++ b/src/java.desktop/windows/data/fontconfig/fontconfig.properties
>> @@ -230,7 +230,7 @@ sequence.dialog.x-MS950-HKSCS-XP=alphabetic,chinese-ms950,ch
>> inese-hkscs,dingbats
>> sequence.dialoginput.x-MS950-HKSCS-XP=alphabetic,chinese-ms950,chinese-hkscs,di
>> ngbats,symbol,chinese-ms950-extb
>>
>> sequence.allfonts.UTF-8.hi=alphabetic/1252,devanagari,dingbats,symbol
>> -sequence.allfonts.UTF-8.ja=alphabetic,japanese,dingbats,symbol
>> +sequence.allfonts.UTF-8.ja=japanese,alphabetic,dingbats,symbol
>>
>> sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
>> ```
>>
>> This diff intends to choose the `japanese` set before the `alphabetic` set, in case for `ja` locale in `UTF-8` file encoding. I am not saying this is the right fix, but could be a starting point.
>
> I've been looking at that exact line since I think it is what we'd use in the new default locale
> and also thinking about the "allfonts" issue we've seen with Korean.
> And which font is "japanese" in this case ?
> Maybe we want to fill out the UTF8.<lang> based locales in this file now that is the default
>
> I suspect it is a lot safer to do what Toshio is doing but I just want to understand the mechanism.
> I didn't have all the JA fonts installed on my system and I've been trying but they don't seem to have
> appeared yet, so specifically I don't have MS Mincho, so there's not much I can test yet.
> It migh
Hi @prrace
The key variable is `WFontConfiguration:textInputCharset`.
In Japanese until Java 17, `textInputCharset` was "SHIFTJIS_CHARSET", which was set in `WFontConfiguration:initTables()`.
`WFontConfiguration:getTextComponentFontName()`, which used the value, called `findFontWithCharset(,"SHIFTJIS_CHARSET")`, and it returned "MS Gothic,SHIFTJIS_CHARSET" or "MS Mincho,SHIFTJIS_CHARSET" by specified logical font name.
> sequence.serif.windows-31j=alphabetic,japanese,dingbats,symbol
In Japanese after Java 18, textInputCharset is "DEFAULT_CHARSET".
findFontWithCharset(,"DEFAULT_CHARSET") retuned null, and the first font in the target line of fontconfig was used. It's alphabetic (mapped "Times New Roman,ANSI_CHARSET" or "Arial,ANSI_CHARSET").
> sequence.allfonts.UTF-8.ja=alphabetic,japanese,dingbats,symbol
When the first one was changed to "japanese", it was used (mapped "MS Gothic,SHIFTJIS_CHARSET" or "MS Mincho,SHIFTJIS_CHARSET").
> sequence.allfonts.UTF-8.ja=japanese,alphabetic,dingbats,symbol
So, I tried to modify `textInputCharset` value only. It almost worked. However, that couldn't pick up the proper line from fontconfig file for Chinese, because it couldn't tell GBK and GB18030 without the native encoding.
That is, the following two lines have the same key.
> sequence.allfonts.UTF-8.zh.CN=alphabetic,chinese-ms936,dingbats,symbol,chinese-ms936-extb
> sequence.allfonts.UTF-8.zh.CN=alphabetic,chinese-gb18030,dingbats,symbol,chinese-gb18030-extb
-------------
PR: https://git.openjdk.java.net/jdk/pull/8329
More information about the client-libs-dev
mailing list