Tarlika said:
As I mentioned before, I am not actually programming the printing myself
- I use JasperReports. What made me think that the System fonts must be
picked up somehow was the fact that the GUI report designer offers a
list with all the fonts installed on my Win2K machine. In fact, I just
chose a more exotic font in the design and it is really picked up at
runtime. On Windows it must be picked up from c:\winnt\fonts.
Printing in Java on Windows works different than printing on Unix/Linux.
Printing on Windows uses the Windows GDI API. That Windows API is
capable of using Windows GUI fonts, so on Windows you don't have a
difference in the list of available fonts. AFAIK windows either uses a
printer's build in rasterizer or uses the same rasterizer for printing
than for GUI display. Windows printing can also download GUI fonts to a
printer if they are not available on the printer. So from a Java point
of view, almost all GUI fonts are available for printing.
I presumed that there must be a similar mechanism on Linux.
Traditionally Unix printing and Unix GUI (X11) are two completely
separate systems. Traditional Unix printing doesn't even allow to query
printer type, capabilities or fonts. A Unix application had to have a
build-in driver for a particular printer, much like it was the case in
ancient DOS. And a user had to chose the right driver before printing.
Over the time two particular printer types became common under Unix:
PostScript and/or HP PCL capable printers. And with the availability of
the ghostscript RIP PostScript became the most common format.
So Sun's idea of generating PostScript when printing from Java on Unix
is a logical way of doing things on Unix. Only that they forgot to
provide basic support, like being able to enumerate the (virtual)
printer fonts or get their font metric directly.
There seems to be a strange idea among the Java team that printing is
just the same as drawing a GUI and that the GUI API is sufficient for
printing, too. Maybe due to the NeWS background.
But then
again different Linux flavours might handle the fonts differently, not
to mention what different VMs might do.
All the Unix/Linux VMs which I have seen (certainly there are more) did
generate PostScript. So using a PostScript font name should give you the
same results on these VMs. PostScript font names should also more or
less work on Windows, since Windows maps PostScript font names to
similar (but not identical) Windows fonts (e.g. Helvetica to Arial).
/Thomas