This commit is contained in:
John Whitington 2022-09-19 14:30:32 +01:00
parent 4c467a896d
commit cab4a6c4a0
2 changed files with 3 additions and 10 deletions

View File

@ -44,12 +44,6 @@ let basename () =
incr fontnum; incr fontnum;
"AAAAA" ^ string_of_char (char_of_int (!fontnum + 65)) "AAAAA" ^ string_of_char (char_of_int (!fontnum + 65))
let string_of_encoding = function
| Pdftext.WinAnsiEncoding -> "/WinAnsiEncoding"
| Pdftext.MacRomanEncoding -> "/MacRomanEncoding"
| Pdftext.StandardEncoding -> "/StandardEncoding"
| _ -> failwith "unknown encoding"
let embed_truetype pdf ~fontfile ~fontname ~text ~encoding = let embed_truetype pdf ~fontfile ~fontname ~text ~encoding =
let unicodepoints = Pdftext.codepoints_of_utf8 text in let unicodepoints = Pdftext.codepoints_of_utf8 text in
let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in

View File

@ -21,7 +21,7 @@ type t =
widths : int array; widths : int array;
subset : Pdfio.bytes} subset : Pdfio.bytes}
let dbg = ref true (* text-based debug *) let dbg = ref false (* text-based debug *)
(* 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 =
@ -141,15 +141,14 @@ 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")
(* FIXME length checking *)
let read_os2_table b blength = let read_os2_table 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;
let xAvgCharWidth = read_short b in let xAvgCharWidth = read_short b in
discard_bytes b 64; (* discard 14 entries usWeightClass...fsLastCharIndex *) discard_bytes b 64; (* discard 14 entries usWeightClass...fsLastCharIndex *)
(* -- end of original OS/2 Version 0 Truetype table. Must check length before reading now. *) (* -- end of original OS/2 Version 0 Truetype table. Must check length before reading now. *)
let sTypoAscender = read_short b in let sTypoAscender = if blength > 68 then read_short b else 0 in
let sTypoDescender = read_short b in let sTypoDescender = if blength > 68 then read_short b else 0 in
discard_bytes b 6; (* discard sTypoLineGap...usWinDescent *) discard_bytes b 6; (* discard sTypoLineGap...usWinDescent *)
(* -- end of OpenType version 0 table *) (* -- end of OpenType version 0 table *)
discard_bytes b 8; (* discard ulCodePageRange1, ulCodePageRange2 *) discard_bytes b 8; (* discard ulCodePageRange1, ulCodePageRange2 *)