This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270091

Summary: Chinese characters not displayed in table header for ordered column (Windows Look&Feel)
Product: platform Reporter: fashukiexp
Component: Outline&TreeTableAssignee: Martin Entlicher <mentlicher>
Status: NEW ---    
Severity: normal CC: fashukiexp
Priority: P3    
Version: 8.0.1   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:
Attachments: Tiny sample program reproducing the bug
Patch proposal

Description fashukiexp 2017-03-16 14:15:33 UTC
Created attachment 163862 [details]
Tiny sample program reproducing the bug

Environment: Windows 7, using the Windows Look and Feel.

Scenario:
* Use the Windows Look and Feel in your Java application (with Metal: no problem).
* Create a ETable with a column header having characters in Chinese or Japanese (or any not supported by Tahoma font).
* When running the program, click or this header to sort the column => these characters will be replaced by a square.
(small Maven project attached, with 1 class and one main method)

Root cause:
The headers of the sorted columns will be rendered in bold by the ETable, which is done in "ETableHeader::getTableCellRendererComponent". This code takes the font of the JLabel used for the rendering, and creates a similar font in bold. For that, it does not uses "Font::deriveFont(...)" (because of a 2005 bug with Apple's JVM), but uses "(new Font (label.getFont().getName(), ...)".
Under Windows it is a problem:
* the default font (used here by the JLabel) is a composite font
* from what I understand, a composite font is a list of physical fonts, which will be successively used to try to render a given character.
* this list of the physical fonts contains one that supports Chinese characters.
* label.getFont().getName() retrieves the name of the first font of the composite font, in the case of the Windows Look and Feel it is "Tahoma" (which does not support Chinese).
* so the "new Font(...)" used as a header renderer will be only "Tahoma", hence the square characters.

Does this analysis makes sense for you?

My suggestion would be to revert the patch from 2005. I don't have a Mac to my disposition to test that its works though.

Old code:
// don't use deriveFont() - see #49973 for details
label.setFont (new Font (label.getFont ().getName (), Font.BOLD, label.getFont ().getSize ()));

New code:
label.setFont(label.getFont().deriveFont(Font.BOLD));
Comment 1 fashukiexp 2017-03-16 14:43:36 UTC
Created attachment 163865 [details]
Patch proposal

Added a patch proposal (revert the fix from 2005)
Comment 2 fashukiexp 2017-03-16 14:45:31 UTC
According to a colleague, there is no Apple JVM any more, so the risk of regression for Mac should be low.
Comment 3 Martin Entlicher 2017-03-16 16:17:21 UTC
Thanks for the investigations. I agree that Apple JVM should not be an issue any more.
Thanks for the patch, according to issue #49973, this was changed at more places, we should change it back to use deriveFont() everywhere.
I'll test it on Mac to verify that it really works there.
Comment 4 fashukiexp 2017-03-17 07:13:57 UTC
Thanks.
I forgot to say that I use Oracle JVM family (1.7 and 1.8).