Justification working now
This commit is contained in:
parent
93a28695d1
commit
de68538857
2
Changes
2
Changes
|
@ -11,7 +11,7 @@ New features:
|
||||||
* New -replace-obj to edit dictionary entries via chain
|
* New -replace-obj to edit dictionary entries via chain
|
||||||
* Create PDF/UA files from scratch with -create-pdf-ua-[1|2]
|
* Create PDF/UA files from scratch with -create-pdf-ua-[1|2]
|
||||||
* Create structure information for files with -draw
|
* Create structure information for files with -draw
|
||||||
* Draw can now make paragraphs
|
* Draw can now make paragraphs with -para, -paras
|
||||||
* Add structure information to -typeset, add -typeset-subformat
|
* Add structure information to -typeset, add -typeset-subformat
|
||||||
|
|
||||||
* = Supported by a grant from NLnet
|
* = Supported by a grant from NLnet
|
||||||
|
|
15
cpdfdraw.ml
15
cpdfdraw.ml
|
@ -244,7 +244,14 @@ let format_paragraph j w s =
|
||||||
let rs_and_widths = ref (map runs_of_utf8 ss) in
|
let rs_and_widths = ref (map runs_of_utf8 ss) in
|
||||||
let space_runs, space_width = runs_of_utf8 " " in
|
let space_runs, space_width = runs_of_utf8 " " in
|
||||||
let remaining = ref w in
|
let remaining = ref w in
|
||||||
|
let allops = ref [] in
|
||||||
let ops = ref [] in
|
let ops = ref [] in
|
||||||
|
let justify ops =
|
||||||
|
match j with
|
||||||
|
| Left -> ops
|
||||||
|
| Right -> [Pdfops.Op_Td (~-.(!remaining), 0.)] @ ops @ [Pdfops.Op_Td (!remaining, 0.)]
|
||||||
|
| Centre -> [Pdfops.Op_Td (~-.(!remaining) /. 2., 0.)] @ ops @ [Pdfops.Op_Td (!remaining /. 2., 0.)]
|
||||||
|
in
|
||||||
while !rs_and_widths <> [] do
|
while !rs_and_widths <> [] do
|
||||||
let word, word_width = hd !rs_and_widths in
|
let word, word_width = hd !rs_and_widths in
|
||||||
if !remaining = w then
|
if !remaining = w then
|
||||||
|
@ -265,13 +272,13 @@ let format_paragraph j w s =
|
||||||
else
|
else
|
||||||
(* If current line not empty, and not enough space, emit newline. *)
|
(* If current line not empty, and not enough space, emit newline. *)
|
||||||
begin
|
begin
|
||||||
ops := Pdfops.Op_T'::!ops;
|
allops =| rev (Pdfops.Op_T'::justify !ops);
|
||||||
|
ops := [];
|
||||||
remaining := w
|
remaining := w
|
||||||
end
|
end
|
||||||
done;
|
done;
|
||||||
rev !ops
|
allops =| rev (Pdfops.Op_T'::justify !ops);
|
||||||
(* TODO Justification - requires a way to offset, which means keeping the ops
|
flatten (rev !allops)
|
||||||
separate, and retaining the full line width *)
|
|
||||||
|
|
||||||
let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num page = function
|
let rec ops_of_drawop struct_tree dryrun pdf endpage filename bates batespad num page = function
|
||||||
| Qq ops ->
|
| Qq ops ->
|
||||||
|
|
Loading…
Reference in New Issue