United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-5059509 REGRESSION: Font.decode() doesn't recognize PLAIN style
JDK-5059509 : REGRESSION: Font.decode() doesn't recognize PLAIN style

Details
Type:
Bug
Submit Date:
2004-06-08
Status:
Resolved
Updated Date:
2004-06-21
Project Name:
JDK
Resolved Date:
2004-06-21
Component:
client-libs
OS:
windows_xp
Sub-Component:
2d
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (b57)

Related Reports

Sub Tasks

Description

Name: pr15447			Date: 06/07/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

A DESCRIPTION OF THE PROBLEM :
This code:

  System.out.println(Font.decode("monospaced-plain-14"));

yields this output:

  java.awt.Font[family=Dialog,name=monospaced-plain,style=plain,size=14]


The problem is with these lines from the decode() method:

	    if (styleName.equals("bolditalic")) {
		fontStyle = Font.BOLD | Font.ITALIC;
	    } else if (styleName.equals("italic")) {
		fontStyle = Font.ITALIC;
	    } else if (styleName.equals("bold")) {
		fontStyle = Font.BOLD;
	    } else {
		/* this string isn't any of the expected styles, so
		 * assume its part of the font name
		 */
		styleIndex = sizeIndex;
		if (str.charAt(styleIndex-1) == sepChar) {
		    styleIndex--;
		}
	    }

If no style is specified, it defaults to plain, but if "plain" is specified,
it's treated as part of the family name.

REGRESSION.  Last worked in version tiger-beta1


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Instead, e.g., of "monospaced-plain-14", use "monospaced-14" and let the style
default to "plain".

Release Regression From : 1.4.2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Incident Review ID: 275520) 
======================================================================

                                    

Comments
EVALUATION

 Font.decode() is implementing the spec to the letter, but the
spec really should include plain as an explicitly allowable string.

The particularly compelling reason for doing that is that this
syntax was historically accepted, even if most people tended
not to explicitly specify the "plain" style.

At this point it would appear that both a spec relaxation (to
allow plain) and a code update to match on it, are needed.

###@###.### 2004-06-07
============================
                                     
2004-06-07
WORK AROUND

Instead, e.g., of "monospaced-plain-14", use "monospaced-14" and let the style
default to "plain".

###@###.### 2004-06-07
==========================
                                     
2004-06-07
SUGGESTED FIX

--- Font.java	Mon Jun  7 17:32:23 2004
***************
*** 1155,1163 ****
       * <li><em>fontname style</em>
       * <li><em>fontname</em>
       * </ul>
!      * in which <i>style</i> is one of the three 
       * case-insensitive strings:
!      * <code>"BOLD"</code>, <code>"BOLDITALIC"</code>, or
       * <code>"ITALIC"</code>, and pointsize is a positive decimal integer
       * representation of the point size.
       * For example, if you want a font that is Arial, bold, with
--- 1155,1163 ----
       * <li><em>fontname style</em>
       * <li><em>fontname</em>
       * </ul>
!      * in which <i>style</i> is one of the four 
       * case-insensitive strings:
!      * <code>"PLAIN"</code>, <code>"BOLD"</code>, <code>"BOLDITALIC"</code>, or
       * <code>"ITALIC"</code>, and pointsize is a positive decimal integer
       * representation of the point size.
       * For example, if you want a font that is Arial, bold, with
***************
*** 1255,1260 ****
--- 1255,1262 ----
  		fontStyle = Font.ITALIC;
  	    } else if (styleName.equals("bold")) {
  		fontStyle = Font.BOLD;
+ 	    } else if (styleName.equals("plain")) {
+ 		fontStyle = Font.PLAIN;
  	    } else {
  		/* this string isn't any of the expected styles, so
  		 * assume its part of the font name


###@###.### 2004-06-07
============================
                                     
2004-06-07
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger-rc

FIXED IN:
tiger-rc

INTEGRATED IN:
tiger-b57
tiger-rc


                                     
2004-06-25



Hardware and Software, Engineered to Work Together