Skeleton for -paras
This commit is contained in:
parent
d70621ed57
commit
76eaa3da21
|
@ -2867,6 +2867,7 @@ let specs =
|
||||||
("-text", Arg.String Cpdfdrawcontrol.addtext, " Draw text");
|
("-text", Arg.String Cpdfdrawcontrol.addtext, " Draw text");
|
||||||
("-stext", Arg.String Cpdfdrawcontrol.addspecialtext, " Draw text with %specials");
|
("-stext", Arg.String Cpdfdrawcontrol.addspecialtext, " Draw text with %specials");
|
||||||
("-para", Arg.String Cpdfdrawcontrol.addpara, " Add a paragraph of text");
|
("-para", Arg.String Cpdfdrawcontrol.addpara, " Add a paragraph of text");
|
||||||
|
("-paras", Arg.String Cpdfdrawcontrol.addparas, " Add paragraphs of text, splitting on newlines");
|
||||||
("-leading", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.Leading f)), " Set leading");
|
("-leading", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.Leading f)), " Set leading");
|
||||||
("-charspace", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.CharSpace f)), " Set character spacing");
|
("-charspace", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.CharSpace f)), " Set character spacing");
|
||||||
("-wordspace", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.WordSpace f)), " Set word space");
|
("-wordspace", Arg.Float (fun f -> Cpdfdrawcontrol.addop (Cpdfdraw.WordSpace f)), " Set word space");
|
||||||
|
|
|
@ -50,7 +50,7 @@ type drawops =
|
||||||
| TextSection of drawops list
|
| TextSection of drawops list
|
||||||
| Text of string
|
| Text of string
|
||||||
| SpecialText of string
|
| SpecialText of string
|
||||||
| Para of justification * float * string
|
| Para of justification * float * string list
|
||||||
| Newline
|
| Newline
|
||||||
| Leading of float
|
| Leading of float
|
||||||
| CharSpace of float
|
| CharSpace of float
|
||||||
|
@ -428,6 +428,7 @@ let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num
|
||||||
if dryrun then iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ()) (Pdftext.codepoints_of_utf8 s);
|
if dryrun then iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ()) (Pdftext.codepoints_of_utf8 s);
|
||||||
fst (runs_of_utf8 s)
|
fst (runs_of_utf8 s)
|
||||||
| Para (j, w, s) ->
|
| Para (j, w, s) ->
|
||||||
|
let s = hd s in (* FIXME *)
|
||||||
if dryrun then iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ()) (Pdftext.codepoints_of_utf8 s);
|
if dryrun then iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ()) (Pdftext.codepoints_of_utf8 s);
|
||||||
format_paragraph j w s
|
format_paragraph j w s
|
||||||
| Leading f -> [Pdfops.Op_TL f]
|
| Leading f -> [Pdfops.Op_TL f]
|
||||||
|
|
|
@ -45,7 +45,7 @@ type drawops =
|
||||||
| TextSection of drawops list
|
| TextSection of drawops list
|
||||||
| Text of string
|
| Text of string
|
||||||
| SpecialText of string
|
| SpecialText of string
|
||||||
| Para of justification * float * string
|
| Para of justification * float * string list
|
||||||
| Newline
|
| Newline
|
||||||
| Leading of float
|
| Leading of float
|
||||||
| CharSpace of float
|
| CharSpace of float
|
||||||
|
|
|
@ -350,10 +350,7 @@ let addspecialtext s =
|
||||||
addop (Cpdfdraw.SpecialText s)
|
addop (Cpdfdraw.SpecialText s)
|
||||||
|
|
||||||
(* "L200pt=....." *)
|
(* "L200pt=....." *)
|
||||||
let addpara s =
|
let jws s =
|
||||||
begin match !drawops with _::_::_ -> () | _ -> error "-stext must be in a -bt / -et section" end;
|
|
||||||
add_default_fontpack (!getfontname ());
|
|
||||||
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
|
||||||
let j, rest =
|
let j, rest =
|
||||||
match explode s with
|
match explode s with
|
||||||
| 'L'::t -> (Cpdfdraw.Left, t)
|
| 'L'::t -> (Cpdfdraw.Left, t)
|
||||||
|
@ -366,4 +363,21 @@ let addpara s =
|
||||||
| [w; s] -> (Cpdfcoord.parse_single_number (Pdf.empty ()) w, s)
|
| [w; s] -> (Cpdfcoord.parse_single_number (Pdf.empty ()) w, s)
|
||||||
| _ -> error "addjpeg: bad file specification"
|
| _ -> error "addjpeg: bad file specification"
|
||||||
in
|
in
|
||||||
addop (Cpdfdraw.Para (j, w, s))
|
j, w, s
|
||||||
|
|
||||||
|
let addpara s =
|
||||||
|
begin match !drawops with _::_::_ -> () | _ -> error "-para must be in a -bt / -et section" end;
|
||||||
|
add_default_fontpack (!getfontname ());
|
||||||
|
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
||||||
|
let j, w, s = jws s in
|
||||||
|
addop (Cpdfdraw.Para (j, w, [s]))
|
||||||
|
|
||||||
|
let split_on_newline s = [s]
|
||||||
|
|
||||||
|
let addparas s =
|
||||||
|
begin match !drawops with _::_::_ -> () | _ -> error "-paras must be in a -bt / -et section" end;
|
||||||
|
add_default_fontpack (!getfontname ());
|
||||||
|
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
||||||
|
let j, w, s = jws s in
|
||||||
|
let splits = split_on_newline s in
|
||||||
|
addop (Cpdfdraw.Para (j, w, splits))
|
||||||
|
|
|
@ -76,6 +76,7 @@ val add_default_fontpack : string -> unit
|
||||||
val addtext : string -> unit
|
val addtext : string -> unit
|
||||||
val addspecialtext : string -> unit
|
val addspecialtext : string -> unit
|
||||||
val addpara : string -> unit
|
val addpara : string -> unit
|
||||||
|
val addparas : string -> unit
|
||||||
|
|
||||||
(** This the beginnings of separation between cpdfcommand and cpdfdraw when
|
(** This the beginnings of separation between cpdfcommand and cpdfdraw when
|
||||||
drawing, for use in cpdflib. It is presently undocumented. *)
|
drawing, for use in cpdflib. It is presently undocumented. *)
|
||||||
|
|
Loading…
Reference in New Issue