From 5503952a9a4c69635081631caefd048e99b67e22 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 13 Sep 2022 17:20:37 +0100 Subject: [PATCH] more --- cpdfembed.ml | 7 +++++++ cpdfembed.mli | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/cpdfembed.ml b/cpdfembed.ml index f0d2764..c95051e 100644 --- a/cpdfembed.ml +++ b/cpdfembed.ml @@ -50,6 +50,7 @@ let string_of_encoding = function | Pdftext.StandardEncoding -> "/StandardEncoding" | _ -> failwith "unknown encoding" +(* FIXME add "" = full subset *) let embed_truetype pdf ~fontfile ~fontname ~text ~encoding = let unicodepoints = Pdftext.codepoints_of_utf8 text in let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in @@ -101,3 +102,9 @@ let embed_truetype pdf ~fontfile ~fontname ~text ~encoding = widths in Pdf.addobj pdf font + +(* For now, to get a Pdftext.font, we build it with the function above using an empty (i.e. full) subset, put it in an empty PDF and then read it back. This will be fixed later. *) +let font_of_truetype ~fontfile ~fontname ~encoding = + let pdf = Pdf.empty () in + let fontobjnum = embed_truetype pdf ~fontfile ~fontname ~text:"" ~encoding in + Pdftext.read_font pdf (Pdf.lookup_obj pdf fontobjnum) diff --git a/cpdfembed.mli b/cpdfembed.mli index 4f3a4d7..8047757 100644 --- a/cpdfembed.mli +++ b/cpdfembed.mli @@ -4,3 +4,8 @@ val embed_truetype : Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> text:string -> encoding:Pdftext.encoding -> int + +(* Eventually, we will just have this, and a subsetting function. Then we will + use Pdftext.write_font to write it. *) +val font_of_truetype : + fontfile:Pdfio.bytes -> fontname:string -> encoding:Pdftext.encoding -> Pdftext.font