ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [Version 10.0.16299.371]
Samsung 4K monitor 3840 x 2160
NVIDIA Quadro K600 Driver version 388.16
Java 10.0.1
A DESCRIPTION OF THE PROBLEM :
Text in a JTextArea with Times New Roman font and 12 pt font size is much smaller than the same font in MS Word, Outlook or Notepad.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run attached code with JTextArea set to Times New Roman 12 pt font using Java 10
2. Open MS Word or Outlook or Notepad.
3. Type "The quick brown fox jumped over the lazy dog".
4. Select entire sentence and change font to "Times New Roman" 12 pt.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The text in the Java program should be the same size as in the Windows programs
ACTUAL -
The text in the Java program is much smaller, appears to be 9 pt instead of 12 pt
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.UIManager;
public class FontTest {
public static void main(String[] args) {
//Set L&F
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel( name );
} catch (Exception e) {
e.printStackTrace();
String laf = UIManager.getLookAndFeel().toString();
//create frame
JFrame frame = new JFrame();
frame.setTitle(System.getProperty("os.name") + " Java Version " + System.getProperty("java.version") +" "+laf);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//create text area
String TEXT = "The quick brown fox jumped over the lazy dog. ";
JTextArea area = new JTextArea();
Font font = Font.decode("Times New Roman");
area.setFont(font);
area.setText( TEXT + "\n" + area.getFont());
frame.getContentPane().add(area);
frame.setPreferredSize(new Dimension(900, 200));
frame.pack();
frame.setVisible(true);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use JTextArea.setFont() to force a larger font size
FREQUENCY : always