JDK-6352143 : Classes extended from Font don't work with Fonts created with createFont()
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-11-17
  • Updated: 2010-04-02
  • Resolved: 2005-11-18
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Extended clases form Font works fine with installed fonts, but doesn't work with fonts created with createFont(...) API.

JUSTIFICATION :
Suppose you want to extend the class Font to support some interface. Public Fonts constructors works good with instaled fonts, but none works with fonts created with createFont() API.

Font has 2 constructors: "Font(String name, int style, int size)" and "Font(Map<? extends AttributedCharacterIterator.Attribute,?> attributes)".
The first constructor, works only with installed fonts. The second, takes from the Attribute (family name, size, style, ...)

An example is the class "FontUIResource". Is impossible to create an FontUIResource from Font created with a createFont(...) API.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
If you extend the Font class, you might want that create an Extended Font from other created with the comand "createFont()".

I expected a Font protected constructor like this:
protected Font(Font f)
ACTUAL -
Java 1.5 hasn't this method, but I saw that Java 1.6 'll have this constructor. Please, this constructor it's very importan for us (I work in a newspaper, and the fonts are very important for us).

Comments
EVALUATION We can't add a new constructor in 1 5. update. No API can be added in update releases. However we can do something "under the covers" so that FontUIResource(Font) can work with Font.createFont() in 1.5. In fact this is the subject of bug 6313541 so this seems to be a duplicate of that. And 6313541 is being fixed in JDK 1.5 update 7 so that the code above will work. The critical requirement for applications is that they must be able to pass the Font instance (not just its "name") to a JDK API such as FontUIResource(Font) so that JDK can reference the created Font. So in summary this is a duplicate of 6313541 which is addressed in 1.5 update 7 and JDK 6.
18-11-2005