-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
x86
-
windows_nt
Name: mc57594 Date: 01/11/2000
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
I believe that there is a design flaw in the Java 2 printing APIs. To
accurately calculate text layout, line and page breaks, etc, I need to provide
a FontRenderContext. This context is obtained from a Graphics2D object. The
only way to get this Graphics2D object for a printer is to actually print.
Unfortunately, the Pageable interface requires that I already know the number
of pages before actually printing. This requires that I have already done the
layout for the text. Which requires a FontRenderContext. Which, as far as I
know, I can only get by printing. Full circle. If my description is accurate,
this is a bug in the API.
==================================================================
'From: ###@###.###
'To: chamness <###@###.###>
'Date: Fri, 17 Dec 1999 15:32:15 -0500
'Subject: Re: (Review ID: 98822) API flaw: FontRenderContext requires Pageable, requires FontRenderContext, etc
Mark,
Thanks for your reply. I will be happy to resubmit this bug, if you
think it's still necessary after reading this SHORT response. I
understand that your volume of work probably prohibits long
communication outside of official channels, and I want to be
respectful of your time.
I have just finished writing a first draft of a general purpose printing
and layout library, which is capable of both sending documents to
the printer and previewing them on the screen, taking into account
multiple fonts, bi-directional text, graphics, headers, footers,
dynamic page numbering, etc. I'm sure it's been done better by
other people, but I tell you this only so that you'll read more into
my question than "I can't print."
The crux of my bug report (and I'll admit it may be based on a
misunderstanding) is the FontRenderContext and the role it plays
in the laying out of text. This FontRenderContext is necessarily
device dependent. Its role is to TAKE DEVICE DEPENDENCIES
INTO ACCOUNT when measuring text. So you shouldn't, ideally,
use the screen FontRenderContext when laying out text for the
printer. Sure, you can, but ideally you shouldn't.
But based on my understanding of the API, this screen device
FontRenderContext is the only FontRenderContext available before
actually submitting a job to the printer. There is no way, according
to my understanding of the API, to obtain a FontRenderContext in
time to lay out the text IN ADVANCE of submitting a job to the
printer.
This may or may not be a bug... for instance, there may be some
way to obtain the FontRenderContext for an arbitrary printer in
advance. But it is not addressed in the article you cited (and I have
read); nor is it cited in any Sun or newsgroup documentation I can
find.
IMHO, the problem ultimately is that the class
java.awt.GraphicsEnvironment has no printer functions performing
roles similar to the functions:
public abstract GraphicsDevice[]
getScreenDevices();
and
public abstract GraphicsDevice
getDefaultScreenDevice();
THANK YOU for your time.
(Review ID: 98822)
======================================================================
- duplicates
-
JDK-4186133 RFE: 2D printing : API to pre-calculate number of pages needed before printing
- Closed