more
This commit is contained in:
parent
7a5f09daef
commit
89401d7c2f
|
@ -1,3 +1,9 @@
|
||||||
|
(* Notes on ttf fonts:
|
||||||
|
|
||||||
|
FIXME: baseline / midline adjustments need to be added for ttf fonts.
|
||||||
|
FIXME: calc_textwidth
|
||||||
|
|
||||||
|
*)
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
open Cpdferror
|
open Cpdferror
|
||||||
|
|
||||||
|
@ -290,7 +296,7 @@ let pagelabel pdf num =
|
||||||
(Pdfpagelabels.complete (Pdfpagelabels.read pdf))
|
(Pdfpagelabels.complete (Pdfpagelabels.read pdf))
|
||||||
|
|
||||||
let addtext
|
let addtext
|
||||||
lines linewidth outline fast colour fontname embed bates batespad fontsize font
|
lines linewidth outline fast colour fontname embed bates batespad fontsize (font : Pdftext.font option)
|
||||||
underneath position hoffset voffset text pages orientation cropbox opacity
|
underneath position hoffset voffset text pages orientation cropbox opacity
|
||||||
justification filename extract_text_font_size shift pdf
|
justification filename extract_text_font_size shift pdf
|
||||||
=
|
=
|
||||||
|
@ -343,7 +349,7 @@ let addtext
|
||||||
in
|
in
|
||||||
let calc_textwidth text =
|
let calc_textwidth text =
|
||||||
match font with
|
match font with
|
||||||
| Some f ->
|
| Some (Pdftext.StandardFont (f, _)) ->
|
||||||
let rawwidth =
|
let rawwidth =
|
||||||
Pdfstandard14.textwidth
|
Pdfstandard14.textwidth
|
||||||
false
|
false
|
||||||
|
@ -494,7 +500,7 @@ let unescape_string s =
|
||||||
implode (unescape_chars [] (explode s))
|
implode (unescape_chars [] (explode s))
|
||||||
|
|
||||||
let
|
let
|
||||||
addtexts linewidth outline fast fontname (font : Pdftext.standard_font option) embed bates batespad colour position linespacing
|
addtexts linewidth outline fast fontname (font : Pdftext.font option) embed bates batespad colour position linespacing
|
||||||
fontsize underneath text pages orientation cropbox opacity justification
|
fontsize underneath text pages orientation cropbox opacity justification
|
||||||
midline topline filename extract_text_font_size shift ?(raw=false) pdf
|
midline topline filename extract_text_font_size shift ?(raw=false) pdf
|
||||||
=
|
=
|
||||||
|
@ -502,8 +508,10 @@ let
|
||||||
let realfontname = ref fontname in
|
let realfontname = ref fontname in
|
||||||
let fontpdfobj =
|
let fontpdfobj =
|
||||||
match font with
|
match font with
|
||||||
| Some f ->
|
| Some (StandardFont (f, _)) ->
|
||||||
make_font embed (Pdftext.string_of_standard_font f)
|
make_font embed (Pdftext.string_of_standard_font f)
|
||||||
|
| Some _ ->
|
||||||
|
failwith "unknown font in addtext"
|
||||||
| None ->
|
| None ->
|
||||||
let firstpage =
|
let firstpage =
|
||||||
List.nth (Pdfpage.pages_of_pagetree pdf) (hd pages - 1)
|
List.nth (Pdfpage.pages_of_pagetree pdf) (hd pages - 1)
|
||||||
|
@ -545,7 +553,7 @@ let
|
||||||
in
|
in
|
||||||
if midline then
|
if midline then
|
||||||
begin match font with
|
begin match font with
|
||||||
| Some font ->
|
| Some (Pdftext.StandardFont (font, _)) ->
|
||||||
let baseline_adjustment =
|
let baseline_adjustment =
|
||||||
(fontsize *. float (Pdfstandard14.baseline_adjustment font)) /. 1000.
|
(fontsize *. float (Pdfstandard14.baseline_adjustment font)) /. 1000.
|
||||||
in
|
in
|
||||||
|
@ -555,7 +563,7 @@ let
|
||||||
else
|
else
|
||||||
if topline then
|
if topline then
|
||||||
begin match font with
|
begin match font with
|
||||||
| Some font ->
|
| Some (Pdftext.StandardFont (font, _)) ->
|
||||||
let baseline_adjustment =
|
let baseline_adjustment =
|
||||||
(fontsize *. float (Pdfstandard14.baseline_adjustment font) *. 2.0) /. 1000.
|
(fontsize *. float (Pdfstandard14.baseline_adjustment font) *. 2.0) /. 1000.
|
||||||
in
|
in
|
||||||
|
|
|
@ -23,7 +23,7 @@ val addtexts :
|
||||||
bool -> (*outline*)
|
bool -> (*outline*)
|
||||||
bool -> (*fast*)
|
bool -> (*fast*)
|
||||||
string -> (*fontname*)
|
string -> (*fontname*)
|
||||||
Pdftext.standard_font option -> (*font*)
|
Pdftext.font option -> (*font*)
|
||||||
bool -> (* embed font *)
|
bool -> (* embed font *)
|
||||||
int -> (* bates number *)
|
int -> (* bates number *)
|
||||||
int option -> (* bates padding width *)
|
int option -> (* bates padding width *)
|
||||||
|
|
|
@ -3721,9 +3721,10 @@ let go () =
|
||||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||||
let font =
|
let font =
|
||||||
match args.font with
|
match args.font with
|
||||||
| StandardFont f -> Some f
|
| StandardFont f -> Some (Pdftext.StandardFont (f, Pdftext.WinAnsiEncoding))
|
||||||
| OtherFont f -> None (* it's in fontname *)
|
| OtherFont f -> None (* it's in fontname *)
|
||||||
| FontToEmbed (_, _) -> error "-add-text can't use TTF fonts yet"
|
| FontToEmbed (fontfile, encoding) ->
|
||||||
|
Some (Cpdfembed.embed_truetype pdf ~fontfile ~fontname:args.fontname ~text:"" ~encoding)
|
||||||
in
|
in
|
||||||
warn_prerotate range pdf;
|
warn_prerotate range pdf;
|
||||||
let pdf =
|
let pdf =
|
||||||
|
|
Loading…
Reference in New Issue