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,15 +26,20 @@ type t =
tounicode : (int, string) Hashtbl.t option} tounicode : (int, string) Hashtbl.t option}
let debug_t t = let debug_t t =
let hex u =
let b = Buffer.create 32 in
String.iter (fun x -> Buffer.add_string b (Printf.sprintf "%02X" (int_of_char x))) u;
Buffer.contents b
in
Printf.printf "firstchar: %i\n" t.firstchar; Printf.printf "firstchar: %i\n" t.firstchar;
Printf.printf "lastchar: %i\n" t.lastchar; Printf.printf "lastchar: %i\n" t.lastchar;
Printf.printf "widths:"; Array.iter (Printf.printf " %i") t.widths; Printf.printf "\n"; Printf.printf "widths:"; Array.iter (Printf.printf " %i") t.widths; Printf.printf "\n";
Printf.printf "fontfile of length %i\n" (Pdfio.bytes_size t.subset_fontfile); Printf.printf "fontfile of length %i\n" (Pdfio.bytes_size t.subset_fontfile);
Printf.printf "subset:"; iter (Printf.printf " U+%04X") t.subset; Printf.printf "\n"; Printf.printf "subset:"; iter (Printf.printf " U+%04X") t.subset; Printf.printf "\n";
Printf.printf "tounicode:"; Printf.printf "tounicode:\n";
begin match t.tounicode with begin match t.tounicode with
| None -> Printf.printf "None"; | None -> Printf.printf "None";
| Some table -> Hashtbl.iter (fun k v -> Printf.printf "%i --> %s\n" k v) table | Some table -> iter (fun (k, v) -> Printf.printf "%i --> U+%s\n" k (hex v)) (sort compare (list_of_hashtbl table))
end; end;
Printf.printf "\n" Printf.printf "\n"