This commit is contained in:
John Whitington 2022-09-20 14:54:45 +01:00
parent 4aa51e1554
commit 676c862451
3 changed files with 8 additions and 10 deletions

View File

@ -3724,7 +3724,7 @@ let go () =
| StandardFont f -> Some (Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding)) | StandardFont f -> Some (Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding))
| OtherFont f -> None (* it's in fontname *) | OtherFont f -> None (* it's in fontname *)
| FontToEmbed (fontfile, encoding) -> | FontToEmbed (fontfile, encoding) ->
Some (Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~text:"" ~encoding) Some (Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding)
in in
warn_prerotate range pdf; warn_prerotate range pdf;
let pdf = let pdf =
@ -3991,7 +3991,7 @@ let go () =
match args.font with match args.font with
| StandardFont f -> Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding) | StandardFont f -> Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding)
| FontToEmbed (fontfile, encoding) -> | FontToEmbed (fontfile, encoding) ->
Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~text:"" ~encoding Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding
| _ -> error "TOC: not a standard or embedded font" | _ -> error "TOC: not a standard or embedded font"
in in
let pdf = Cpdftoc.typeset_table_of_contents ~font ~fontsize:args.fontsize ~title:args.toc_title ~bookmark:args.toc_bookmark pdf in let pdf = Cpdftoc.typeset_table_of_contents ~font ~fontsize:args.fontsize ~title:args.toc_title ~bookmark:args.toc_bookmark pdf in
@ -4002,7 +4002,7 @@ let go () =
match args.font with match args.font with
| StandardFont f -> Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding) | StandardFont f -> Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding)
| FontToEmbed (fontfile, encoding) -> | FontToEmbed (fontfile, encoding) ->
Cpdfembed.embed_truetype (Pdf.empty ()) ~fontfile ~fontname:args.fontname ~text:"" ~encoding Cpdfembed.embed_truetype (Pdf.empty ()) ~fontfile ~fontname:args.fontname ~codepoints:[] ~encoding
| _ -> error "text to PDF: not a standard or embedded font" | _ -> error "text to PDF: not a standard or embedded font"
in in
let pdf = let pdf =

View File

@ -44,8 +44,7 @@ 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 embed_truetype pdf ~fontfile ~fontname ~text ~encoding = let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
let unicodepoints = Pdftext.codepoints_of_utf8 text in
let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in
let encoding_table = Pdftext.reverse_table_of_encoding encoding in let encoding_table = Pdftext.reverse_table_of_encoding encoding in
let accepted_unicodepoints = let accepted_unicodepoints =
@ -53,7 +52,7 @@ let embed_truetype pdf ~fontfile ~fontname ~text ~encoding =
(fun u -> (fun u ->
(u, pdfcode_of_unicode_codepoint encoding_table glyphlist_table u)) (u, pdfcode_of_unicode_codepoint encoding_table glyphlist_table u))
(calc_accepted_unicodepoints (calc_accepted_unicodepoints
encoding_table glyphlist_table unicodepoints) encoding_table glyphlist_table codepoints)
in in
let f = Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile ~encoding in let f = Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile ~encoding in
let name_1 = basename () in let name_1 = basename () in

View File

@ -1,6 +1,5 @@
(* Embed a TrueType font for the given set of UTF8 characters in the given (* Embed a TrueType font for the given set of unicode codepoints in the given
encoding, adding it as an object to the PDF, and returning the number of encoding, adding the fontfile to the PDF and returning the font object. *)
that object. *)
val embed_truetype : val embed_truetype :
Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> text:string -> Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> codepoints:int list ->
encoding:Pdftext.encoding -> Pdftext.font encoding:Pdftext.encoding -> Pdftext.font