how to get the best rendering quality on Linux

280 views
Skip to first unread message

Willie Abrams

unread,
Mar 4, 2018, 12:29:49 AM3/4/18
to pdfium
Thanks to this list, I've been able to address a number of problems and I have good PDF rendering working on Linux.

However, the program I am working on is a port from macOS, and we are seeing differences in the PDF rendering between PDFium on Linux and Core Graphics on macOS.

Specifically, text rendering is still slightly lighter, a bit thinner on Linux. I was able to make slight improvements by passing FPDF_LCD_TEXT to FPDF_RenderPageBitmap, but I'm still not quite as good as I would like.

Are there any tips or tricks or flags I should try both in building pdfium or from an API level to get the best (I do not care about speed) rendering quality?

Thanks!
Willie

Martin Sandsmark

unread,
Mar 5, 2018, 3:57:54 AM3/5/18
to pdfium
Hi!


On 4 March 2018 at 06:29, Willie Abrams <wil...@pobox.com> wrote:
> Specifically, text rendering is still slightly lighter, a bit thinner on
> Linux. I was able to make slight improvements by passing FPDF_LCD_TEXT to
> FPDF_RenderPageBitmap, but I'm still not quite as good as I would like.

Using different versions of Freetype is the first thing that comes to
mind. Do you use the bundled Freetype on both platforms?


--
Martin Sandsmark
Chief Technical Officer
+47 980 33 988

https://remarkable.com
Pilestredet 75c, 0354 Oslo - Norway

Willie Abrams

unread,
Mar 5, 2018, 9:15:22 AM3/5/18
to pdfium
On Monday, March 5, 2018 at 2:57:54 AM UTC-6, Martin Sandsmark wrote:
Using different versions of Freetype is the first thing that comes to
mind. Do you use the bundled Freetype on both platforms?

That's a good question!

On macOS, we use Core Graphics and native PDF rendering pipeline (on old Xserves). We are trying to replace that with PDFium and Linux. Text rendering is the most obvious difference between the two.

I believe I am using the bundled FreeType on Linux. I am passing:

gn gen out/codebuild --args='use_sysroot=false is_clang=false use_custom_libcxx=false pdf_is_complete_lib=true pdf_is_standalone=true pdf_enable_v8=false pdf_enable_xfa=false pdfium_bundle_freetype=true'

when I build pdfium. Any suggestions?

Dan Sinclair

unread,
Mar 5, 2018, 9:18:38 AM3/5/18
to Willie Abrams, pdfium
The other question would be if the fonts are embedded or not? If the font isn't embedded, are you sure that font renders the same on Linux and MacOS? If the font isn't embedded, and isn't installed, we will substitute another font which may look different.

dan


--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+unsubscribe@googlegroups.com.
To post to this group, send email to pdf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/5a164f5e-7ce2-41bb-b599-bf70852eb99b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Martin Sandsmark

unread,
Mar 5, 2018, 11:03:29 AM3/5/18
to Willie Abrams, pdfium
Hi!


On 5 March 2018 at 15:15, Willie Abrams <wil...@pobox.com> wrote:
> On macOS, we use Core Graphics and native PDF rendering pipeline (on old
> Xserves). We are trying to replace that with PDFium and Linux. Text
> rendering is the most obvious difference between the two.

Ah, then I misunderstood you, I thought there were differences when
running pdfium on macos vs. running pdfium on linux.

In case the font choice (as Dan suggested) isn't the issue, and you
want to match the look of coregraphics, I'd try to tweak the
freetype config (or potentially use another unbundled version, I'm not
sure which version pdfium bundles).

E. g. look here:
https://www.freetype.org/freetype2/docs/text-rendering-general.html

Willie Abrams

unread,
Mar 6, 2018, 4:59:42 PM3/6/18
to pdfium
On Monday, March 5, 2018 at 10:03:29 AM UTC-6, Martin Sandsmark wrote:
In case the font choice (as Dan suggested) isn't the issue, and you
want to match the look of coregraphics, I'd try to tweak the
freetype config (or potentially use another unbundled version, I'm not
sure which version pdfium bundles).

E. g. look here:
https://www.freetype.org/freetype2/docs/text-rendering-general.html

This describes exactly the difference I am seeing!

On macOS, we trigger sub-pixel font smoothing in a CGBitmap (looks better than what Preview.app does) , and the text rendering is similar to the FreeType Stem-Dark auto hinter in the article you linked to.

I'm currently using the bundled FreeType to build PDFium, so, I'll have to dig a bit more and figure out how to change to this. (if you have more suggestions or examples, I would appreciate it)

(Thanks also to Dan about his suggestion about embedded fonts. That was not the problem, but it was a good thing to verify.)

Thanks again!
Willie

Martin Sandsmark

unread,
Mar 7, 2018, 4:59:25 AM3/7/18
to Willie Abrams, pdfium
Hi!


On 6 March 2018 at 22:59, Willie Abrams <wil...@pobox.com> wrote:
> I'm currently using the bundled FreeType to build PDFium, so, I'll have to
> dig a bit more and figure out how to change to this. (if you have more
> suggestions or examples, I would appreciate it)

It's probably easier to use the bundled freetype, since you AFAIK need
to recompile freetype to change this (by editing the ftoption.h
header).

You could try to use the distro freetype, maybe it has enabled the
correct things, by doing «gn gen --args="pdf_bundle_freetype=false
[...]» when building pdfium.

Willie Abrams

unread,
Mar 7, 2018, 11:51:12 AM3/7/18
to Martin Sandsmark, pdfium
Do you know what to define in ftoption.h? All I can seem to find is

* FT_Property_Set( library, "cff",
* "no-stem-darkening", &no_stem_darkening );

And calling that shortly after FT_Init_FreeType. (Which I can automate with sed, but that seems trickier.)

Willie

Martin Sandsmark

unread,
Mar 8, 2018, 3:43:58 AM3/8/18
to Willie Abrams, pdfium
Hi!


On 7 March 2018 at 17:51, Willie Abrams <wil...@pobox.com> wrote:
> Do you know what to define in ftoption.h? All I can seem to find is [...]
> And calling that shortly after FT_Init_FreeType. (Which I can automate with
> sed, but that seems trickier.)

Unfortunately I don't really know freetype. But pdfium ships with a
custom ftoption.h, as you probably noticed, that disables e. g.
subpixel rendering (because of the patent issues, I assume). So I'd
first try with a plain unpatched ftoption.h.


If you don't manage to figure it out by testing turning on/off the
various options you could try searching the freetype mailing list
archives, and if you don't find anything there either just sending a
mail to their list. Probably helps if you attach screenshots as well
if you do this.

Info about the lists is here: https://www.freetype.org/contact.html
Reply all
Reply to author
Forward
0 new messages