From 6997a566612733c51448acbf2dd71813c82482d7 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 20 Jul 2023 13:35:06 +0100 Subject: [PATCH] Proper font IDs --- cpdftexttopdf.ml | 4 +--- cpdftoc.ml | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cpdftexttopdf.ml b/cpdftexttopdf.ml index 5170809..5359540 100644 --- a/cpdftexttopdf.ml +++ b/cpdftexttopdf.ml @@ -10,14 +10,12 @@ let rec of_utf8_with_newlines fontpack fontsize t = (fun u -> match Cpdfembed.get_char fontpack u with | Some (c, n, f) -> - (*Printf.printf "Charcode %i, font number %i\n" c n;*) begin if n <> !currfont then begin if !currtext <> [] then items := Cpdftype.Text (rev !currtext)::!items; currtext := []; currfont := n; - (* FIXME font id *) - items := Cpdftype.Font ("", f, fontsize)::!items; + items := Cpdftype.Font (string_of_int n, f, fontsize)::!items; currtext := char_of_int c::!currtext; end else diff --git a/cpdftoc.ml b/cpdftoc.ml index ce25ec4..8bf0183 100644 --- a/cpdftoc.ml +++ b/cpdftoc.ml @@ -38,10 +38,9 @@ let of_utf8 fontpack fontsize t = (map (function | [] -> [] - | (_, _, font) as h::t -> + | (_, n, font) as h::t -> let charcodes = map (fun (c, _, _) -> char_of_int c) (h::t) in - (*FIXME id *) - [Cpdftype.Font ("", font, fontsize); Cpdftype.Text charcodes]) + [Cpdftype.Font (string_of_int n, font, fontsize); Cpdftype.Text charcodes]) collated) (* Cpdftype codepoints from a font and PDFDocEndoding string *) @@ -68,12 +67,11 @@ let rec shorten_text_inner l t = let shorten_text fontpack fontsize l t = let short = shorten_text_inner l t in if short = t then t else - let charcode, _, dotfont = + let charcode, dotfontnum, dotfont = unopt (Cpdfembed.get_char fontpack (int_of_char '.')) in let charcode = char_of_int charcode in - (* FIXME ID *) - short @ [Cpdftype.Font ("", dotfont, fontsize); Cpdftype.Text [charcode; charcode; charcode]] + short @ [Cpdftype.Font (string_of_int dotfontnum, dotfont, fontsize); Cpdftype.Text [charcode; charcode; charcode]] (* Calculate the used codepoints *) let used pdf fastrefnums labels title marks =