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,20 +350,34 @@ let addspecialtext s =
|
||||||
addop (Cpdfdraw.SpecialText s)
|
addop (Cpdfdraw.SpecialText s)
|
||||||
|
|
||||||
(* "L200pt=....." *)
|
(* "L200pt=....." *)
|
||||||
|
let jws s =
|
||||||
|
let j, rest =
|
||||||
|
match explode s with
|
||||||
|
| 'L'::t -> (Cpdfdraw.Left, t)
|
||||||
|
| 'R'::t -> (Cpdfdraw.Right, t)
|
||||||
|
| 'C'::t -> (Cpdfdraw.Centre, t)
|
||||||
|
| _ -> error "Unknown justification specification"
|
||||||
|
in
|
||||||
|
let w, s =
|
||||||
|
match String.split_on_char '=' (implode rest) with
|
||||||
|
| [w; s] -> (Cpdfcoord.parse_single_number (Pdf.empty ()) w, s)
|
||||||
|
| _ -> error "addjpeg: bad file specification"
|
||||||
|
in
|
||||||
|
j, w, s
|
||||||
|
|
||||||
let addpara s =
|
let addpara s =
|
||||||
begin match !drawops with _::_::_ -> () | _ -> error "-stext must be in a -bt / -et section" end;
|
begin match !drawops with _::_::_ -> () | _ -> error "-para must be in a -bt / -et section" end;
|
||||||
add_default_fontpack (!getfontname ());
|
add_default_fontpack (!getfontname ());
|
||||||
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
||||||
let j, rest =
|
let j, w, s = jws s in
|
||||||
match explode s with
|
addop (Cpdfdraw.Para (j, w, [s]))
|
||||||
| 'L'::t -> (Cpdfdraw.Left, t)
|
|
||||||
| 'R'::t -> (Cpdfdraw.Right, t)
|
let split_on_newline s = [s]
|
||||||
| 'C'::t -> (Cpdfdraw.Centre, t)
|
|
||||||
| _ -> error "Unknown justification specification"
|
let addparas s =
|
||||||
in
|
begin match !drawops with _::_::_ -> () | _ -> error "-paras must be in a -bt / -et section" end;
|
||||||
let w, s =
|
add_default_fontpack (!getfontname ());
|
||||||
match String.split_on_char '=' (implode rest) with
|
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
||||||
| [w; s] -> (Cpdfcoord.parse_single_number (Pdf.empty ()) w, s)
|
let j, w, s = jws s in
|
||||||
| _ -> error "addjpeg: bad file specification"
|
let splits = split_on_newline s in
|
||||||
in
|
addop (Cpdfdraw.Para (j, w, splits))
|
||||||
addop (Cpdfdraw.Para (j, w, s))
|
|
||||||
|
|
|
@ -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