Skip to content

PDF rendering library with sub-pixel engine to increase the apparent resolution of LCD display

License

Notifications You must be signed in to change notification settings

jonathanffon/poppler-lcd-patch

Repository files navigation

poppler-lcd-patch

v24.06.1

PDF rendering library with subpixel engine.

The goal is to increase the apparent resolution of PDF content on LCD laptop.

Features

  • Embed subpixel rendering into Cairo font engine of poppler and poppler-glib.
  • Add Cairo backend to poppler-qt5 and poppler-qt6.
  • Grant subpixel smoothing to poppler-based PDF viewers (Evince, Okular, TeXstudio...).
  • Previously installed poppler libraries remain untouched (Only *.desktop file will be modified).

Build & Inject

Prerequisites

Suppose you are using Arch Linux. Those packages are needed to compile poppler: 'libjpeg' 'gcc-libs' 'cairo' 'fontconfig' 'openjpeg2' 'gtk3' 'pkgconfig' 'lcms2' 'gobject-introspection' 'icu' 'qt5-base' 'qt6-base' 'git' 'nss' 'gpgme' 'gtk-doc' 'curl' 'cmake' 'python' 'boost' 'glib2-devel'

pacman -S libjpeg-turbo gcc-libs cairo fontconfig openjpeg2 gtk3 pkgconf lcms2 gobject-introspection icu qt5-base qt6-base git nss gpgme gtk-doc curl cmake python boost glib2-devel

Build from source

A script was provided to build necessary shared libraries. Generated binaries will be copied to ~/.config/poppler-lcd folder. In addition, you must use the python package provided by the official repo (/usr/bin/python) when building from source.

bash gen.sh

Inject

Sudoer's password is required. Desktop entries (*.desktop) will be modified to preload patched libraries.

bash gen.sh inject

If you don't want to modify system desktop entries directly, copy them to ~/.local/share/application and modify them as you wish.

Take okular for example. Find the line Exec=okular %U and replace it with: Exec=LD_PRELOAD=${pathto}/libpoppler-qt6.so:${pathto}/libpoppler.so okular %U Use your customized desktop entry instead.

Restore

If you don't want this subpixel rendering functionality any more and prefer using the original poppler libraries, recover desktop entries by running:

bash gen.sh unload

Supported Frontends

  • Document Viewer (Evince)

  • Okular

  • TeXstudio

  • Zathura

    ...

Screenshot

before and after subpixel rendering

History

PDF viewers on Linux laptop won't render fonts smoothly due to the lack of subpixel hinting.

The issue was submitted 13 years ago by Ernst Sjöstrand (Issue 61). Anders Kaseorg provided a 10-line patch that forced subpixel rendering on Cairo and some image comparison showed great improvements. Then Paul Gideon Dann created a patch for Poppler-0.14 and Vladimir's for Poppler-0.22.

About 9 years ago, Paul requested a Cairo backend for Poppler's Qt4 wrapper, to which the maintainer Albert Astals Cid said no lest someone may complain about a new subpixel functionality (Issue 435).

Two years ago, Yichao Zhou proposed a patch of subpixel rendering support for Poppler-0.43 (Issue 23). It was reviewed by Adrian Johnson but he didn't seem to be willing to accept it.

Nowadays, Zhou's patch won't work for Poppler>0.43 and Paul's patch is still under maintainance for the latest poppler version. Paul's patch has the following disadvantages:

  1. subpixel rendering wrapper for glib is so incomplete that any poppler-glib based frontend (e.g. evince) has to be patched to enable subpixel rendering.
  2. Cairo compositing operator used for Type 3 fonts is controlled inexplicitly by switching off subpixel antialias.

Based on the work of Paul and Zhou, I have rewritten the subpixel patch to provide subpixel functionality to PDF viewers without patching their own source code.

At one time, I tried to maintain a package in Arch User Repository(AUR) that provided a subpixel-hinting version of poppler. However, it might lead to broken package dependencies.

Finally, DLL injection was choosed to introduce subpixel rendering for PDF viewers. The trick can be used on various Linux Distros and won't affect system files except for the *.desktop launcher.

About

PDF rendering library with sub-pixel engine to increase the apparent resolution of LCD display

Resources

License

Stars

Watchers

Forks

Packages

No packages published