Beginning -add-text/TTF
This commit is contained in:
parent
7408a79186
commit
6a92be56cf
|
@ -231,7 +231,7 @@ let expand_lines text time pdf endpage extract_text_font_size filename bates bat
|
||||||
|
|
||||||
let addtext
|
let addtext
|
||||||
time lines linewidth outline fast colour fontname encoding bates batespad
|
time lines linewidth outline fast colour fontname encoding bates batespad
|
||||||
fontsize fontpack font fontpdfobj underneath position hoffset voffset text pages
|
fontsize fontpack font fontpdfobj fontpackpdfobjs underneath position hoffset voffset text pages
|
||||||
cropbox opacity justification filename extract_text_font_size shift raw pdf
|
cropbox opacity justification filename extract_text_font_size shift raw pdf
|
||||||
=
|
=
|
||||||
let endpage = Pdfpage.endpage pdf in
|
let endpage = Pdfpage.endpage pdf in
|
||||||
|
@ -512,29 +512,27 @@ let
|
||||||
| Some (Pdftext.StandardFont (_, e)) -> e
|
| Some (Pdftext.StandardFont (_, e)) -> e
|
||||||
| Some (Pdftext.SimpleFont {encoding}) -> encoding
|
| Some (Pdftext.SimpleFont {encoding}) -> encoding
|
||||||
| _ -> Pdftext.WinAnsiEncoding
|
| _ -> Pdftext.WinAnsiEncoding
|
||||||
|
in
|
||||||
|
let fontpackpdfobjs =
|
||||||
|
match cpdffont with
|
||||||
|
| Cpdfembed.EmbedInfo {fontfile; fontname; encoding} ->
|
||||||
|
let codepoints = map fst (list_of_hashtbl used) in
|
||||||
|
let fonts = fst (Cpdfembed.embed_truetype !pdf ~fontfile ~fontname ~codepoints ~encoding) in
|
||||||
|
map (Pdftext.write_font !pdf) fonts
|
||||||
|
| _ -> []
|
||||||
in
|
in
|
||||||
iter
|
iter
|
||||||
(fun line ->
|
(fun line ->
|
||||||
let voff, hoff = !voffset, 0. in
|
let voff, hoff = !voffset, 0. in
|
||||||
pdf :=
|
pdf :=
|
||||||
addtext time lines linewidth outline fast colour !realfontname encoding
|
addtext time lines linewidth outline fast colour !realfontname encoding
|
||||||
bates batespad fontsize fontpack font fontpdfobj underneath position hoff voff line
|
bates batespad fontsize fontpack font fontpdfobj fontpackpdfobjs underneath
|
||||||
pages cropbox opacity justification filename extract_text_font_size shift
|
position hoff voff line pages cropbox opacity justification filename
|
||||||
raw !pdf;
|
extract_text_font_size shift raw !pdf;
|
||||||
voffset := !voffset +. (linespacing *. fontsize))
|
voffset := !voffset +. (linespacing *. fontsize))
|
||||||
lines;
|
lines;
|
||||||
(* FIXME Here we need to embed all the fonts, not just one *)
|
|
||||||
begin match cpdffont with
|
|
||||||
| Cpdfembed.EmbedInfo {fontfile; fontname; encoding} ->
|
|
||||||
let codepoints = map fst (list_of_hashtbl used) in
|
|
||||||
let objnum = match fontpdfobj with Pdf.Indirect i -> i | _ -> failwith "bad fontpdfobj" in
|
|
||||||
let font = hd (fst (Cpdfembed.embed_truetype !pdf ~fontfile ~fontname ~codepoints ~encoding)) in
|
|
||||||
ignore (Pdftext.write_font ~objnum !pdf font)
|
|
||||||
| _ -> ()
|
|
||||||
end;
|
|
||||||
!pdf
|
!pdf
|
||||||
|
|
||||||
|
|
||||||
let addrectangle
|
let addrectangle
|
||||||
fast (w, h) colour outline linewidth opacity position relative_to_cropbox
|
fast (w, h) colour outline linewidth opacity position relative_to_cropbox
|
||||||
underneath range pdf
|
underneath range pdf
|
||||||
|
|
|
@ -106,4 +106,3 @@ let rec collate_runs cfn a = function
|
||||||
let collate_runs = function
|
let collate_runs = function
|
||||||
| [] -> []
|
| [] -> []
|
||||||
| (_, fontnum, _)::_ as l -> collate_runs fontnum [] l
|
| (_, fontnum, _)::_ as l -> collate_runs fontnum [] l
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ let dbg =
|
||||||
(* Pdfe.logger := (fun s -> print_string s; flush stdout) *)
|
(* Pdfe.logger := (fun s -> print_string s; flush stdout) *)
|
||||||
ref false
|
ref false
|
||||||
|
|
||||||
|
let test_subsetting = true
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{flags : int;
|
{flags : int;
|
||||||
minx : int;
|
minx : int;
|
||||||
|
@ -496,6 +498,7 @@ let write_font filename data =
|
||||||
close_out fh
|
close_out fh
|
||||||
|
|
||||||
let find_main encoding subset =
|
let find_main encoding subset =
|
||||||
|
if test_subsetting then (take subset 3, [drop subset 3]) else
|
||||||
let encoding_table = Pdftext.table_of_encoding encoding in
|
let encoding_table = Pdftext.table_of_encoding encoding in
|
||||||
let first, rest =
|
let first, rest =
|
||||||
List.partition
|
List.partition
|
||||||
|
|
Loading…
Reference in New Issue