This commit is contained in:
John Whitington 2022-09-24 17:19:05 +01:00
parent bfcfaddec3
commit 6589824a8f
1 changed files with 12 additions and 1 deletions

View File

@ -2,8 +2,13 @@
open Pdfutil open Pdfutil
open Cpdferror open Cpdferror
(* Keep a record of charcodes used for font subsetting. *)
let used = null_hash () let used = null_hash ()
(* If we have used a TTF font, put its name and object number here. Then we
know we put it there, and can avoid writing it anew across ANDS. *)
let glob_pdfobjnum = null_hash ()
type color = type color =
Grey of float Grey of float
| RGB of float * float * float | RGB of float * float * float
@ -515,7 +520,13 @@ let
| Some (StandardFont (f, encoding)) -> | Some (StandardFont (f, encoding)) ->
make_font embed encoding (Pdftext.string_of_standard_font f) make_font embed encoding (Pdftext.string_of_standard_font f)
| Some f -> | Some f ->
Pdf.Indirect (Pdftext.write_font pdf f) begin match Hashtbl.find glob_pdfobjnum fontname with
| exception Not_found ->
let i = Pdftext.write_font pdf f in
Hashtbl.add glob_pdfobjnum fontname i; Pdf.Indirect i
| i ->
Pdf.Indirect i
end
| None -> | None ->
let firstpage = let firstpage =
List.nth (Pdfpage.pages_of_pagetree pdf) (hd pages - 1) List.nth (Pdfpage.pages_of_pagetree pdf) (hd pages - 1)