From a257ce355acf4533c5148ea4a462348583d897a8 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 23 Nov 2022 15:15:17 +0000 Subject: [PATCH] more --- cpdftruetype.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cpdftruetype.ml b/cpdftruetype.ml index a4ab522..ed70abf 100644 --- a/cpdftruetype.ml +++ b/cpdftruetype.ml @@ -301,6 +301,12 @@ let padword n = let r = n + (if n mod 4 = 0 then 0 else 4 - n mod 4) in i32ofi r +let fonumr = ref (-1) + +let fonum () = + fonumr += 1; + !fonumr + let subset_font major minor tables indexToLocFormat subset encoding cmap loca mk_b glyfoffset data = let tables = Array.of_list (sort (fun (_, _, o, _) (_, _, o', _) -> compare o o') tables) in let tablesout = ref [] in @@ -402,7 +408,7 @@ let subset_font major minor tables indexToLocFormat subset encoding cmap loca mk newtables; let bytes = bytes_of_write_bitstream bs in if !dbg then Printf.printf "Made subset font of length %i bytes\n" (bytes_size bytes); - let o = open_out_bin "fontout.ttf" in + let o = open_out_bin ("fontout" ^ string_of_int (fonum ()) ^ ".ttf") in output_string o (string_of_bytes bytes); close_out o; bytes @@ -522,7 +528,7 @@ let parse ?(subset=[]) data encoding = end; let flags = calculate_flags italicangle in let firstchar_1, lastchar_1 = calculate_limits subset_1 in - let firstchar_2, lastchar_2 = calculate_limits subset_2 in + let firstchar_2, lastchar_2 = (0, length subset_2 - 1) in let numOfLongHorMetrics = match keep (function (t, _, _, _) -> string_of_tag t = "hhea") !tables with | (_, _, o, l)::_ -> let b = mk_b (i32toi o) in read_hhea_table b