This commit is contained in:
John Whitington 2022-09-24 12:34:50 +01:00
parent ad442568db
commit 39d48da070
1 changed files with 13 additions and 9 deletions

View File

@ -138,7 +138,11 @@ let extract_widths chars_and_widths =
(* For finding the height for URL links, we try to find the Cap Height for the
font. For now, this will only work for built-in fonts. We fall back to using
the font size alone if we cannot get the cap height. *)
let cap_height fontname =
let cap_height font fontname =
match font with
| Some (Pdftext.SimpleFont {fontdescriptor = Some {capheight}}) ->
Some capheight
| _ ->
try
let font = unopt (Pdftext.standard_font_of_name ("/" ^ fontname)) in
let header, _, _, _ = Pdfstandard14.afm_data font in
@ -448,7 +452,7 @@ let addtext
let ex = annot_coord text e in
let x, y = x -. hoffset -. joffset, y -. voffset in
let height =
match cap_height fontname with
match cap_height font fontname with
| Some c -> (c *. fontsize) /. 1000.
| None -> fontsize
in