JDK-6992611 : java.awt.Font needs to understand OpenType fonts, or at least also TYPE2
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u22
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2008
  • CPU: x86
  • Submitted: 2010-10-16
  • Updated: 2012-03-20
  • Resolved: 2012-02-03
Related Reports
Duplicate :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
java.awt.Font currently only supports TrueType and Type1 formats. Neither of these formats are current anymore: TrueType is now OpenType-with-truetype-outlines, Type1 are an extinct format, with Adobe having moved on to OpenType-with-type2-oulines.

Given that this class is used by AWT and Swing for all typography, it is unacceptable that it does not support TYPE2, a format that has been widely used in commercial fonts for over a decade.

JUSTIFICATION :
It's 2010.

OpenType has established itself as de facto font technology after continued effort by Microsoft, Adobe and Apple, and the work payed off -- we finally have a proper unified font technology. Even LaTeX (in the form of XeTeX, LuaTeX and ConTeXt) now supports Unicode and OpenType.

Java has fallen behind. Its String class does not properly support Unicode 4 and higher and its Font class does not properly support OpenType.

At the very least, Font needs to be able to deal with OpenType fonts that use CFF/Type2 blocks. All modern Adobe fonts use this format today (in fact, Adobe had all its font updated to this format and no longer sells or supplies Type1 fonts), and for large Unicode fonts this format is preferred, as it packs its data more efficiently than TrueType fonts.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would like to see java.awt.Font have a constructor that does not need a type indicator, in addition to the currently existing constructors, that load an .otf or .ttf file and autodetect what they need to load, because that's what the opentype wrapper allows. The sfnt version, the first four bytes in the file, unambiguously indicate which font type is being loaded. This doesn't even require FreeType.

new Font(new File("myfont.otf")) should be sufficient.

Barring that, at the very least java.awt.Font needs a TYPE2 constant so that cff/type2 fonts can explicitly be loaded

new Font(Font.TYPE2, new File("myfont.otf"));

The best solution is probably to offer both, because the first is trivial (find the first 4 bytes, determine the font type, then call this(type, resource))
ACTUAL -
java.awt.Font does not support OpenType, nor TYPE2.

CUSTOMER SUBMITTED WORKAROUND :
There is no workaround. AWT and Swing rely on java.awt.Font. As long as it does not support OpenType, but only supports TrueType and the obsolete Type1, java's typographical capabilities are archaic.

Comments
EVALUATION This was in fact done for JDK 7. See 6954424
03-02-2012