Puzzles with printed output

From: Jonathan Sachs (llm040903_at_earthlink.net)
Date: 09/05/04


Date: Sun, 05 Sep 2004 12:46:15 GMT

I'm working with printing from a subclass of JTextPane. The printing has
uncovered some aspects of Swing behavior that are puzzling, and in at least
one respect, plain wrong. I'm seeking information about what is
happening and how I can make my output print correctly.

I am currently using JBuilder 5 with JDK 1.3.0. (I intend to upgrade when
JBuilder 2005 is released.) The operating system is Windows XP.

This is my first experiment with printing in Swing, but I don't think I'm
doing anything unusual. I define attributes by creating SimpleAttributeSet
objects and setting attributes with the StyleConstants "set..." methods.
Then I pass a SimpleAttributeSet object to the document's insertString
method with each piece of text. I am currently using Times New Roman
10-point type, but I had similar problems with Swing's built-in Serif font.

My extension to JTextPane implements Printable, and defines a print method
that is copied directly from an example I found on the Web. The menu's Print
command creates a PrinterJob and a Book, and uses them to print the document
without trying to do anything fancy.

On the screen, the Times New Roman font looks like a different family from
the same font displayed in a Microsoft Word window. The line height is
right, but the x-height is smaller, making the font almost unreadable in
this size.

In print, the font appears to be of the right family (the x-height is the
same as in printed output from Word), but it appears to be bold, although I
did not set the "bold" attribute. I have tried turning the bold attribute
both off and on. Turning it off has no effect. Turning it on makes the
displayed text look 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.



Relevant Pages

  • Re: How to display a box in "em" units?
    ... space used for printing the capital M, ... I read up on M, N and x spacing from where they originated, in print ... and the proportion varies greatly by font. ... quad, whether or not people like that, and not its width but its size(as I ...
    (comp.infosystems.www.authoring.html)
  • Re: Another Chinese font problem
    ... no actual bold font file installed, if it is printed to a PostScript ... Windows looks after font rendering to the screen and to the printer. ... So, when printing to this printer type, Windows sends the data and allows ...
    (microsoft.public.word.printingfonts)
  • Re: Printing in VB6
    ... > 1) How do I determine how many lines of a font will fit on a page? ... > not bold - I wanted the first part to be bold. ... We use some of this code for printing. ... Set Up the RichTextBox Control for WYSIWYG Printing ...
    (microsoft.public.vb.general.discussion)
  • Re: Printing in VB6
    ... > 1) How do I determine how many lines of a font will fit on a page? ... How about directing your printing to a picturebox first? ... > not bold - I wanted the first part to be bold. ...
    (microsoft.public.vb.general.discussion)
  • Re: Font representation
    ... But a font became... ... bold or something. ... It has another parameters like spacing or char width. ... There's an idea that it's caused by differences of GDI and GDI+. ...
    (microsoft.public.dotnet.framework)