Thread View: borland.public.jbuilder.java.swing
1 messages
1 total messages
Started by Jonathan Sachs
Thu, 02 Sep 2004 01:02
Font misbehavior in display and/or print
Author: Jonathan Sachs
Date: Thu, 02 Sep 2004 01:02
Date: Thu, 02 Sep 2004 01:02
55 lines
3517 bytes
3517 bytes
I'm working with an extension of JTextPane and printing. The printing has uncovered some aspects of Swing behavior that are puzzling, and in at least one respect, plain wrong. I'm seeking some enlightenment about what is happening and how I can make my output both display and print correctly. I am currently using a rather old system, JBuilder 5 with JDK 1.3.0. (I intend to upgrade when JBuilder 2005 is released.) I'm defining attributes by creating SimpleAttributeSet objects and setting attributes with the StyleConstants "set..." methods. Then I pass an attribute object to the document's insertString method along with each piece of text. I am currently using Times New Roman 10-point type (in Windows XP), but I had similar problems with Swing's built-in Serif font. This is my first experiment with printing in Swing, but I don't think I'm doing anything unusual. My extension to JTextPane implements Printable, and defines a print method that is copied directly from a simple example I found on the Web. The menu's Print command creates a PrinterJob and a Book, and uses them to print the entire content of the text pane without trying to do anything fancy. On the screen, the Times New Roman font looks a different family from the same font displayed in a Microsoft Word window. The line height is the same, but the x-height is smaller, making the font almost unreadable in this size. In print, the font appears to be of the same family as in printed output from Word (the x-height is the same), but it is much heavier. It is comparable to Word's Times New Roman 10-point bold. I have tried turning the bold attribute both off and on. Turning it off has no effect, and turning it on makes the displayed text look heavier (like Word's Times New Roman 10-point bold), but has no effect on the printed text. Line spacing on the screen is the same as in Word (with Word's line spacing set to "single"). Line spacing in print is considerably wider; Word prints exactly six lines per inch, while my application prints about 5.5. I have tried explicitly setting line spacing to zero, with no effect. Some of the text my application displays is intentionally underlined or struck out. On the screen the underlines and strikeouts are correct. In print they are all about 5% too short when I try to print regular characters, and about 5% too long when I try to print bold characters.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads