This commit is contained in:
John Whitington 2022-09-27 15:43:49 +01:00
parent 8bb895d2fe
commit ec1ef96d21
1 changed files with 6 additions and 10 deletions

View File

@ -171,12 +171,8 @@ let rec string_of_encoding = function
| Pdftext.WinAnsiEncoding -> "WinAnsiEncoding" | Pdftext.WinAnsiEncoding -> "WinAnsiEncoding"
| _ -> error "unknown encoding" | _ -> error "unknown encoding"
let make_font embed encoding fontname = let make_font embed pdf font =
Pdf.Dictionary Pdf.Indirect (Pdftext.write_font pdf font)
[("/Type", Pdf.Name "/Font");
("/Subtype", Pdf.Name "/TrueType");
("/Encoding", Pdf.Name ("/" ^ string_of_encoding encoding));
("/BaseFont", Pdf.Name ("/" ^ fontname))]
let extract_page_text only_fontsize pdf _ page = let extract_page_text only_fontsize pdf _ page =
let text_extractor = ref None in let text_extractor = ref None in
@ -401,9 +397,9 @@ let addtext
in in
let newresources = let newresources =
match font with match font with
| Some (Pdftext.StandardFont _) -> | Some (Pdftext.StandardFont _ as font) ->
let newfontdict = let newfontdict =
Pdf.add_dict_entry fontdict unique_fontname (make_font embed encoding fontname) Pdf.add_dict_entry fontdict unique_fontname (make_font embed pdf font)
in in
Pdf.add_dict_entry resources' "/Font" newfontdict Pdf.add_dict_entry resources' "/Font" newfontdict
| Some f -> | Some f ->
@ -491,8 +487,8 @@ let
let realfontname = ref fontname in let realfontname = ref fontname in
let fontpdfobj = let fontpdfobj =
match font with match font with
| Some (StandardFont (f, encoding)) -> | Some (StandardFont _ as font) ->
make_font embed encoding (Pdftext.string_of_standard_font f) make_font embed pdf font
| Some f -> | Some f ->
begin match Hashtbl.find glob_pdfobjnum fontname with begin match Hashtbl.find glob_pdfobjnum fontname with
| exception Not_found -> | exception Not_found ->