From 8f0f153a853624dbfa5d8846b178a0708269420e Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 13 Jun 2023 15:21:23 +0100 Subject: [PATCH] All now pushed into Cpdftruetype --- cpdfembed.ml | 23 +---------------------- cpdftexttopdf.ml | 2 +- cpdftruetype.ml | 4 ++-- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/cpdfembed.ml b/cpdfembed.ml index 7e519bf..6d7bdfe 100644 --- a/cpdfembed.ml +++ b/cpdfembed.ml @@ -22,24 +22,6 @@ let get_char (fonts, table) u = | (n, charcode) -> Some (charcode, n, List.nth fonts n) | exception Not_found -> None -let pdfcode_of_unicode_codepoint encoding_table glyphlist_table u = - try - Some (Hashtbl.find encoding_table (Hashtbl.find glyphlist_table [u])) - with - Not_found -> None - -let calc_accepted_unicodepoints encoding_table glyphlist_table codepoints = - sort (fun a b -> compare b a) (* FIXME: Remove once subset experiment gone *) - (setify - (option_map - (fun u -> - match - pdfcode_of_unicode_codepoint encoding_table glyphlist_table u - with - | Some _ -> Some u - | None -> None) - codepoints)) - let fontnum = ref 0 let basename () = @@ -104,9 +86,6 @@ let make_fontpack_hashtable fs = table let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding = - let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in - let encoding_table = Pdftext.reverse_table_of_encoding encoding in - let accepted_unicodepoints = calc_accepted_unicodepoints encoding_table glyphlist_table codepoints in - let fs = Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile encoding in + let fs = Cpdftruetype.parse ~subset:codepoints fontfile encoding in let subsets_and_their_fonts = map (make_single_font ~fontname ~encoding pdf) fs in (map snd subsets_and_their_fonts, make_fontpack_hashtable subsets_and_their_fonts) diff --git a/cpdftexttopdf.ml b/cpdftexttopdf.ml index 62b2a4c..5e98bba 100644 --- a/cpdftexttopdf.ml +++ b/cpdftexttopdf.ml @@ -45,7 +45,7 @@ let rec of_utf8_with_newlines fontpack fontsize t = let typeset ~papersize ~font ~fontsize text = let pdf = Pdf.empty () in - let codepoints = Pdftext.codepoints_of_utf8 (Pdfio.string_of_bytes text) in + let codepoints = setify (Pdftext.codepoints_of_utf8 (Pdfio.string_of_bytes text)) in let fontpack = match font with | Cpdfembed.PreMadeFontPack t -> t diff --git a/cpdftruetype.ml b/cpdftruetype.ml index a37f5ae..bfba361 100644 --- a/cpdftruetype.ml +++ b/cpdftruetype.ml @@ -443,8 +443,8 @@ let _ = let parse ?(subset=[]) data encoding = (*if !dbg then*) begin - Printf.printf "********SUBSET is "; - iter (Printf.printf "%i ") subset; + Printf.printf "********Cpdftruetype.parse SUBSET is "; + iter (Printf.printf "U+%04X ") subset; Printf.printf "\n" end; let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in