All now pushed into Cpdftruetype
This commit is contained in:
parent
2029657153
commit
8f0f153a85
23
cpdfembed.ml
23
cpdfembed.ml
|
@ -22,24 +22,6 @@ let get_char (fonts, table) u =
|
||||||
| (n, charcode) -> Some (charcode, n, List.nth fonts n)
|
| (n, charcode) -> Some (charcode, n, List.nth fonts n)
|
||||||
| exception Not_found -> None
|
| exception Not_found -> None
|
||||||
|
|
||||||
let pdfcode_of_unicode_codepoint encoding_table glyphlist_table u =
|
|
||||||
try
|
|
||||||
Some (Hashtbl.find encoding_table (Hashtbl.find glyphlist_table [u]))
|
|
||||||
with
|
|
||||||
Not_found -> None
|
|
||||||
|
|
||||||
let calc_accepted_unicodepoints encoding_table glyphlist_table codepoints =
|
|
||||||
sort (fun a b -> compare b a) (* FIXME: Remove once subset experiment gone *)
|
|
||||||
(setify
|
|
||||||
(option_map
|
|
||||||
(fun u ->
|
|
||||||
match
|
|
||||||
pdfcode_of_unicode_codepoint encoding_table glyphlist_table u
|
|
||||||
with
|
|
||||||
| Some _ -> Some u
|
|
||||||
| None -> None)
|
|
||||||
codepoints))
|
|
||||||
|
|
||||||
let fontnum = ref 0
|
let fontnum = ref 0
|
||||||
|
|
||||||
let basename () =
|
let basename () =
|
||||||
|
@ -104,9 +86,6 @@ let make_fontpack_hashtable fs =
|
||||||
table
|
table
|
||||||
|
|
||||||
let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
|
let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
|
||||||
let glyphlist_table = Pdfglyphlist.reverse_glyph_hashes () in
|
let fs = Cpdftruetype.parse ~subset:codepoints fontfile encoding in
|
||||||
let encoding_table = Pdftext.reverse_table_of_encoding encoding in
|
|
||||||
let accepted_unicodepoints = calc_accepted_unicodepoints encoding_table glyphlist_table codepoints in
|
|
||||||
let fs = Cpdftruetype.parse ~subset:accepted_unicodepoints fontfile encoding in
|
|
||||||
let subsets_and_their_fonts = map (make_single_font ~fontname ~encoding pdf) fs in
|
let subsets_and_their_fonts = map (make_single_font ~fontname ~encoding pdf) fs in
|
||||||
(map snd subsets_and_their_fonts, make_fontpack_hashtable subsets_and_their_fonts)
|
(map snd subsets_and_their_fonts, make_fontpack_hashtable subsets_and_their_fonts)
|
||||||
|
|
|
@ -45,7 +45,7 @@ let rec of_utf8_with_newlines fontpack fontsize t =
|
||||||
|
|
||||||
let typeset ~papersize ~font ~fontsize text =
|
let typeset ~papersize ~font ~fontsize text =
|
||||||
let pdf = Pdf.empty () in
|
let pdf = Pdf.empty () in
|
||||||
let codepoints = Pdftext.codepoints_of_utf8 (Pdfio.string_of_bytes text) in
|
let codepoints = setify (Pdftext.codepoints_of_utf8 (Pdfio.string_of_bytes text)) in
|
||||||
let fontpack =
|
let fontpack =
|
||||||
match font with
|
match font with
|
||||||
| Cpdfembed.PreMadeFontPack t -> t
|
| Cpdfembed.PreMadeFontPack t -> t
|
||||||
|
|
|
@ -443,8 +443,8 @@ let _ =
|
||||||
let parse ?(subset=[]) data encoding =
|
let parse ?(subset=[]) data encoding =
|
||||||
(*if !dbg then*)
|
(*if !dbg then*)
|
||||||
begin
|
begin
|
||||||
Printf.printf "********SUBSET is ";
|
Printf.printf "********Cpdftruetype.parse SUBSET is ";
|
||||||
iter (Printf.printf "%i ") subset;
|
iter (Printf.printf "U+%04X ") subset;
|
||||||
Printf.printf "\n"
|
Printf.printf "\n"
|
||||||
end;
|
end;
|
||||||
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in
|
let mk_b byte_offset = bitbytes_of_input (let i = input_of_bytes data in i.seek_in byte_offset; i) in
|
||||||
|
|
Loading…
Reference in New Issue