This commit is contained in:
John Whitington 2022-10-04 22:15:14 +01:00
parent 1f6afaccd8
commit 3c10f50d68
3 changed files with 11 additions and 7 deletions

View File

@ -48,7 +48,7 @@ let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
let accepted_unicodepoints = let accepted_unicodepoints =
calc_accepted_unicodepoints encoding_table glyphlist_table codepoints calc_accepted_unicodepoints encoding_table glyphlist_table codepoints
in in
let f = hd (Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile ~encoding) in let f = hd (Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile encoding) in
let name_1 = basename () in let name_1 = basename () in
let module TT = Cpdftruetype in let module TT = Cpdftruetype in
let fontfile = let fontfile =

View File

@ -356,7 +356,7 @@ let remove_unneeded_tables major minor tables indexToLocFormat subset encoding c
close_out o; close_out o;
bytes bytes
let parse ?(subset=[]) data ~encoding = let parse ?(subset=[]) data encoding =
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in
let b = mk_b 0 in let b = mk_b 0 in
let major, minor = read_fixed b in let major, minor = read_fixed b in

View File

@ -1,4 +1,6 @@
(* Parse a TrueType font *) (* Parse and subset TrueType fonts *)
(* The type of a single parsed font, including everything needed to build a PDF font. *)
type t = type t =
{flags : int; {flags : int;
minx : int; minx : int;
@ -19,7 +21,9 @@ type t =
subset : Pdfio.bytes; subset : Pdfio.bytes;
tounicode : Pdfio.bytes option} tounicode : Pdfio.bytes option}
(* Parse the font, given the list of Unicode codepoints required for the subset (* Parse the given TrueType font file. It will return one or more fonts. The
and optionally their PDF codepoint too. Returns the information required for first, a plain Latin font in the given encoding. Others are for the
embedding this font in a PDF. *) additional characters in the font. For subsetting, or to return a full
val parse : ?subset:int list -> Pdfio.bytes -> encoding:Pdftext.encoding -> t list font-pack, you should supply a subset (a list of unicode codepoints whose
corresponding glyphs are required). *)
val parse : ?subset:int list -> Pdfio.bytes -> Pdftext.encoding -> t list