🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1012

Font misbehavior in display and/or print

#1012
From: Jonathan Sachs
Date: Thu, 02 Sep 2004 01:02
55 lines
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.
Technical Details
Message-ID: <0juZc.486$N4.281@newsread3.news.pas.earthlink.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!wns13feed!worldnet.att.net!207.217.77.102!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!c37cafc2!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,b05b9fd31d7b0d10,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!wns13feed!worldnet.att.net!207.217.77.102!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!c37cafc2!not-for-mail
From: "Jonathan Sachs" <llm040609@earthlink.net>
Newsgroups: borland.public.jbuilder.java.swing
Subject: Font misbehavior in display and/or print
Lines: 57
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <0juZc.486$N4.281@newsread3.news.pas.earthlink.net>
Date: Thu, 02 Sep 2004 01:02:52 GMT
NNTP-Posting-Host: 66.167.222.69
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread3.news.pas.earthlink.net 1094086972 66.167.222.69 (Wed, 01 Sep 2004 18:02:52 PDT)
NNTP-Posting-Date: Wed, 01 Sep 2004 18:02:52 PDT
Organization: EarthLink Inc. -- http://www.EarthLink.net