JDK-8209435 : [macOS] Text with bold font weight rendered as normal text when TTC font is used
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: 9,openjfx11,openjfx12
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • Submitted: 2018-08-13
  • Updated: 2021-07-13
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.
Other
tbdUnresolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
Steps to reproduce:

- Compile and run the attached test cases (BoldEngText.java TamilText.java)
- or
- Load the attached "marquee-ta.html" into HelloWebView
Comments
I can conform this webrev fixes a part of the issue but (meanwhile?) there is still an issue with system fonts: when we search for "System Font Regular", the font that is returned has fullName "System Font" and is stored as such in the map. Since its fullName is different from "System Font Regular", it won't be accepted in the LogicalFont search, and a new lookup is done, resulting in the same FontResource, which is again put in the array that is bounded at 127 items, hence it will fail with the same error as before.
26-06-2021

Updated the webrev with test: http://cr.openjdk.java.net/~arajkumar/8209435/webrev.01 [~prr], Please take a look.
19-09-2018

Another simple test using 'javafx.scene.text.Font', Font font = Font.font("Helvetica", FontWeight.BOLD, 10); System.err.println(font.getName()); 9-b119: Helvetica Bold 9-b120: Helvetica
15-08-2018

[~prr], Attached a non-webview reduced test case.(TamilText.java). I also see that the problem is not just tied to complex text, it happens on english/latin text also(Refer BoldEngText.java), but with english/latin texts garbage characters are not seen, instead text is not shown bold. "BoldEngText.java" test renders the TextArea with Helvetica, bold, but the rendered text is not bold. It happens with any TTC type font whether the selected font type is not at it's 0th index.
14-08-2018

[~prr], Sure, I can write one using controls API.
14-08-2018

Arun, do you have a small (non-webview) test case for this ? I think I would like to debug such a test case.
13-08-2018

I'll wait for Phil to comment on the fix itself. As for where it should be targeted, given that this is not a recent regression (introduced in 9), it is probably better for this to go into 12 rather than getting it into 11 as a late fix.
13-08-2018

[~kcr] [~prr], Please take a look.
13-08-2018

Root cause Analysis: This is a regression of JDK-8139838 and reproducible from jdk-9+120. JDK-8139838 is not back-ported to 8u-dev, so it is not reproducible in 8u-dev. Problem happens when trying to rendering a complex text with "bold" font weight. For example the attached test(marquee-ta.html), renders a complex text(tamil: ���������������) with "bold" weight. In order to render that text, the fallback font created by Prism is "Tamil Sangam MN", which is a TTC type has both "normal" and "bold" ttfs. But the PrismFontFile.createFontResource doesn't load all the collection inside TTC which leads to creation of incorrect fallback font(regular "Tamil Sangam MN" is associated as a fallback instead "Tamil Sangam MN Bold"). When each time rendering a text(Glyph layout happens), the above step is repeated because there is no font is associated to render the complex text with bold weight, which leads to font slot to exhaust. I get the following error with -Dprism.debugfonts=true while loading marquee-ta.html in HelloWebView. or load http://tamil.thehindu.com ( ..truncated .. ) Fallback font= Tamil Sangam MN Bold slot=124 Fallback font= Tamil Sangam MN Bold slot=125 Too many font fallbacks! Fallback font= Tamil Sangam MN Bold slot=-1 Too many font fallbacks! ( ..truncated .. ) Proposed solution: PrismFontFile.PrismFontFile(String name, String filename) must load all fonts and find the matching font for fallback. webrev: http://cr.openjdk.java.net/~arajkumar/8209435/webrev
13-08-2018