Continued assualt on Mt. Truetype

This commit is contained in:
John Whitington 2023-06-22 13:50:30 +01:00
parent 45db007f56
commit ebd407598a
2 changed files with 18 additions and 13 deletions

View File

@ -10,7 +10,7 @@ let rec of_utf8_with_newlines fontpack fontsize t =
(fun u -> (fun u ->
match Cpdfembed.get_char fontpack u with match Cpdfembed.get_char fontpack u with
| Some (c, n, f) -> | Some (c, n, f) ->
Printf.printf "Charcode %i, font number %i\n" c n; (*Printf.printf "Charcode %i, font number %i\n" c n;*)
begin if n <> !currfont then begin if n <> !currfont then
begin begin
if !currtext <> [] then items := Cpdftype.Text (rev !currtext)::!items; if !currtext <> [] then items := Cpdftype.Text (rev !currtext)::!items;

View File

@ -2,7 +2,7 @@
open Pdfutil open Pdfutil
open Pdfio open Pdfio
let dbg = ref true let dbg = ref false
type t = type t =
{flags : int; {flags : int;
@ -26,17 +26,22 @@ type t =
tounicode : (int, string) Hashtbl.t option} tounicode : (int, string) Hashtbl.t option}
let debug_t t = let debug_t t =
Printf.printf "firstchar: %i\n" t.firstchar; let hex u =
Printf.printf "lastchar: %i\n" t.lastchar; let b = Buffer.create 32 in
Printf.printf "widths:"; Array.iter (Printf.printf " %i") t.widths; Printf.printf "\n"; String.iter (fun x -> Buffer.add_string b (Printf.sprintf "%02X" (int_of_char x))) u;
Printf.printf "fontfile of length %i\n" (Pdfio.bytes_size t.subset_fontfile); Buffer.contents b
Printf.printf "subset:"; iter (Printf.printf " U+%04X") t.subset; Printf.printf "\n"; in
Printf.printf "tounicode:"; Printf.printf "firstchar: %i\n" t.firstchar;
begin match t.tounicode with Printf.printf "lastchar: %i\n" t.lastchar;
| None -> Printf.printf "None"; Printf.printf "widths:"; Array.iter (Printf.printf " %i") t.widths; Printf.printf "\n";
| Some table -> Hashtbl.iter (fun k v -> Printf.printf "%i --> %s\n" k v) table Printf.printf "fontfile of length %i\n" (Pdfio.bytes_size t.subset_fontfile);
end; Printf.printf "subset:"; iter (Printf.printf " U+%04X") t.subset; Printf.printf "\n";
Printf.printf "\n" Printf.printf "tounicode:\n";
begin match t.tounicode with
| None -> Printf.printf "None";
| Some table -> iter (fun (k, v) -> Printf.printf "%i --> U+%s\n" k (hex v)) (sort compare (list_of_hashtbl table))
end;
Printf.printf "\n"
let required_tables = let required_tables =
["head"; "hhea"; "loca"; "cmap"; "maxp"; "cvt "; "glyf"; "prep"; "hmtx"; "fpgm"] ["head"; "hhea"; "loca"; "cmap"; "maxp"; "cvt "; "glyf"; "prep"; "hmtx"; "fpgm"]