Added fontpack width calculation in -add-text
This commit is contained in:
parent
6a92be56cf
commit
291c5391c3
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ NONDOC = cpdfyojson cpdfxmlm
|
|||
DOC = cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord \
|
||||
cpdfattach cpdfpagespec cpdfposition cpdfpresent cpdfmetadata \
|
||||
cpdfbookmarks cpdfpage cpdftruetype cpdfremovetext cpdfextracttext \
|
||||
cpdfembed cpdfaddtext cpdffont cpdftype cpdfpad cpdfocg \
|
||||
cpdfembed cpdffont cpdftype cpdfaddtext cpdfpad cpdfocg \
|
||||
cpdfsqueeze cpdfdraft cpdfspot cpdfpagelabels cpdfcreate cpdfannot \
|
||||
cpdfxobject cpdfimpose cpdftweak cpdftexttopdf cpdftoc cpdfjpeg \
|
||||
cpdfpng cpdfimage cpdfdraw cpdfcomposition cpdfshape \
|
||||
|
|
|
@ -259,8 +259,14 @@ let addtext
|
|||
| None -> Pdf.Dictionary []
|
||||
| Some d -> d
|
||||
in
|
||||
(* FIXME If a fontpack is available, we need to calculate the width from the codepoints in preference. *)
|
||||
let calc_textwidth text =
|
||||
match fontpack with
|
||||
| Some fontpack ->
|
||||
let widthss = map (fun font -> Cpdftype.font_widths font fontsize) (fst fontpack) in
|
||||
let triples = option_map (Cpdfembed.get_char fontpack) (Pdftext.codepoints_of_utf8 text) in
|
||||
let widths = map (fun (charcode, fontnum, _) -> (List.nth widthss fontnum).(charcode)) triples in
|
||||
fsum widths
|
||||
| None ->
|
||||
match font with
|
||||
| Some (Pdftext.StandardFont (f, _)) ->
|
||||
let rawwidth =
|
||||
|
|
|
@ -11,6 +11,7 @@ type cpdffont =
|
|||
|
||||
val fontpack_of_standardfont : Pdftext.font -> t
|
||||
|
||||
(* Returns (charcode, fontnumber, font) *)
|
||||
val get_char : t -> int -> (int * int * Pdftext.font) option
|
||||
|
||||
val embed_truetype :
|
||||
|
|
Loading…
Reference in New Issue