From 42e4c6689d029872b11da2e7364ce92f954162cd Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 10 Oct 2022 14:51:58 +0100 Subject: [PATCH] more --- cpdfembed.ml | 4 ++-- cpdftruetype.ml | 13 +++++++++---- cpdftruetype.mli | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cpdfembed.ml b/cpdfembed.ml index bbd9099..8a8ec8b 100644 --- a/cpdfembed.ml +++ b/cpdfembed.ml @@ -34,12 +34,12 @@ let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding = let name_1 = basename () in let module TT = Cpdftruetype in let fontfile = - let len = Pdfio.bytes_size f.TT.subset in + let len = Pdfio.bytes_size f.TT.subset_fontfile in Pdf.Stream {contents = (Pdf.Dictionary [("/Length", Pdf.Integer len); ("/Length1", Pdf.Integer len)], - Pdf.Got f.TT.subset)} + Pdf.Got f.TT.subset_fontfile)} in let fontfile_num = Pdf.addobj pdf fontfile in let open Pdftext in diff --git a/cpdftruetype.ml b/cpdftruetype.ml index bd0d03c..8826ef6 100644 --- a/cpdftruetype.ml +++ b/cpdftruetype.ml @@ -19,7 +19,8 @@ type t = firstchar : int; lastchar : int; widths : int array; - subset : Pdfio.bytes; + subset_fontfile : Pdfio.bytes; + subset : int list; tounicode : Pdfio.bytes option} let dbg = ref false @@ -554,7 +555,11 @@ let parse ?(subset=[]) data encoding = | (_, _, o, l)::_ -> o, l | [] -> raise (Pdf.PDFError "No glyf table found in TrueType font") in - let subset = remove_unneeded_tables major minor !tables indexToLocFormat subset encoding !glyphcodes loca mk_b glyfoffset data in + let main_subset = remove_unneeded_tables major minor !tables indexToLocFormat (tl subset) encoding !glyphcodes loca mk_b glyfoffset data in + let second_subset = remove_unneeded_tables major minor !tables indexToLocFormat [hd subset] encoding !glyphcodes loca mk_b glyfoffset data in [{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; - capheight; stemv; xheight; avgwidth; maxwidth; firstchar; lastchar; - widths; subset; tounicode = None}] + capheight; stemv; xheight; avgwidth; maxwidth; firstchar; lastchar; + widths; subset_fontfile = main_subset; subset = tl subset; tounicode = None}; + {flags; minx; miny; maxx; maxy; italicangle; ascent; descent; + capheight; stemv; xheight; avgwidth; maxwidth; firstchar; lastchar; + widths; subset_fontfile = second_subset; subset = [hd subset]; tounicode = None}] diff --git a/cpdftruetype.mli b/cpdftruetype.mli index 193b7e0..f15b75c 100644 --- a/cpdftruetype.mli +++ b/cpdftruetype.mli @@ -18,7 +18,8 @@ type t = firstchar : int; lastchar : int; widths : int array; - subset : Pdfio.bytes; + subset_fontfile : Pdfio.bytes; + subset : int list; tounicode : Pdfio.bytes option} (* Parse the given TrueType font file. It will return one or more fonts. The