diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 6a2b06c..0a7fc80 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -14,6 +14,8 @@ let exit n = begin try iter Sys.remove !tempfiles with _ -> exit n end; exit n +let null () = () + let initial_file_size = ref 0 let empty = Pdf.empty () @@ -1771,7 +1773,10 @@ let embed_font () = embed_font_inner args.font let _ = Cpdfdrawcontrol.embed_font := embed_font +let _ = Cpdfdrawcontrol.setdrawing := (fun () -> args.op <- Some Draw) + let setfont f = + (*Printf.printf "Cpdfcommand.setfont: |%s|\n%!" f;*) try let fontname, _ = Hashtbl.find Cpdfdrawcontrol.ttfs f in args.font <- EmbeddedFont f; diff --git a/cpdfcommand.mli b/cpdfcommand.mli index 75d8f68..7089877 100644 --- a/cpdfcommand.mli +++ b/cpdfcommand.mli @@ -8,3 +8,5 @@ val go_withargv : string array -> unit (**/**) exception StayOnError + +val null : unit -> unit diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 2e10c2f..0bf0b8d 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -248,22 +248,22 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func | Opacity v -> [Pdfops.Op_gs (extgstate "/ca" v)] | SOpacity v -> [Pdfops.Op_gs (extgstate "/CA" v)] | FontPack (identifier, cpdffont, codepoints) -> - (*Printf.printf "FontPack op: %s\n" identifier;*) + (*Printf.printf "FontPack op: |%s|\n%!" identifier;*) let fontpack = match Hashtbl.find !fontpacks identifier with | (fontpack, _) -> - (*Printf.printf "Cpdfdraw FontPack op: using existing fontpack %s\n" identifier;*) + (*Printf.printf "Cpdfdraw FontPack op: using existing fontpack |%s|\n%!" identifier;*) fontpack | exception Not_found -> - (*Printf.printf "Cpdfdraw FontPack op: storing new fontpack %s\n" identifier;*) + (*Printf.printf "Cpdfdraw FontPack op: storing new fontpack |%s|\n%!" identifier;*) let fontpack = match cpdffont with | PreMadeFontPack fp -> - (*Printf.printf "it's a pre-made font pack\n"; *) + (*Printf.printf "it's a pre-made font pack\n%!";*) fp | EmbedInfo {fontfile; fontname; encoding} -> let codepoints = map fst (list_of_hashtbl codepoints) in - (*Printf.printf "%i codepoints to embed\n" (length codepoints);*) + (*Printf.printf "%i codepoints to embed\n%!" (length codepoints);*) if codepoints = [] then default_fontpack else Cpdfembed.embed_truetype pdf ~fontfile ~fontname ~codepoints ~encoding | ExistingNamedFont -> @@ -279,7 +279,7 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func Not_found -> let o = if dryrun then 0 else Pdftext.write_font pdf font in let name = fresh_name "/F" in - (*Printf.printf "Adding font %s as %s\n" identifier name;*) + (*Printf.printf "Adding font %s as %s\n%!" identifier name;*) Hashtbl.replace (res ()).fonts (identifier, n) (name, o); name) (fst fontpack) @@ -288,7 +288,7 @@ let rec ops_of_drawop dryrun pdf endpage filename bates batespad num page = func (res ()).page_names <- ns @ (res ()).page_names; [] | Font (identifier, size) -> - (*Printf.printf "Cpdfdraw Font op: Changing to stored font %s\n" identifier;*) + (*Printf.printf "Cpdfdraw Font op: Changing to stored font %s\n%!" identifier;*) let fontpack, codepoints = Hashtbl.find !fontpacks identifier in (res ()).current_fontpack <- (identifier, fontpack); if dryrun then (res ()).current_fontpack_codepoints <- codepoints; diff --git a/cpdfdrawcontrol.ml b/cpdfdrawcontrol.ml index 319b14e..156938b 100644 --- a/cpdfdrawcontrol.ml +++ b/cpdfdrawcontrol.ml @@ -2,11 +2,12 @@ open Pdfutil open Cpdferror -let embed_font = ref (fun () -> Cpdfembed.ExistingNamedFont) -let getfontname = ref (fun () -> "") -let getfontsize = ref (fun () -> 0.) -let setfontname = ref (fun _ -> ()) -let setfontsize = ref (fun _ -> ()) +let embed_font = ref (fun () -> Printf.printf "BAD *\n%!"; Cpdfembed.ExistingNamedFont) +let setdrawing = ref (fun () -> Printf.printf "BAD **\n%!"; ()) +let getfontname = ref (fun () -> Printf.printf "BAD ***\n%!"; "") +let getfontsize = ref (fun () -> Printf.printf "BAD ****\n%!"; 0.) +let setfontname = ref (fun _ -> Printf.printf "BAD *****\n%!"; ()) +let setfontsize = ref (fun _ -> Printf.printf "BAD ******\n%!"; ()) let ttfs = null_hash () diff --git a/cpdfdrawcontrol.mli b/cpdfdrawcontrol.mli index f7ddb0f..11a1bdd 100644 --- a/cpdfdrawcontrol.mli +++ b/cpdfdrawcontrol.mli @@ -3,6 +3,7 @@ val getfontname : (unit -> string) ref val getfontsize : (unit -> float) ref val setfontname : (string -> unit) ref val setfontsize : (float -> unit) ref +val setdrawing : (unit -> unit) ref val ttfs : (string, (string * Cpdfembed.cpdffont)) Hashtbl.t val fontpack_initialised : bool ref val drawops : (string * Cpdfdraw.drawops list) list ref