You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Jeremias Maerki <de...@jeremias-maerki.ch> on 2007/11/03 12:22:17 UTC

Dramatic improvement of PDF text painting quality for SVG

As you may have see, I've reimplemented the PDFTextPainter which is part
of the PDFTranscoder. All most all text is now painted using PDF text
painting primitives (except for SVG fonts and where filters are used).

The advantages: smaller PDF files, better visible quality, copy/paste
is possible.

Change:
http://svn.apache.org/viewvc?rev=591587&view=rev

Implementation notes:
- The text painter has a fallback so it can still paint text with SVG
fonts. Text for which there's no font in FOP's FontInfo object will be
painted using shapes as before.
- I've reenabled the "stroke text" switch so you can switch to text as
shapes if anything goes bad (which it shouldn't as the new code is
already well tested).
- By default, I've enabled the PDFTrancoder to make use of FOP's font
auto-detection, so no additional configuration should be necessary to
handle most cases.
- During testing I found that at least on Windows, Sun J2SE 6.0_03
doesn't register Type 1 fonts (like Helvetica) in the Java AWT font list.
That can lead to unexpected font substitution.
- On Linux with J2SE 1.5, my client saw some unexpected behaviour in
terms of font selection which may have to do with either Linux itself or
the JVM. We haven't found out. Installing the right fonts and removing
others helped in this situation.
- The above two points are most likely due to the approach I've taken.
The insider will notice that I've extended the StrokingTextPainter which
means that all text is internally built up using shapes but effectively
painted using PDF text by the PDF TextPainter. That way I didn't have to
reimplement a lot of the flow text functionality. Actually, I've managed
to implement all this with next to no changes in Batik itself (just a
nit. Cameron has taken care of my patch. Thanks!). All this naturally
means, I rely on the font metrics from the AWT subsystem and I just
carefully position each glyph at the position where the Stroking
TextPainter would have painted each glyph as shapes. Now, if no
equivalent font is found in the FontInfo object, the result will look
bad: for example, Times text with Arial font metrics. Fortunately, with
font auto-detection this problem usually doesn't appear. The visual
differences between the PNGTranscoder and the PDFTranscoder are minimal.
I've tested the whole W3C SVG 1.1 test suite.
- I've investigated what it would take to hook FontInfo into Batik's
font subsystem. It looked like too much work for the benefit I get. Just
so you know there's still room for improvement, but for now I've
followed the 80:20 rule.

Feedback welcome. And yes, XSL-FO documents with embedded SVG profit
from these changes, too. :-)

Have fun!
Jeremias Maerki


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Cameron McCormack <ca...@mcc.id.au>.
Jeremias Maerki:
> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).
> 
> The advantages: smaller PDF files, better visible quality, copy/paste
> is possible.

Awesome!  I know many people will be pleased with this.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 05.11.2007 08:22:38 Max Berger wrote:
> Jeremias,
> 
> 
> Am Samstag, den 03.11.2007, 12:22 +0100 schrieb Jeremias Maerki:
> > Implementation notes:
> > - The text painter has a fallback so it can still paint text with SVG
> > fonts. Text for which there's no font in FOP's FontInfo object will be
> > painted using shapes as before.
> 
> Please correct me if I'm wrong:
> 
> AFAIK fop does not embed fonts into the document unless explicitly
> requested. So with the new auto-detection feature, it will automatically
> pick up all fonts on the local system, and provide font-metrics
> (FontInfo) for it, but not embed them.

No, it does embed them by default! I think we don't have a facility to
suppress font embedding for auto-detected fonts, yet.

> If the resulting pdf is moved to
> a different machine where the installed font set is different, the
> result will look very garbled.

No, it doesn't affect the resulting PDF because the fonts are embedded.

> > Feedback welcome. And yes, XSL-FO documents with embedded SVG profit
> > from these changes, too. :-)
> > Have fun!
> > Jeremias Maerki
> 
> 
> Max


Jeremias Maerki


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Max Berger <ma...@berger.name>.
Jeremias,


Am Samstag, den 03.11.2007, 12:22 +0100 schrieb Jeremias Maerki:
> Implementation notes:
> - The text painter has a fallback so it can still paint text with SVG
> fonts. Text for which there's no font in FOP's FontInfo object will be
> painted using shapes as before.

Please correct me if I'm wrong:

AFAIK fop does not embed fonts into the document unless explicitly
requested. So with the new auto-detection feature, it will automatically
pick up all fonts on the local system, and provide font-metrics
(FontInfo) for it, but not embed them. If the resulting pdf is moved to
a different machine where the installed font set is different, the
result will look very garbled.

> Feedback welcome. And yes, XSL-FO documents with embedded SVG profit
> from these changes, too. :-)
> Have fun!
> Jeremias Maerki


Max

Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Not anymore. But remember that in order to include FOP's transcoders in
Batik, a release needs to be made, which means a branch, which means an
opportunity to temporarily work around these things.

