JDK-8223834 : [macos] Font.canDisplayUpTo always returns -1 on mac OS X
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8,9,12,13
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: os_x
  • CPU: x86
  • Submitted: 2019-05-09
  • Updated: 2020-09-09
  • Resolved: 2019-05-14
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
tbdResolved
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Mac OS 10.14.4

A DESCRIPTION OF THE PROBLEM :
Font.canDisplayUpTo method always returns -1 on Mac OS X even if the font doesn't contain necessary glyphs to display the string.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Mac OS includes Herculanum system font which doesn't support cyrillic characters. Execute the following function:

System.out.println(new Font("Herculanum", Font.PLAIN, 12).canDisplayUpTo("����������������"));

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The code prints "0" since "Herculanum" font doesn't support Cyrillic characters
ACTUAL -
The method returns -1 as if all characters are supported

---------- BEGIN SOURCE ----------
System.out.println(new Font("Herculanum", Font.PLAIN, 12).canDisplayUpTo("����������������"));
---------- END SOURCE ----------

FREQUENCY : always



Comments
That is because Apple always implemented fall back support so if this font doesn't have the code points, they come from another font. So this is just an Apple behaviour.
14-05-2019

In macOS x, Font.canDisplayUpTo method always returns -1 if the font doesn't contain necessary glyphs to display the string. Checked this with reported version and could confirm the issue. Tested with Herculanum font installed on Windows and mac machine. javac -encoding UTF8 Scratch.java Results (macOS x): ========= 8: Fail 8u211: Fail 9: Fail 12: Fail 13 ea b: Fail This is a mac specific issue where it returns -1 instead of 0, on Windows result is consistant (0). To verify, run the attached test case with respective JDK version. Windows: > java Scratch 0 macOS x: $ java Scratch -1
14-05-2019