Toc spacing back in
This commit is contained in:
parent
55b94b069f
commit
b8bc5f1905
12
cpdftoc.ml
12
cpdftoc.ml
|
@ -28,6 +28,13 @@ let collate_runs = function
|
||||||
| [] -> []
|
| [] -> []
|
||||||
| (_, fontnum, _)::_ as l -> collate_runs fontnum [] l
|
| (_, fontnum, _)::_ as l -> collate_runs fontnum [] l
|
||||||
|
|
||||||
|
let rec width_of_runs runs =
|
||||||
|
match runs with
|
||||||
|
| Cpdftype.Font (f, fontsize)::Cpdftype.Text t::more ->
|
||||||
|
Cpdftype.width_of_string (Cpdftype.font_widths f fontsize) t +. width_of_runs more
|
||||||
|
| [] -> 0.
|
||||||
|
| _ -> failwith "width_of_runs"
|
||||||
|
|
||||||
(* Run of Font / Text elements from a fontpack and UTF8 text *)
|
(* Run of Font / Text elements from a fontpack and UTF8 text *)
|
||||||
let of_utf8 fontpack fontsize t =
|
let of_utf8 fontpack fontsize t =
|
||||||
let codepoints = Pdftext.codepoints_of_utf8 t in
|
let codepoints = Pdftext.codepoints_of_utf8 t in
|
||||||
|
@ -127,10 +134,9 @@ let typeset_table_of_contents ~font ~fontsize ~title ~bookmark pdf =
|
||||||
in
|
in
|
||||||
of_pdfdocencoding fontpack fontsize pde
|
of_pdfdocencoding fontpack fontsize pde
|
||||||
in
|
in
|
||||||
(*let widths = Cpdftype.font_widths f fontsize in
|
let textgap = width -. margin *. 2. -. indent -. width_of_runs labelruns in
|
||||||
let textgap = width -. margin *. 2. -. indent -. Cpdftype.width_of_string widths label in*)
|
|
||||||
(*let text = shorten_text widths (textgap -. fontsize *. 3.) text in*) (*FIXME add back in, but in unicode not codepoints! *)
|
(*let text = shorten_text widths (textgap -. fontsize *. 3.) text in*) (*FIXME add back in, but in unicode not codepoints! *)
|
||||||
let space = 0. (*textgap -. Cpdftype.width_of_string widths text*) in
|
let space = textgap -. width_of_runs textruns in
|
||||||
[Cpdftype.BeginDest mark.Pdfmarks.target;
|
[Cpdftype.BeginDest mark.Pdfmarks.target;
|
||||||
Cpdftype.HGlue indent]
|
Cpdftype.HGlue indent]
|
||||||
@ textruns @
|
@ textruns @
|
||||||
|
|
|
@ -3,8 +3,7 @@ open Pdfutil
|
||||||
open Pdfio
|
open Pdfio
|
||||||
|
|
||||||
let dbg =
|
let dbg =
|
||||||
(*let _ =
|
(* Pdfe.logger := (fun s -> print_string s; flush stdout) *)
|
||||||
Pdfe.logger := (fun s -> print_string s; flush stdout)*)
|
|
||||||
ref false
|
ref false
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
|
|
Loading…
Reference in New Issue