BTW, the EPS transcoder is currently broken. Everything is upside down
and I haven't investigated, yet. Don't know where and when it got broken.

This all just reminds me that we need to get this stuff out of FOP. I'm
still on the image package redesign and will have to do a few smaller
things afterwards. But after that I want to get this done.

Jeremias Maerki



On 06.11.2007 00:43:34 Cameron McCormack wrote:
> Jeremias Maerki:
> > As you may have see, I've reimplemented the PDFTextPainter which is part
> > of the PDFTranscoder. All most all text is now painted using PDF text
> > painting primitives (except for SVG fonts and where filters are used).
> 
> By the way, is the FOP code after this commit still able to be compiled
> with Java 1.3?  I would like this change to be in the final Batik 1.7
> release (whenever that happens, maybe in a few weeks).
> 
> -- 
> Cameron McCormack, http://mcc.id.au/
> 	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Not anymore. But remember that in order to include FOP's transcoders in
Batik, a release needs to be made, which means a branch, which means an
opportunity to temporarily work around these things.

BTW, the EPS transcoder is currently broken. Everything is upside down
and I haven't investigated, yet. Don't know where and when it got broken.

This all just reminds me that we need to get this stuff out of FOP. I'm
still on the image package redesign and will have to do a few smaller
things afterwards. But after that I want to get this done.

Jeremias Maerki



On 06.11.2007 00:43:34 Cameron McCormack wrote:
> Jeremias Maerki:
> > As you may have see, I've reimplemented the PDFTextPainter which is part
> > of the PDFTranscoder. All most all text is now painted using PDF text
> > painting primitives (except for SVG fonts and where filters are used).
> 
> By the way, is the FOP code after this commit still able to be compiled
> with Java 1.3?  I would like this change to be in the final Batik 1.7
> release (whenever that happens, maybe in a few weeks).
> 
> -- 
> Cameron McCormack, http://mcc.id.au/
> 	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Cameron McCormack <ca...@mcc.id.au>.
Jeremias Maerki:
> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).

By the way, is the FOP code after this commit still able to be compiled
with Java 1.3?  I would like this change to be in the final Batik 1.7
release (whenever that happens, maybe in a few weeks).

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Cameron McCormack <ca...@mcc.id.au>.
Jeremias Maerki:
> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).

By the way, is the FOP code after this commit still able to be compiled
with Java 1.3?  I would like this change to be in the final Batik 1.7
release (whenever that happens, maybe in a few weeks).

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Cameron McCormack <ca...@mcc.id.au>.
Jeremias Maerki:
> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).
> 
> The advantages: smaller PDF files, better visible quality, copy/paste
> is possible.

Awesome!  I know many people will be pleased with this.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

Re: Dramatic improvement of PDF text painting quality for SVG

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 03.11.2007 16:02:56 The Web Maestro wrote:
> > And yes, XSL-FO documents with embedded SVG profit
> > from these changes, too. :-)
> 
> Does this require any special FO to implement? IOW, are there any
> settings which can be made in the XSL-FO which turns ON/OFF this
> functionality?

As I mentioned, there's a fallback switch (in case anything comes out
wrong, for both the PDFTranscoder and the PDFRenderer/PDFSVGHandler)
where you can disable it, but by default it's on.

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by The Web Maestro <th...@gmail.com>.
On 11/3/07, Jeremias Maerki <de...@jeremias-maerki.ch> wrote:
> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).
>
> The advantages: smaller PDF files, better visible quality, copy/paste
> is possible.

This looks like a great addition.

> Feedback welcome.

I and others have often wondered about getting selectable text from
FOP output. Thank you!

> And yes, XSL-FO documents with embedded SVG profit
> from these changes, too. :-)

Does this require any special FO to implement? IOW, are there any
settings which can be made in the XSL-FO which turns ON/OFF this
functionality?

-- 
Regards,

The Web Maestro
-- 
<th...@gmail.com> - <http://homepage.mac.com/webmaestro/>
My religion is simple. My religion is kindness.
- HH The 14th Dalai Lama of Tibet

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by th...@kodak.com.
Hi Jeremias,

Jeremias Maerki <de...@jeremias-maerki.ch> wrote on 11/03/2007 07:22:17 AM:

> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).
> 
> The advantages: smaller PDF files, better visible quality, copy/paste
> is possible.

   This is a great addition.  Thanks for taking the time to implement
this.


Re: Dramatic improvement of PDF text painting quality for SVG

Posted by th...@kodak.com.
Hi Jeremias,

Jeremias Maerki <de...@jeremias-maerki.ch> wrote on 11/03/2007 07:22:17 AM:

> As you may have see, I've reimplemented the PDFTextPainter which is part
> of the PDFTranscoder. All most all text is now painted using PDF text
> painting primitives (except for SVG fonts and where filters are used).
> 
> The advantages: smaller PDF files, better visible quality, copy/paste
> is possible.

   This is a great addition.  Thanks for taking the time to implement
this.