From 44f62e49ca07d72a177d8f79a427ca15a2231aed Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 13 Oct 2022 19:33:52 +0100 Subject: [PATCH] more --- cpdftruetype.ml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/cpdftruetype.ml b/cpdftruetype.ml index 31ed9a8..080883c 100644 --- a/cpdftruetype.ml +++ b/cpdftruetype.ml @@ -499,8 +499,11 @@ let parse ?(subset=[]) data encoding = | (_, _, o, l)::_ -> o, l | [] -> raise (Pdf.PDFError "No loca table found in TrueType font") in + let subset_1 = if subset = [] then [] else tl subset in + let subset_2 = if subset = [] then [] else [hd subset] in let flags = calculate_flags italicangle in - let firstchar, lastchar = calculate_limits subset in + let firstchar_1, lastchar_1 = calculate_limits subset_1 in + let firstchar_2, lastchar_2 = calculate_limits subset_2 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 @@ -511,7 +514,8 @@ let parse ?(subset=[]) data encoding = | (_, _, o, _)::_ -> read_hmtx_table numOfLongHorMetrics (mk_b (i32toi o)) | [] -> raise (Pdf.PDFError "No hmtx table found in TrueType font") in - let widths = calculate_widths unitsPerEm encoding firstchar lastchar subset !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 maxwidth = calculate_maxwidth unitsPerEm hmtxdata in let stemv = calculate_stemv () in let b = mk_b (i32toi locaoffset) in @@ -522,11 +526,11 @@ let parse ?(subset=[]) data encoding = | [] -> raise (Pdf.PDFError "No glyf table found in TrueType font") in let main_subset = - subset_font major minor !tables indexToLocFormat (if subset = [] then [] else tl subset) + subset_font major minor !tables indexToLocFormat subset_1 encoding !glyphcodes loca mk_b glyfoffset data in let second_subset = - subset_font major minor !tables indexToLocFormat (if subset = [] then [] else [hd subset]) + subset_font major minor !tables indexToLocFormat subset_2 encoding !glyphcodes loca mk_b glyfoffset data in let second_tounicode = @@ -536,9 +540,9 @@ let parse ?(subset=[]) data encoding = Some h in [{flags; minx; miny; maxx; maxy; italicangle; ascent; descent; - capheight; stemv; xheight; avgwidth; maxwidth; firstchar; lastchar; - widths; subset_fontfile = main_subset; subset = if subset = [] then [] else tl subset; tounicode = None}; + capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_1; lastchar = lastchar_1; + widths = widths_1; subset_fontfile = main_subset; subset = subset_1; tounicode = None}; {flags; minx; miny; maxx; maxy; italicangle; ascent; descent; - capheight; stemv; xheight; avgwidth; maxwidth; firstchar; lastchar; - widths; subset_fontfile = second_subset; subset = if subset = [] then [] else [hd subset]; + capheight; stemv; xheight; avgwidth; maxwidth; firstchar = firstchar_2; lastchar = lastchar_2; + widths = widths_2; subset_fontfile = second_subset; subset = subset_2; tounicode = second_tounicode}]