From 8f7d53c208ac76580fdd6bfbbecdd87014cd3504 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 4 Oct 2022 14:59:42 +0100 Subject: [PATCH] more --- cpdftruetype.ml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cpdftruetype.ml b/cpdftruetype.ml index abfb15c..00049a9 100644 --- a/cpdftruetype.ml +++ b/cpdftruetype.ml @@ -23,8 +23,9 @@ type t = let dbg = ref false (* text-based debug *) +(* Don't list loca or glyf here, because we do them manually... *) let required_tables = - ["head"; "hhea"; "loca"; "cmap"; "maxp"; "cvt "; "glyf"; "prep"; "hmtx"; "fpgm"] + ["head"; "hhea"; "cmap"; "maxp"; "cvt "; "prep"; "hmtx"; "fpgm"] (* 32-bit signed fixed-point number (16.16) returned as two ints *) let read_fixed b = @@ -130,7 +131,7 @@ let read_loca_table indexToLocFormat numGlyphs b = for x = 1 to Array.length arr - 1 do if arr.(x) = arr.(x - 1) then arr.(x - 1) <- -1l done; - if arr <> [||] then arr.(Array.length arr - 1) <- -1l + (*if arr <> [||] then arr.(Array.length arr - 1) <- -1l*) in match indexToLocFormat with | 0 -> @@ -141,6 +142,19 @@ let read_loca_table indexToLocFormat numGlyphs b = fix_empties arr; arr | _ -> raise (Pdf.PDFError "Unknown indexToLocFormat in read_loca_table") +let write_loca_table indexToLocFormat bs arr = + let arr = Array.copy arr in + for x = 1 to Array.length arr do + if arr.(x) = -1l then arr.(x) <- arr.(x - 1) + done; + Array.iter + (fun x -> + match indexToLocFormat with + | 0 -> putval bs 16 (i32div x 2l) + | 1 -> putval bs 32 x + | _ -> raise (Pdf.PDFError "Unknown indexToLocFormat in write_loca_table")) + arr + let read_os2_table unitsPerEm b blength = let version = read_ushort b in if !dbg then Printf.printf "OS/2 table blength = %i bytes, version number = %i\n" blength version;