more
This commit is contained in:
parent
be610916d4
commit
e3421cdcc2
|
@ -8,6 +8,11 @@ type cpdffont =
|
||||||
| EmbedInfo of {fontfile : Pdfio.bytes; fontname : string; encoding : Pdftext.encoding}
|
| EmbedInfo of {fontfile : Pdfio.bytes; fontname : string; encoding : Pdftext.encoding}
|
||||||
| ExistingNamedFont of string
|
| ExistingNamedFont of string
|
||||||
|
|
||||||
|
let get_char (fonts, table) u =
|
||||||
|
match Hashtbl.find table u with
|
||||||
|
| (n, charcode) -> Some (charcode, n, List.nth fonts n)
|
||||||
|
| exception Not_found -> None
|
||||||
|
|
||||||
let pdfcode_of_unicode_codepoint encoding_table glyphlist_table u =
|
let pdfcode_of_unicode_codepoint encoding_table glyphlist_table u =
|
||||||
try
|
try
|
||||||
Some (Hashtbl.find encoding_table (Hashtbl.find glyphlist_table [u]))
|
Some (Hashtbl.find encoding_table (Hashtbl.find glyphlist_table [u]))
|
||||||
|
|
|
@ -9,6 +9,8 @@ type cpdffont =
|
||||||
| EmbedInfo of {fontfile : Pdfio.bytes; fontname : string; encoding : Pdftext.encoding}
|
| EmbedInfo of {fontfile : Pdfio.bytes; fontname : string; encoding : Pdftext.encoding}
|
||||||
| ExistingNamedFont of string
|
| ExistingNamedFont of string
|
||||||
|
|
||||||
|
val get_char : t -> int -> (int * int * Pdftext.font) option
|
||||||
|
|
||||||
val embed_truetype :
|
val embed_truetype :
|
||||||
Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> codepoints:int list ->
|
Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> codepoints:int list ->
|
||||||
encoding:Pdftext.encoding -> t
|
encoding:Pdftext.encoding -> t
|
||||||
|
|
|
@ -5,12 +5,6 @@ let used_characters t =
|
||||||
let codepoints = Pdftext.codepoints_of_utf8 t in
|
let codepoints = Pdftext.codepoints_of_utf8 t in
|
||||||
setify codepoints
|
setify codepoints
|
||||||
|
|
||||||
(* Just first font, expand later. Move into cpdfembed? *)
|
|
||||||
let get_char (fonts, table) u =
|
|
||||||
match Hashtbl.find table u with
|
|
||||||
| (n, charcode) -> Some charcode
|
|
||||||
| exception Not_found -> None
|
|
||||||
|
|
||||||
let rec of_utf8_with_newlines fontpack t =
|
let rec of_utf8_with_newlines fontpack t =
|
||||||
let items = ref [] in
|
let items = ref [] in
|
||||||
let buf = ref [] in
|
let buf = ref [] in
|
||||||
|
@ -18,8 +12,8 @@ let rec of_utf8_with_newlines fontpack t =
|
||||||
let charcodes_of_codepoints cs =
|
let charcodes_of_codepoints cs =
|
||||||
option_map
|
option_map
|
||||||
(fun u ->
|
(fun u ->
|
||||||
match get_char fontpack u with
|
match Cpdfembed.get_char fontpack u with
|
||||||
| Some c -> Some (char_of_int c)
|
| Some (c, _, _) -> Some (char_of_int c)
|
||||||
| None -> Printf.printf "No glyph for unicode U+%04X in this font\n" u; None)
|
| None -> Printf.printf "No glyph for unicode U+%04X in this font\n" u; None)
|
||||||
cs
|
cs
|
||||||
in
|
in
|
||||||
|
|
Loading…
Reference in New Issue