JDK-4989955 : Font sizes in JTextPane are too large
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2004-02-06
  • Updated: 2004-03-24
  • Resolved: 2004-03-24
Related Reports
Relates :  
Description

Name: rmT116609			Date: 02/05/2004


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

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When displaying a html page the fonts used with 1.5 are larger than with 1.4.x.
Running the test case code under 1.4.2 the JTextPane is 317x78 pixels large, with 1.5 beta the same JTextPane requires 402x86 pixels because larger fonts are used.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test case under 1.4.2 and 1.5 and compare the results.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Same size on both versions of the runtime.
ACTUAL -
Different sizes depending on the runtime version.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.text.html.*;

public class Main extends JFrame
{
	public Main()
	{
		String css = "<style type=\"text/css\">\n<!--\nh1 {font-family:Verdana; font-size:14pt; font-style:normal; font-weight:bold;  }\nh2 {font-family:Verdana; font-size:10pt; font-style:normal; font-weight:normal; } \n//-->\n</style>\n";
		String html = "<html><head>"+css+"</head><body><h1>h1: ABCDEFGHIJKLMNOPQRSTUVWXYZ</h1><h2>h2: ABCDEFGHIJKLMNOPQRSTUVWXYZ</h2></body></html>";
		System.out.println(html);

		JTextPane textPane = new JTextPane();
		textPane.setEditorKit( new HTMLEditorKit() );
		textPane.setText(html);
		getContentPane().add(textPane);
		pack();
		setTitle(System.getProperty("java.vm.version")+": "+textPane.getWidth()+"x"+textPane.getHeight());
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	public static void main(String[] args)
	{
		new Main();
	}

}

---------- END SOURCE ----------
(Incident Review ID: 237470) 
======================================================================

Comments
EVALUATION Name: dsR10138 Date: 03/24/2004 In jdk 1.4.x and earlier jdk versions the point size values (pt) were treated as pixels (px). Such behavior was incorrect, see bug 4765271, and was fixed. Currently we treat pt's as 1/72 of a physical inch. Font sizes in jdk 1.5 are now correct and consistent with web browsers. I'm closing this bug as not a bug. ###@###.### 2004-03-24 ======================================================================
24-03-2004