JDK-8067487 : Selecting fonts based on family and style needs improvement
  • Type: Enhancement
  • Component: client-libs
  • Affected Version: 8u25,9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-11-13
  • Updated: 2014-12-15
  • Resolved: 2014-12-15
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :
Not sure if this is a bug or an RFE, since the spec for Font(family, style, size) says:

When a font family name is specified, the style argument is used to select the most appropriate face from the family.

and clearly there are cases where the selection is not the most appropriate.

Here are some examples (on OS X):

American Typewriter:
AmericanTypewriter
AmericanTypewriter-Bold
AmericanTypewriter-Condensed
AmericanTypewriter-CondensedBold         [Bold]
AmericanTypewriter-CondensedLight        [Plain]
AmericanTypewriter-Light



Apple SD Gothic Neo:
AppleSDGothicNeo-Bold
AppleSDGothicNeo-ExtraBold               [Bold]
AppleSDGothicNeo-Heavy                   [Plain]
AppleSDGothicNeo-Light
AppleSDGothicNeo-Medium
AppleSDGothicNeo-Regular
AppleSDGothicNeo-SemiBold
AppleSDGothicNeo-Thin
AppleSDGothicNeo-UltraLight


Avenir:
Avenir-Black
Avenir-BlackOblique
Avenir-Book
Avenir-BookOblique
Avenir-Heavy                             [Plain] [Bold]
Avenir-HeavyOblique
Avenir-Light
Avenir-LightOblique
Avenir-Medium
Avenir-MediumOblique
Avenir-Oblique
Avenir-Roman


Avenir Next:
AvenirNext-Bold                          [Bold]
AvenirNext-BoldItalic
AvenirNext-DemiBold
AvenirNext-DemiBoldItalic
AvenirNext-Heavy                         [Plain]
AvenirNext-HeavyItalic
AvenirNext-Italic
AvenirNext-Medium
AvenirNext-MediumItalic
AvenirNext-Regular
AvenirNext-UltraLight
AvenirNext-UltraLightItalic


A couple of obvious observations: Regular should be preferred for PLAIN and a simple Bold should be preferred for BOLD over things like DemiBold, ExtraBold, ...

JUSTIFICATION :
The exact set of faces in a family may be system dependent. Applications should get a reasonable font face when they specify a family name or use deriveFont().

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Additional font naming conventions should be recognized and taken into account.
ACTUAL -
It seems that any font without a recognized style is considered PLAIN and the choice among those is random. Similarly, when more than one font is recognized as BOLD or ITALIC, the choice among them is random.

CUSTOMER SUBMITTED WORKAROUND :
The only practical workaround is to use font face names rather than family names.


Comments
I note that the submitter is citing OS X examples. I think it likely that in large part s/he is running into 8064833 : [macosx] Native font lookup uses family+style, not full name/postscript name for which I just proposed a fix which does try to pick the 'closest' set of fonts to what would be the base family by examining width and weight. So I will close this out as a duplicate, although there is an RFE element to this since you might want to be able to explicitly specify preferred width and weight to the lookup process - and also find out these attributes of a font.
15-12-2014

Migrated so PM will get chance to evaluate if this is an area we would consider to imporve for later version
15-12-2014