This commit is contained in:
John Whitington 2021-11-22 11:56:16 -08:00
parent 2768495bf1
commit 6d97fd4851
2 changed files with 7 additions and 3 deletions

View File

@ -2918,6 +2918,9 @@ let of_utf8 (f, fontsize) t =
|> map char_of_int |> map char_of_int
|> implode |> implode
let of_pdfdocencoding (f, fontsize) t =
of_utf8 (f, fontsize) (Pdftext.utf8_of_pdfdocstring t)
let typeset text = let typeset text =
let pdf = Pdf.empty () in let pdf = Pdf.empty () in
let f = (Pdftext.StandardFont (Pdftext.Courier, Pdftext.WinAnsiEncoding), 12.) in let f = (Pdftext.StandardFont (Pdftext.Courier, Pdftext.WinAnsiEncoding), 12.) in
@ -2945,7 +2948,7 @@ let typeset_table_of_contents pdf =
(fun mark -> (fun mark ->
[Cpdftype.BeginDest mark.Pdfmarks.target; [Cpdftype.BeginDest mark.Pdfmarks.target;
Cpdftype.HGlue {Cpdftype.glen = float mark.Pdfmarks.level *. 20.; Cpdftype.gstretch = 0.}; Cpdftype.HGlue {Cpdftype.glen = float mark.Pdfmarks.level *. 20.; Cpdftype.gstretch = 0.};
Cpdftype.Text (of_utf8 f mark.Pdfmarks.text); Cpdftype.Text (of_pdfdocencoding f mark.Pdfmarks.text);
Cpdftype.EndDest; Cpdftype.EndDest;
Cpdftype.NewLine]) Cpdftype.NewLine])
(Pdfmarks.read_bookmarks pdf) (Pdfmarks.read_bookmarks pdf)

View File

@ -99,8 +99,9 @@ let font_widths f fontsize =
let width_of_string ws s = let width_of_string ws s =
fold_left ( +. ) 0. (map (fun s -> ws.(int_of_char s)) (explode s)) fold_left ( +. ) 0. (map (fun s -> ws.(int_of_char s)) (explode s))
(* Takes ws, the width table and text, and returns (this_line, needs_newline, remaining_text) *)
let split_text space_left ws t = let split_text space_left ws t =
(t, false, "", 0.) (t, false, "")
let layout lmargin rmargin papersize i = let layout lmargin rmargin papersize i =
let width = let width =
@ -115,7 +116,7 @@ let layout lmargin rmargin papersize i =
s.width_table <- font_widths f fontsize; s.width_table <- font_widths f fontsize;
o := Font (f, fontsize) :: !o o := Font (f, fontsize) :: !o
| Text text -> | Text text ->
let this_line, needs_newline, remaining_text, space_used = let this_line, needs_newline, remaining_text =
split_text (xpos_max -. s.xpos) s.width_table text split_text (xpos_max -. s.xpos) s.width_table text
in in
o := Text this_line :: !o; o := Text this_line :: !o;