JDK-8285308 : Win: Japanese logical fonts are drawn with wrong size
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 18,19
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: generic
  • Submitted: 2022-04-21
  • Updated: 2022-06-16
  • Resolved: 2022-05-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b24Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
openjdk version "18" 2022-03-22
OpenJDK Runtime Environment (build 18+36-2087)
OpenJDK 64-Bit Server VM (build 18+36-2087, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
AWT Text shows Japanese fonts with wrong size.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Launch the sample program on Japanese Windows.

EXPECTED VERSUS ACTUAL BEHAVIOR :
See the attached images.
errorJPFont.png: Japanese font is drawing with unexpected size.
expected.png: Both English and Japanese fonts are expected.

REPRODUCIBILITY :
This bug can be reproduced always.

ADDITIONAL INFORMATION:
This issue can be related with JEP 400, UTF-8 by Default.
When we use "-Dfile.encoding=COMAPT", this issue was gone.

---------- BEGIN SOURCE ----------
import java.awt.*;

public class fonttest {
    public static void main(String[] args) {
        Frame f = new Frame();
        TextField t = new TextField();
        t.setText("ABC\u3042\u3044ABC");
        t.setFont(new Font(Font.SERIF, Font.PLAIN, 8));
        f.add(t);
        f.setSize(200,100);
        f.setVisible(true);
    }
}
---------- END SOURCE ---------- 
Comments
Changeset: 40e99a19 Author: Phil Race <prr@openjdk.org> Date: 2022-05-19 23:41:45 +0000 URL: https://git.openjdk.java.net/jdk/commit/40e99a19f20dde0916684f93c17c51c7c5de109a
19-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8662 Date: 2022-05-11 18:25:09 +0000
11-05-2022

The wrong native encoding means the wrong font was picked up to apply to the text control. This is fixed by checking for the UTF controls and assigning the right code page as before.
11-05-2022

As the request in PR8329, assigning this to Phil.
05-05-2022

Attached the screen shot and source codes of 30-point case. - Screen shot: 30pointcase.png - Java sample: fonttest.java_v2 - C++ sample: Win32Project1.cpp_v2
27-04-2022

The bigger fonts are caused by the behavior of RichEdit component. Attached the screen shot of a native application of RichEdit, and its source code.
25-04-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8329 Date: 2022-04-21 09:14:14 +0000
22-04-2022

Adding noreg-hard tag since native encoding of the environment was the condition of the issue. It's required the primary language change of Windows.
21-04-2022