Scaffolding for paragraphs
This commit is contained in:
parent
6b75d36741
commit
d8d0e9c2b2
|
@ -2839,6 +2839,7 @@ let specs =
|
||||||
("-et", Arg.Unit Cpdfdrawcontrol.addet, " End text");
|
("-et", Arg.Unit Cpdfdrawcontrol.addet, " End text");
|
||||||
("-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");
|
||||||
("-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");
|
||||||
|
|
|
@ -7,6 +7,9 @@ type colspec =
|
||||||
| Grey of float
|
| Grey of float
|
||||||
| CYMK of float * float * float * float
|
| CYMK of float * float * float * float
|
||||||
|
|
||||||
|
type justification =
|
||||||
|
Left | Right | Centre
|
||||||
|
|
||||||
type drawops =
|
type drawops =
|
||||||
| Rect of float * float * float * float
|
| Rect of float * float * float * float
|
||||||
| Bezier of float * float * float * float * float * float
|
| Bezier of float * float * float * float * float * float
|
||||||
|
@ -43,6 +46,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
|
||||||
| Newline
|
| Newline
|
||||||
| Leading of float
|
| Leading of float
|
||||||
| CharSpace of float
|
| CharSpace of float
|
||||||
|
@ -327,6 +331,9 @@ let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num
|
||||||
let s = process_specials pdf endpage filename bates batespad num page s in
|
let s = process_specials pdf endpage filename bates batespad num page s in
|
||||||
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);
|
||||||
runs_of_utf8 s
|
runs_of_utf8 s
|
||||||
|
| Para (j, w, s) ->
|
||||||
|
if dryrun then iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ()) (Pdftext.codepoints_of_utf8 s);
|
||||||
|
[]
|
||||||
| Leading f -> [Pdfops.Op_TL f]
|
| Leading f -> [Pdfops.Op_TL f]
|
||||||
| CharSpace f -> [Pdfops.Op_Tc f]
|
| CharSpace f -> [Pdfops.Op_Tc f]
|
||||||
| WordSpace f -> [Pdfops.Op_Tw f]
|
| WordSpace f -> [Pdfops.Op_Tw f]
|
||||||
|
|
|
@ -6,6 +6,9 @@ type colspec =
|
||||||
| Grey of float
|
| Grey of float
|
||||||
| CYMK of float * float * float * float
|
| CYMK of float * float * float * float
|
||||||
|
|
||||||
|
type justification =
|
||||||
|
Left | Right | Centre
|
||||||
|
|
||||||
type drawops =
|
type drawops =
|
||||||
| Rect of float * float * float * float
|
| Rect of float * float * float * float
|
||||||
| Bezier of float * float * float * float * float * float
|
| Bezier of float * float * float * float * float * float
|
||||||
|
@ -42,6 +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
|
||||||
| Newline
|
| Newline
|
||||||
| Leading of float
|
| Leading of float
|
||||||
| CharSpace of float
|
| CharSpace of float
|
||||||
|
|
|
@ -321,3 +321,22 @@ let addspecialtext s =
|
||||||
add_default_fontpack (!getfontname ());
|
add_default_fontpack (!getfontname ());
|
||||||
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
addop (Cpdfdraw.Font (!getfontname (), !getfontsize ()));
|
||||||
addop (Cpdfdraw.SpecialText s)
|
addop (Cpdfdraw.SpecialText s)
|
||||||
|
|
||||||
|
(* "L200pt=....." *)
|
||||||
|
let addpara 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 =
|
||||||
|
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
|
||||||
|
addop (Cpdfdraw.Para (j, w, s))
|
||||||
|
|
|
@ -66,6 +66,7 @@ val addnewline : unit -> unit
|
||||||
val add_default_fontpack : string -> unit
|
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
|
||||||
|
|
||||||
(** 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