Fighting with embedding
This commit is contained in:
parent
0c1d6719e0
commit
fc3c7539a4
|
@ -74,20 +74,22 @@ let make_single_font ~fontname ~encoding pdf f =
|
||||||
encoding})
|
encoding})
|
||||||
|
|
||||||
let make_fontpack_hashtable fs =
|
let make_fontpack_hashtable fs =
|
||||||
Printf.printf "make_fontpack_hashtable\n";
|
|
||||||
let indexes = indx0 fs in
|
let indexes = indx0 fs in
|
||||||
let table = null_hash () in
|
let table = null_hash () in
|
||||||
iter2
|
iter2
|
||||||
(fun i (subset, f) ->
|
(fun i (subset, f) ->
|
||||||
let charcode_extractor = Pdftext.charcode_extractor_of_font_real f in
|
let charcode_extractor = Pdftext.charcode_extractor_of_font_real f in
|
||||||
iter
|
iter
|
||||||
(fun u -> Hashtbl.add table u (i, unopt (charcode_extractor u)))
|
(fun u ->
|
||||||
|
match charcode_extractor u with
|
||||||
|
| Some x -> Hashtbl.add table u (i, x)
|
||||||
|
| None -> Printf.printf "charcode_extractor could not find char in make_fontpack_hashtable\n")
|
||||||
subset)
|
subset)
|
||||||
indexes fs;
|
indexes fs;
|
||||||
Printf.printf "end of make_fontpack_hashtable\n";
|
|
||||||
table
|
table
|
||||||
|
|
||||||
let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
|
let embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding =
|
||||||
let fs = Cpdftruetype.parse ~subset:codepoints fontfile encoding in
|
let fs = Cpdftruetype.parse ~subset:codepoints 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
|
||||||
|
Printf.printf "embed_truetype finished\n";
|
||||||
(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)
|
||||||
|
|
|
@ -58,6 +58,7 @@ let typeset ~papersize ~font ~fontsize text =
|
||||||
let margin =
|
let margin =
|
||||||
Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15.
|
Pdfunits.points (Pdfpaper.width papersize) (Pdfpaper.unit papersize) /. 15.
|
||||||
in
|
in
|
||||||
|
Printf.printf "**** made instructions for page\n";
|
||||||
let firstfont = hd (keep (function Cpdftype.Font _ -> true | _ -> false) instrs) in
|
let firstfont = hd (keep (function Cpdftype.Font _ -> true | _ -> false) instrs) in
|
||||||
let instrs = [firstfont; Cpdftype.BeginDocument] @ instrs in
|
let instrs = [firstfont; Cpdftype.BeginDocument] @ instrs in
|
||||||
let pages = Cpdftype.typeset margin margin margin margin papersize pdf instrs in
|
let pages = Cpdftype.typeset margin margin margin margin papersize pdf instrs in
|
||||||
|
|
Loading…
Reference in New Issue