badonhill-io / randeli

Augment PDFs and e-books to aid neurodivergent (ADD/ADHD) reading
GNU General Public License v2.0
1 stars 1 forks source link

Support non-simple PDF fonts #1

Open nhi-vanye opened 1 year ago

nhi-vanye commented 1 year ago

Currently only supports PDFs with simple fonts (i.e. Type1, TrueType, and Type3), but XeLaTeX uses Type0 (i.e. e_Type0 == 4).

randeli inspect --read samples/xelatex/alt-font.pdf --fonts

PDFNet is running in demo mode.
Package: base
11:58:55.111 NOTICE          r.cli | Page 1 / 1
11:58:55.111 DETAIL          r.cli |   Bounding Box 0,0 595,841 )
11:58:55.111 INFO            r.cli | Element 1 group-begin (10) ( 0,0 0,0 )
11:58:55.111 INFO            r.cli | Element 2 text-begin (2) ( 0,0 0,0 )
11:58:55.112 INFO            r.cli | Element 3 new-line (4) ( 0,0 0,0 )
11:58:55.112 INFO            r.cli | Element 4 text (3) ( 89,726 128,740 )
11:58:55.113 DETAIL          r.cli |   text = Lorem
11:58:55.113 DETAIL          r.cli |   font = DejaVu Serif (type=4)

Compare this to a PDFLaTeX generated document - 0 = e_Type1

randeli inspect --read samples/pdflatex/alt-font.pdf --fonts

PDFNet is running in demo mode.
Package: base
12:00:48.689 NOTICE          r.cli | Page 1 / 1
12:00:48.689 DETAIL          r.cli |   Bounding Box 0,0 595,841 )
12:00:48.689 INFO            r.cli | Element 1 text-begin (2) ( 0,0 0,0 )
12:00:48.690 INFO            r.cli | Element 2 new-line (4) ( 0,0 0,0 )
12:00:48.690 INFO            r.cli | Element 3 text (3) ( 89,724 128,742 )
12:00:48.690 DETAIL          r.cli |   text = Lorem
12:00:48.690 DETAIL          r.cli |   font = DejaVu Serif (type=0)

Two approaches, use a box, or try and handle the text directly.

nhi-vanye commented 1 year ago

Re-open as the PR is a workaround.