JDK-4765271 : Mapping of the CSS length units is incorrect
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2002-10-18
  • Updated: 2021-02-03
  • Resolved: 2003-09-26
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
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description

Name: sv35042			Date: 10/18/2002


FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0

ADDITIONAL OPERATING SYSTEMS :
Windows Me


A DESCRIPTION OF THE PROBLEM :
When displaying a HTML page, the text is shown approx. 1.3
times smaller than in any kind of browser. E.g. The font
size is set to 12pt, but in JEditorPane it is rendered as a
9pt size font is rendered by a web browser such as Netscape
or Internet Explorer (tested on NS 4.7, 6.2; IE 5.5).

As far as I can see in the related javax.swing packages, it
seems as if inner classes FontSize and LengthUnit and
related methods in class CSS and StyleSheet cause the error.

My suspiction is that method parseCssValue in inner class
FontSize of class CSS sets a wrong length unit in line
else {
  fs.lu = new LengthUnit(value, (short)1, 1f);
}
creating a length unit 'px' by default. As well it seems as
if the mapping between relative and absolute font sizes is
wrong.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open the following HTML file and style sheet in a
JEditorPane and in a browser and compare the displays.

<html>
  <head>
    <link href="style.css" rel="stylesheet" type="text/css">

  </head>
  <body>
    <p style="font-size:8pt">
      Test 8pt
    </p>
    <p style="font-size:9pt">
      Test 9pt
    </p>
    <p style="font-size:10pt">
      Test 10pt
    </p>
    <p style="font-size:11pt">
      Test 11pt
    </p>
    <p style="font-size:12pt">
      Test 12pt
    </p>
    <p style="font-size:14pt">
      Test 14pt
    </p>
    <p style="font-size:18pt">
      Test 18pt
    </p>
    <p style="font-size:20pt">
      Test 20pt
    </p>
    <p style="font-size:24pt">
      Test 24pt
    </p>
    <p style="font-size:36pt">
      Test 36pt
    </p>
    <p style="font-size:48pt">
      Test 48pt
    </p>
  </body>
</html>

styles as in 'style.css'...

body  {font-size: 12pt;
       font-family: Arial,Sans-Serif;
       font-weight: normal;
       margin-left: 0;
       margin-right: 0;
       color: black}

p   {margin-top: 15}





EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected result was to see text in similar sizes in both the
browser and the JEditorPane. Instead, JEditorPane was
displaying smaller text than any browser.

IMPORTANT: I have seen two bug postings (partly) referring
to the same bug. Both were closed claiming this would have
been solved.
This is definitely not solved! Please try the simple test
described above.

This bug can be reproduced always.

CUSTOMER WORKAROUND :
possible work around would be to intercept method getRule in
class StyleSheet and change any font size to a bigger one
for display...
(Review ID: 153446) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b22
24-07-2004

EVALUATION Name: dsR10138 Date: 05/28/2003 The mapping of the CSS length units was incorrect. The fix is to make the mapping according to the CSS2 spec. This fix is also needed to fix the bug 4690812. ###@###.### 2003-05-28 ====================================================================== We had to revert the default behavior to the way it was before the fix. See bug 5042095 [GTK+ theming needs to happen for JEditorPane] for the details. New API was added to JEditorPane: /** + * Key for a client property used to indicate whether + * <a href="http://www.w3.org/TR/CSS21/syndata.html#length-units"> + * w3c compliant</a> length units are used for html rendering. + * <p> + * By default this is not enabled; to enable + * it set the client {@link putClientProperty property} with this name + * to <code>Boolean.TRUE</code>. + * + * @since 1.5 + */ + public static final String W3C_LENGTH_UNITS ="JEditorPane.w3cLengthUnits"; + Please use this API to enable w3c compatible length units for JEditorPane ###@###.### 2004-07-23
23-07-2004