tectonic-typesetting / tectonic

A modernized, complete, self-contained TeX/LaTeX engine, powered by XeTeX and TeXLive.
https://tectonic-typesetting.github.io/
Other
3.93k stars 160 forks source link

Reduce and rationalize system library dependencies #15

Open pkgw opened 7 years ago

pkgw commented 7 years ago

We want Tectonic to depend on as few system libraries as we can get away with. This issue is for tracking the big picture of the overall project to reduce our dependence on system libraries.

The current roster of pkg-config dependencies is:

Other libraries that the executable ends up depending on (on Linux):

(This is looking at DT_NEEDED records in the executable; ldd walks the tree of deps and comes up with more.)

We can probably eventually get rid of many of these!

pkgw commented 7 years ago

Poppler

Update: Poppler is gone!

Usage includes:

So it's really all about embedding PDFs as images within other PDFs. All pdfimage.cpp does is parse the document ("all") and get the bounds of a specified page, or count the pages.

khaledhosny commented 7 years ago

I think (not sure though) xdvipdfmx has code to extract the bounding box of PDF files (among other image files) AKA the extractbb mode.

khaledhosny commented 7 years ago

Indeed, it can read the bounding box and the number of pages:

$ extractbb -O -p5 sile.pdf 
%%Title: sile.pdf
%%Creator: extractbb 20160307
%%BoundingBox: 0 0 595 842
%%HiResBoundingBox: 0.000000 0.000000 595.280000 841.890000
%%PDFVersion: 1.5
%%Pages: 78
%%CreationDate: Sun Apr 23 16:15:38 2017
pkgw commented 7 years ago

And yes, it was just an hour's work to remove Poppler as a dependency! This is great, since Poppler is/was quite heavyweight.

pkgw commented 7 years ago

libpng

Libpng is only used directly in dpx-pngimage.c, which of course is all about reading PNG files to get their bounding boxes and embed them in PDF output files.

Crates.io shows a popular PNG crate. Unclear if it would have all of the bells and whistles that are exploited in the current xdvipdfmx code. Strangely there isn't obviously a Rust libpng-sys crate ... you'd think there would be? Maybe PNGs are too simple for everyone.

Urgency: unclear. Libpng is popular, but its binary compatibility seems unreliable.

chris-morgan commented 7 years ago

Things like libpng or whatever equivalent you settle on can safely be optional, too—not everyone needs images in their documents.

pkgw commented 7 years ago

@chris-morgan Yup! The hope is that one day they will all be Cargo "features" that can be activated or deactivated as circumstances dictate. It will take a lot of infrastructure work to get to the point where that is possible, though.