First sucessful higher character

This commit is contained in:
John Whitington 2023-06-13 16:48:21 +01:00
parent fc3c7539a4
commit 3a295f99f2
1 changed files with 28 additions and 7 deletions

View File

@ -25,6 +25,19 @@ type t =
subset : int list; subset : int list;
tounicode : (int, string) Hashtbl.t option} tounicode : (int, string) Hashtbl.t option}
let debug_t t =
Printf.printf "firstchar: %i\n" t.firstchar;
Printf.printf "lastchar: %i\n" t.lastchar;
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 "subset:"; iter (Printf.printf " U+%04X") t.subset; Printf.printf "\n";
Printf.printf "tounicode:";
begin match t.tounicode with
| None -> Printf.printf "None";
| Some table -> Hashtbl.iter (fun k v -> Printf.printf "%i --> %s\n" k v) 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"]
@ -591,17 +604,25 @@ let parse ?(subset=[]) data encoding =
let second_tounicode = let second_tounicode =
if subset = [] then None else if subset = [] then None else
let h = null_hash () in let h = null_hash () in
let s = (implode (tl (tl (explode (Pdftext.utf16be_of_codepoints [hd subset]))))) in let s = (implode (tl (tl (explode (Pdftext.utf16be_of_codepoints (tl subset)))))) in
Printf.printf "String for tounicode = %S\n" s; Printf.printf "String for tounicode = %S\n" s;
Hashtbl.add h 0 s; Hashtbl.add h 0 s;
Some h Some h
in in
Printf.printf "returning the font pack. Job done.\n"; Printf.printf "returning the fonts. Job done.\n";
[{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; let one =
{flags; minx; miny; maxx; maxy; italicangle; ascent; descent;
capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_1; lastchar = lastchar_1; capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_1; lastchar = lastchar_1;
widths = widths_1; subset_fontfile = main_subset; subset = subset_1; tounicode = None}] widths = widths_1; subset_fontfile = main_subset; subset = subset_1; tounicode = None}
@ in
[{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; let two =
{flags; minx; miny; maxx; maxy; italicangle; ascent; descent;
capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_2; lastchar = lastchar_2; capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_2; lastchar = lastchar_2;
widths = widths_2; subset_fontfile = second_subset; subset = subset_2; widths = widths_2; subset_fontfile = second_subset; subset = subset_2;
tounicode = second_tounicode}] tounicode = second_tounicode}
in
Printf.printf "\nMain subset:\n";
debug_t one;
Printf.printf "\nHigher subset:\n";
debug_t two;
[one; two]