On Mon, 5 Jun 2023 19:45:05 GMT, Phil Race <[email protected]> wrote:

>> On AIX, lib/fontconfig.bfc file is used to find font setting.
>> I ran SwingSet2 List demo program with AIX C locale.
>> JDK21's line spacing is larger then JDK17.
>> Screen shots are in 
>> [JDK-8307953](https://bugs.openjdk.org/browse/JDK-8307953).
>> When I used `-Dfile.encoding=COMPAT` option on AIX C locale, SwingSet2 
>> worked fine as expected.
>> 
>> This situation happens `Charset.defaultCharset()` always returns UTF-8 after 
>> JEP 400 by default.
>> `native.encoding` system property has platform's encoding/charset name.
>> If platform's charset name is not supported by Java, charset name should be 
>> `UTF-8`.
>> 
>> Additionally, following parts are changed:
>> `src/java.desktop/aix/data/fontconfig/fontconfig.propertie`s has invalid 
>> charset name.
>> For Java for AIX:
>> - Encoding name for AIX's Zh_TW locale is `big5`, charset name should be 
>> `x-IBM950` instead of `big5`.
>> - Encoding name for AIX's zh_CN locale is `IBM-eucCN`, charset name should 
>> be `x-IBM1383` instead of `x-EUCCN`.
>> 
>> In my understanding, this fix affects just for AIX platform.
>> 
>> Note:
>> macos-x64 tier1 test was failed, but I think it's not related this PR.
>
> src/java.desktop/share/classes/sun/awt/FontConfiguration.java line 142:
> 
>> 140:     private void setEncoding() {
>> 141:         encoding = 
>> Charset.forName(System.getProperty("native.encoding"),
>> 142:                                    UTF_8).name();
> 
> It is extremely misleading that this hugely impactful and wrong change is 
> slipped into a bug about AIX.
> I don't much care what you do with AIX, but revert this.
> 
> The  native.encoding is not something we want to use here.
> We had not over-looked that JEP 400 changed this and it is fine.
> You are effectively undoing JEP 400 and making fontconfig files be found and 
> use the old encoding when we really want it to match the default encoding as 
> per the fontconfig spec
> https://docs.oracle.com/en/java/javase/20/intl/font-configuration-files.html
>     Encoding - the canonical name of the default encoding, as provided by 
> java.nio.charset.Charset.defaultCharset().name().
> 
> Any env. on which line-spacing changes is because that is what is set up to 
> be in that locale+encoding  and if you want to change it, update the 
> fontconfig file for that locale+encoding.
> 
> @naotoj - please comment.

I agree with Phil here. The proposed fix would violate what's defined in the 
fontconfig spec. I would expect AIX's font config to correctly choose an 
appropriate font file for the UTF-8 environment.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13937#discussion_r1218526887

Reply via email to