Ready for testing of -paras
This commit is contained in:
parent
76eaa3da21
commit
a3d7a278d1
10
cpdfdraw.ml
10
cpdfdraw.ml
|
@ -428,9 +428,13 @@ 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);
|
||||
fst (runs_of_utf8 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);
|
||||
format_paragraph j w s
|
||||
if dryrun then iter (iter (fun c -> Hashtbl.replace (res ()).current_fontpack_codepoints c ())) (map Pdftext.codepoints_of_utf8 s);
|
||||
let first = ref true in
|
||||
flatten
|
||||
(map
|
||||
(function para ->
|
||||
if not !first then ([Pdfops.Op_T']) else (clear first; []) @ format_paragraph j w para)
|
||||
s)
|
||||
| Leading f -> [Pdfops.Op_TL f]
|
||||
| CharSpace f -> [Pdfops.Op_Tc f]
|
||||
| WordSpace f -> [Pdfops.Op_Tw f]
|
||||
|
|
|
@ -372,12 +372,18 @@ let addpara s =
|
|||
let j, w, s = jws s in
|
||||
addop (Cpdfdraw.Para (j, w, [s]))
|
||||
|
||||
let split_on_newline s = [s]
|
||||
let rec split_on_newlines a = function
|
||||
| 0x005c::0x004e::t -> rev a::split_on_newlines [] t
|
||||
| h::t -> split_on_newlines (h::a) t
|
||||
| [] -> if a = [] then [] else [rev a]
|
||||
|
||||
let split_on_newlines s =
|
||||
map Pdftext.utf8_of_codepoints (split_on_newlines [] (Pdftext.codepoints_of_utf8 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
|
||||
let splits = split_on_newlines s in
|
||||
addop (Cpdfdraw.Para (j, w, splits))
|
||||
|
|
Loading…
Reference in New Issue