-
Bug
-
Resolution: Unresolved
-
P4
-
17, 20, 21
-
Fedora Linux 37
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
OS: Fedora Linux 37. Java: Oracle Java 17.0.6.
A DESCRIPTION OF THE PROBLEM :
Running Java program that uses Swing for GUI displays text in a JTextArea using the "Monospaced" font produces uneven lines. For "Monospaced plain" the output is "almost perfect" -- the output does not align exactly vertically. There is a slight "wave" on the far right when scanning down the output lines. When using "Monospaced bold" the output is scrunched horizontally. The problem does not occur when using a specific monospaced font -- eg "DejaVu Sans Mono" or "Liberation Mono".
The problem does not occur for
1. Fedora 37 using Oracle Java 1.8.0_201 (but bold lines are stretched horizontally; OK)
2. Windows 10 or Mac M2 using Oracle Java 17.0.6
3. Raspberry Pi 4 using 64-bit OS and OpenJDK 17.0.6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program with Oracle Java 17.0.6.
2. Run the program with Oracle Java 17.0.6.
3. Click "Next Font": button in the displayed GUI.
4. "Monospaced plain" font is used. Note slight "wave" on far right.
5. Click "Next Font" button.
6. "Monospaced bold" font is used. Note text is bold. All lines are scrunched horizontally.
7. Optional. Uncomment the 4 lines in the "fonts" variable declaration and run again. The "DejaVu" and "Liberation" fonts display correct output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When "Monospaced plain" or "Monospaced bold" font is used, displayed output should align horizontally and vertically. Column containing rightmost character -- an asterisk -- should not be wavy. For the bold font, the only difference from the plain font is that the text is bold.
ACTUAL -
When "Monospaced plain" is used, rightmost column bytes do not align. There is a wave appearance as you scan down the lines. When "Monospaced bold" is used, the text is bold, but scrunched horizontally, making the text appear to be using a non-monospaced font.
Note: I have screenshots showing output for "Monospaced" and "DejaVu" from Fedora 37 using Oracle Java 17.0.6 and Oracle Java 1.8.0_201 that I can send.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class TestMonospacedFont {
private JTextArea textArea;
private JScrollPane scrollPane;
private JTextField textField;
public String[] textData = {
"SNAP DUMP ID=1 TEXT=All EBCDIC characters",
" 000FFE00 *00010203 04050607 08090A0B 0C0D0E0F* *................*",
" 000FFE10 *10111213 14151617 18191A1B 1C1D1E1F* *................*",
" 000FFE20 *20212223 24252627 28292A2B 2C2D2E2F* *................*",
" 000FFE30 *30313233 34353637 38393A3B 3C3D3E3F* *................*",
" 000FFE40 *40414243 44454647 48494A4B 4C4D4E4F* * ...........<(+.*",
" 000FFE50 *50515253 54555657 58595A5B 5C5D5E5F* *&.........!$*);.*",
" 000FFE60 *60616263 64656667 68696A6B 6C6D6E6F* *-/.........,%_>?*",
" 000FFE70 *70717273 74757677 78797A7B 7C7D7E7F* *..........:#@'=\"*",
" 000FFE80 *80818283 84858687 88898A8B 8C8D8E8F* *.abcdefghi......*",
" 000FFE90 *90919293 94959697 98999A9B 9C9D9E9F* *.jklmnopqr......*",
" 000FFEA0 *A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF* *.~stuvwxyz......*",
" 000FFEB0 *B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF* *................*",
" 000FFEC0 *C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF* *{ABCDEFGHI......*",
" 000FFED0 *D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF* *}JKLMNOPQR......*",
" 000FFEE0 *E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF* *\\.STUVWXYZ......*",
" 000FFEF0 *F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF* *0123456789......*"
};
public int curFont = 0;
public Font[] fonts =
{
// new Font("DejaVu Sans Mono", Font.PLAIN, 12),
// new Font("DejaVu Sans Mono", Font.BOLD, 12),
// new Font("Liberation Mono", Font.PLAIN, 12),
// new Font("Liberation Mono", Font.BOLD, 12),
new Font("Monospaced", Font.PLAIN, 12),
new Font("Monospaced", Font.BOLD, 12)
};
public TestMonospacedFont()
{
textArea = new JTextArea(20, 50);
textArea.setEditable(false);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
textArea.setMargin(new Insets(5,5,5,5));
scrollPane = new JScrollPane(textArea);
textField = new JTextField(50);
textField.setHorizontalAlignment(JTextField.LEFT);
JPanel p = new JPanel();
JButton b = new JButton("Next Font");
b.addActionListener(new ButtonHandler());
p.add(b);
p.add(new JLabel("Font : "));
p.add(textField);
JFrame frame = new JFrame("Test Monospaced Font");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(scrollPane,BorderLayout.CENTER);
frame.getContentPane().add(p,BorderLayout.SOUTH);
textArea.setText(null);
Font f = textArea.getFont();
textField.setText(" "+f);
curFont = 0; // start over with fonts
for (int i = 0; i < textData.length; i++) {
textArea.append(textData[i]+"\n");
}
frame.pack();
frame.setVisible(true);
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
Font f = fonts[curFont++];
textField.setText(" "+f);
textArea.setFont(f);
if (curFont == fonts.length) curFont = 0;
}
}
public static void main(String[] args)
{
new TestMonospacedFont();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Modify source to use a "non-generic" monospaced font such as "DejaVu Sans Mono" or "Liberation Mono". The sample program illustrates their use and shows expected output.
FREQUENCY : always
OS: Fedora Linux 37. Java: Oracle Java 17.0.6.
A DESCRIPTION OF THE PROBLEM :
Running Java program that uses Swing for GUI displays text in a JTextArea using the "Monospaced" font produces uneven lines. For "Monospaced plain" the output is "almost perfect" -- the output does not align exactly vertically. There is a slight "wave" on the far right when scanning down the output lines. When using "Monospaced bold" the output is scrunched horizontally. The problem does not occur when using a specific monospaced font -- eg "DejaVu Sans Mono" or "Liberation Mono".
The problem does not occur for
1. Fedora 37 using Oracle Java 1.8.0_201 (but bold lines are stretched horizontally; OK)
2. Windows 10 or Mac M2 using Oracle Java 17.0.6
3. Raspberry Pi 4 using 64-bit OS and OpenJDK 17.0.6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program with Oracle Java 17.0.6.
2. Run the program with Oracle Java 17.0.6.
3. Click "Next Font": button in the displayed GUI.
4. "Monospaced plain" font is used. Note slight "wave" on far right.
5. Click "Next Font" button.
6. "Monospaced bold" font is used. Note text is bold. All lines are scrunched horizontally.
7. Optional. Uncomment the 4 lines in the "fonts" variable declaration and run again. The "DejaVu" and "Liberation" fonts display correct output.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When "Monospaced plain" or "Monospaced bold" font is used, displayed output should align horizontally and vertically. Column containing rightmost character -- an asterisk -- should not be wavy. For the bold font, the only difference from the plain font is that the text is bold.
ACTUAL -
When "Monospaced plain" is used, rightmost column bytes do not align. There is a wave appearance as you scan down the lines. When "Monospaced bold" is used, the text is bold, but scrunched horizontally, making the text appear to be using a non-monospaced font.
Note: I have screenshots showing output for "Monospaced" and "DejaVu" from Fedora 37 using Oracle Java 17.0.6 and Oracle Java 1.8.0_201 that I can send.
---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class TestMonospacedFont {
private JTextArea textArea;
private JScrollPane scrollPane;
private JTextField textField;
public String[] textData = {
"SNAP DUMP ID=1 TEXT=All EBCDIC characters",
" 000FFE00 *00010203 04050607 08090A0B 0C0D0E0F* *................*",
" 000FFE10 *10111213 14151617 18191A1B 1C1D1E1F* *................*",
" 000FFE20 *20212223 24252627 28292A2B 2C2D2E2F* *................*",
" 000FFE30 *30313233 34353637 38393A3B 3C3D3E3F* *................*",
" 000FFE40 *40414243 44454647 48494A4B 4C4D4E4F* * ...........<(+.*",
" 000FFE50 *50515253 54555657 58595A5B 5C5D5E5F* *&.........!$*);.*",
" 000FFE60 *60616263 64656667 68696A6B 6C6D6E6F* *-/.........,%_>?*",
" 000FFE70 *70717273 74757677 78797A7B 7C7D7E7F* *..........:#@'=\"*",
" 000FFE80 *80818283 84858687 88898A8B 8C8D8E8F* *.abcdefghi......*",
" 000FFE90 *90919293 94959697 98999A9B 9C9D9E9F* *.jklmnopqr......*",
" 000FFEA0 *A0A1A2A3 A4A5A6A7 A8A9AAAB ACADAEAF* *.~stuvwxyz......*",
" 000FFEB0 *B0B1B2B3 B4B5B6B7 B8B9BABB BCBDBEBF* *................*",
" 000FFEC0 *C0C1C2C3 C4C5C6C7 C8C9CACB CCCDCECF* *{ABCDEFGHI......*",
" 000FFED0 *D0D1D2D3 D4D5D6D7 D8D9DADB DCDDDEDF* *}JKLMNOPQR......*",
" 000FFEE0 *E0E1E2E3 E4E5E6E7 E8E9EAEB ECEDEEEF* *\\.STUVWXYZ......*",
" 000FFEF0 *F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF* *0123456789......*"
};
public int curFont = 0;
public Font[] fonts =
{
// new Font("DejaVu Sans Mono", Font.PLAIN, 12),
// new Font("DejaVu Sans Mono", Font.BOLD, 12),
// new Font("Liberation Mono", Font.PLAIN, 12),
// new Font("Liberation Mono", Font.BOLD, 12),
new Font("Monospaced", Font.PLAIN, 12),
new Font("Monospaced", Font.BOLD, 12)
};
public TestMonospacedFont()
{
textArea = new JTextArea(20, 50);
textArea.setEditable(false);
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
textArea.setMargin(new Insets(5,5,5,5));
scrollPane = new JScrollPane(textArea);
textField = new JTextField(50);
textField.setHorizontalAlignment(JTextField.LEFT);
JPanel p = new JPanel();
JButton b = new JButton("Next Font");
b.addActionListener(new ButtonHandler());
p.add(b);
p.add(new JLabel("Font : "));
p.add(textField);
JFrame frame = new JFrame("Test Monospaced Font");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(scrollPane,BorderLayout.CENTER);
frame.getContentPane().add(p,BorderLayout.SOUTH);
textArea.setText(null);
Font f = textArea.getFont();
textField.setText(" "+f);
curFont = 0; // start over with fonts
for (int i = 0; i < textData.length; i++) {
textArea.append(textData[i]+"\n");
}
frame.pack();
frame.setVisible(true);
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
Font f = fonts[curFont++];
textField.setText(" "+f);
textArea.setFont(f);
if (curFont == fonts.length) curFont = 0;
}
}
public static void main(String[] args)
{
new TestMonospacedFont();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Modify source to use a "non-generic" monospaced font such as "DejaVu Sans Mono" or "Liberation Mono". The sample program illustrates their use and shows expected output.
FREQUENCY : always