diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 0c26d50..3a9c232 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2054,6 +2054,7 @@ let addsopacity f = addop (Cpdfdraw.SOpacity f) let addtext s = + addop (Cpdfdraw.Font ("/F0", 36.)); addop (Cpdfdraw.Text s) let addblock s = diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 5f72e15..004ea04 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -39,6 +39,7 @@ type drawops = | NewPage | Opacity of float | SOpacity of float + | Font of string * float | Text of string | Block of unit (* to fix *) | URL of string @@ -57,6 +58,10 @@ let fresh_gs_name () = gsnum += 1; "/gs" ^ string_of_int !gsnum +let current_url = ref None + +let fresh_font_name () = "/F0" + let rec ops_of_drawop pdf = function | Push -> [Pdfops.Op_q] | Pop -> [Pdfops.Op_Q] @@ -107,6 +112,16 @@ let rec ops_of_drawop pdf = function let n = fresh_gs_name () in Hashtbl.add gss n (Pdf.Dictionary [("/CA", Pdf.Real v)]); [Pdfops.Op_gs n] + | URL s -> + current_url := Some s; + [] + | EndURL -> + current_url := None; + [] + | Font (s, f) -> + [Pdfops.Op_Tf (s, f)] + | Text s -> + [Pdfops.Op_BT; Pdfops.Op_Tj s; Pdfops.Op_ET] (* FIXME: convert to actual char codes based on font in use, obvs *) and ops_of_drawops pdf drawops = flatten (map (ops_of_drawop pdf) drawops) diff --git a/cpdfdraw.mli b/cpdfdraw.mli index a367f51..eecfe2d 100644 --- a/cpdfdraw.mli +++ b/cpdfdraw.mli @@ -37,6 +37,7 @@ type drawops = | NewPage | Opacity of float | SOpacity of float + | Font of string * float | Text of string | Block of unit (* to fix *) | URL of string