Back into format 4 problem

This commit is contained in:
John Whitington 2023-06-12 14:06:41 +01:00
parent 09986b5198
commit 7a513260e9
1 changed files with 9 additions and 8 deletions

View File

@ -25,7 +25,7 @@ type t =
subset : int list; subset : int list;
tounicode : (int, string) Hashtbl.t option} tounicode : (int, string) Hashtbl.t option}
let dbg = ref true let dbg = ref false
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"]
@ -551,8 +551,9 @@ let parse ?(subset=[]) data encoding =
| (_, _, o, _)::_ -> read_hmtx_table numOfLongHorMetrics (mk_b (i32toi o)) | (_, _, o, _)::_ -> read_hmtx_table numOfLongHorMetrics (mk_b (i32toi o))
| [] -> raise (Pdf.PDFError "No hmtx table found in TrueType font") | [] -> raise (Pdf.PDFError "No hmtx table found in TrueType font")
in in
Printf.printf "firstchar_1, lastchar_1, firstchar_2, lastchar_2 = %i, %i, %i%, %i\n" firstchar_1 lastchar_1 firstchar_2 lastchar_2;
let widths_1 = calculate_widths unitsPerEm encoding firstchar_1 lastchar_1 subset_1 !glyphcodes hmtxdata in let widths_1 = calculate_widths unitsPerEm encoding firstchar_1 lastchar_1 subset_1 !glyphcodes hmtxdata in
let widths_2 = calculate_widths unitsPerEm encoding firstchar_2 lastchar_2 subset_2 !glyphcodes hmtxdata in (*let widths_2 = calculate_widths unitsPerEm encoding firstchar_2 lastchar_2 subset_2 !glyphcodes hmtxdata in*)
let maxwidth = calculate_maxwidth unitsPerEm hmtxdata in let maxwidth = calculate_maxwidth unitsPerEm hmtxdata in
let stemv = calculate_stemv () in let stemv = calculate_stemv () in
let b = mk_b (i32toi locaoffset) in let b = mk_b (i32toi locaoffset) in
@ -566,23 +567,23 @@ let parse ?(subset=[]) data encoding =
subset_font major minor !tables indexToLocFormat subset_1 subset_font major minor !tables indexToLocFormat subset_1
encoding !glyphcodes loca mk_b glyfoffset data encoding !glyphcodes loca mk_b glyfoffset data
in in
let second_subset = (*let second_subset =
subset_font major minor !tables indexToLocFormat subset_2 subset_font major minor !tables indexToLocFormat subset_2
encoding !glyphcodes loca mk_b glyfoffset data encoding !glyphcodes loca mk_b glyfoffset data
in in*)
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 [hd 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*)
[{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; [{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}]
@ if fontpack_experiment then (*@ if fontpack_experiment then
[{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; [{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}] else [] tounicode = second_tounicode}] else []*)