-
Bug
-
Resolution: Fixed
-
P3
-
17, 18, 19, 20
-
b06
-
b16
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8333809 | 17.0.13 | Martin Doerr | P3 | Resolved | Fixed | b01 |
ADDITIONAL SYSTEM INFORMATION :
Windows 10, Java 17.0.4.1
A DESCRIPTION OF THE PROBLEM :
All fonts are displayed using the same font size despite having different absolute font-size definition in css file.
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Load a html file with an external css file (containing font-size specifications) in JEditorPane.
The font size specifications in the css are ignored.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Different font sizes should be rendered differently in the GUI.
ACTUAL -
All font sizes are equal. The same Test with JDK 11 is working fine.
---------- BEGIN SOURCE ----------
CSSTest.java
++++++++++++++++
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.text.Document;
@SuppressWarnings ("serial")
public class CSSTest
extends JFrame
{
private final JEditorPane editor;
public CSSTest (String url)
{
super("External CSS Test");
Container contentPane = super.getContentPane();
editor = new JEditorPane();
editor.setEditable(false);
editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
editor.putClientProperty(JEditorPane.W3C_LENGTH_UNITS, false);
contentPane.add(new JScrollPane(editor), BorderLayout.CENTER);
editor.getActionMap().put("Reload-Page", new AbstractAction("Reload-Page")
{
@Override
public void actionPerformed (final ActionEvent evt)
{
loadPage(url);
}
});
editor.getActionMap().put("Debug-Page", new AbstractAction("Debug-Page")
{
@Override
public void actionPerformed (final ActionEvent evt)
{
debugPage();
}
});
KeyStroke ctrlR = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK);
editor.getInputMap().put(ctrlR, "Reload-Page");
KeyStroke ctrlShiftD = KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
editor.getInputMap().put(ctrlShiftD, "Debug-Page");
loadPage(url);
}
void loadPage (String url)
{
try
{
editor.setContentType("text/html");
editor.getDocument().putProperty(Document.StreamDescriptionProperty, null); // Reload
editor.setPage(url);
}
catch (IOException e)
{
editor.setContentType("text/plain");
editor.setText(e.toString());
editor.setForeground(Color.red);
}
}
void debugPage ()
{
System.out.println(editor.getDocument().getDefaultRootElement());
System.out.println(editor.getUI().getRootView(editor));
}
public static void main (final String[] args)
throws Exception
{
SwingUtilities.invokeLater( () ->
{
CSSTest frame = new CSSTest(args[0]);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 800);
frame.setLocation(0, 0);
frame.setVisible(true);
});
}
}
++++++++++++++++
external-css-test.html
++++++++++++++++
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="external-css.css">
</head>
<body>
<p class="help_title">Help Title</p>
<hr>
<p class="help_subtitle">Help Subtitle</p>
<p class="help_text">Help text text</p>
<p class="help_id">Help Id<br>
<hr>
<p class="copyright_text">Coyright</p>
<br></p>
</body>
</html>
++++++++++++++++
external-css.css
++++++++++++++++
p {margin:0; padding:0;}
.help_title
{
font-family: Arial;
font-size: 24pt;
font-weight: bold;
margin-top:16;
margin-left:10;
margin-bottom:16;
}
.help_subtitle
{
font-family: Tahoma;
font-size: 14pt;
font-weight: bold;
margin-top:5;
margin-left:20;
margin-bottom:5;
}
.help_text
{
font-family: Tahoma;
font-size: 12pt;
margin-bottom:15;
margin-left:20;
}
.help_id
{
font-family: Tahoma;
font-size: 9pt;
margin-left:20;
}
.copyright_text
{
font-family: Tahoma;
font-size: 9pt;
margin-left:10;
}
++++++++++++++++
---------- END SOURCE ----------
FREQUENCY : always
Windows 10, Java 17.0.4.1
A DESCRIPTION OF THE PROBLEM :
All fonts are displayed using the same font size despite having different absolute font-size definition in css file.
REGRESSION : Last worked in version 11
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Load a html file with an external css file (containing font-size specifications) in JEditorPane.
The font size specifications in the css are ignored.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Different font sizes should be rendered differently in the GUI.
ACTUAL -
All font sizes are equal. The same Test with JDK 11 is working fine.
---------- BEGIN SOURCE ----------
CSSTest.java
++++++++++++++++
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.text.Document;
@SuppressWarnings ("serial")
public class CSSTest
extends JFrame
{
private final JEditorPane editor;
public CSSTest (String url)
{
super("External CSS Test");
Container contentPane = super.getContentPane();
editor = new JEditorPane();
editor.setEditable(false);
editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
editor.putClientProperty(JEditorPane.W3C_LENGTH_UNITS, false);
contentPane.add(new JScrollPane(editor), BorderLayout.CENTER);
editor.getActionMap().put("Reload-Page", new AbstractAction("Reload-Page")
{
@Override
public void actionPerformed (final ActionEvent evt)
{
loadPage(url);
}
});
editor.getActionMap().put("Debug-Page", new AbstractAction("Debug-Page")
{
@Override
public void actionPerformed (final ActionEvent evt)
{
debugPage();
}
});
KeyStroke ctrlR = KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.CTRL_DOWN_MASK);
editor.getInputMap().put(ctrlR, "Reload-Page");
KeyStroke ctrlShiftD = KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
editor.getInputMap().put(ctrlShiftD, "Debug-Page");
loadPage(url);
}
void loadPage (String url)
{
try
{
editor.setContentType("text/html");
editor.getDocument().putProperty(Document.StreamDescriptionProperty, null); // Reload
editor.setPage(url);
}
catch (IOException e)
{
editor.setContentType("text/plain");
editor.setText(e.toString());
editor.setForeground(Color.red);
}
}
void debugPage ()
{
System.out.println(editor.getDocument().getDefaultRootElement());
System.out.println(editor.getUI().getRootView(editor));
}
public static void main (final String[] args)
throws Exception
{
SwingUtilities.invokeLater( () ->
{
CSSTest frame = new CSSTest(args[0]);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 800);
frame.setLocation(0, 0);
frame.setVisible(true);
});
}
}
++++++++++++++++
external-css-test.html
++++++++++++++++
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="external-css.css">
</head>
<body>
<p class="help_title">Help Title</p>
<hr>
<p class="help_subtitle">Help Subtitle</p>
<p class="help_text">Help text text</p>
<p class="help_id">Help Id<br>
<hr>
<p class="copyright_text">Coyright</p>
<br></p>
</body>
</html>
++++++++++++++++
external-css.css
++++++++++++++++
p {margin:0; padding:0;}
.help_title
{
font-family: Arial;
font-size: 24pt;
font-weight: bold;
margin-top:16;
margin-left:10;
margin-bottom:16;
}
.help_subtitle
{
font-family: Tahoma;
font-size: 14pt;
font-weight: bold;
margin-top:5;
margin-left:20;
margin-bottom:5;
}
.help_text
{
font-family: Tahoma;
font-size: 12pt;
margin-bottom:15;
margin-left:20;
}
.help_id
{
font-family: Tahoma;
font-size: 9pt;
margin-left:20;
}
.copyright_text
{
font-family: Tahoma;
font-size: 9pt;
margin-left:10;
}
++++++++++++++++
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8333809 JEditorPane ignores font-size styles in external linked css-file
- Resolved
- duplicates
-
JDK-8300183 JEditorPane does not honor font-size definitions in external css file
- Closed
- links to
-
Commit openjdk/jdk17u-dev/ffa8a102
-
Commit openjdk/jdk/1caba0f1
-
Review openjdk/jdk17u-dev/2545
-
Review openjdk/jdk/10054
(1 links to)