This commit is contained in:
John Whitington 2022-10-04 14:59:42 +01:00
parent aa181a9d7c
commit 8f7d53c208
1 changed files with 16 additions and 2 deletions

View File

@ -23,8 +23,9 @@ type t =
let dbg = ref false (* text-based debug *) let dbg = ref false (* text-based debug *)
(* Don't list loca or glyf here, because we do them manually... *)
let required_tables = 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 *) (* 32-bit signed fixed-point number (16.16) returned as two ints *)
let read_fixed b = let read_fixed b =
@ -130,7 +131,7 @@ let read_loca_table indexToLocFormat numGlyphs b =
for x = 1 to Array.length arr - 1 do for x = 1 to Array.length arr - 1 do
if arr.(x) = arr.(x - 1) then arr.(x - 1) <- -1l if arr.(x) = arr.(x - 1) then arr.(x - 1) <- -1l
done; done;
if arr <> [||] then arr.(Array.length arr - 1) <- -1l (*if arr <> [||] then arr.(Array.length arr - 1) <- -1l*)
in in
match indexToLocFormat with match indexToLocFormat with
| 0 -> | 0 ->
@ -141,6 +142,19 @@ let read_loca_table indexToLocFormat numGlyphs b =
fix_empties arr; arr fix_empties arr; arr
| _ -> raise (Pdf.PDFError "Unknown indexToLocFormat in read_loca_table") | _ -> 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 read_os2_table unitsPerEm b blength =
let version = read_ushort b in let version = read_ushort b in
if !dbg then Printf.printf "OS/2 table blength = %i bytes, version number = %i\n" blength version; if !dbg then Printf.printf "OS/2 table blength = %i bytes, version number = %i\n" blength version;