TTF/no default

This commit is contained in:
John Whitington 2023-07-17 13:53:09 +01:00
parent 951a947f43
commit 1db9310884
1 changed files with 16 additions and 5 deletions

View File

@ -384,6 +384,8 @@ type font =
let ttfs = null_hash () let ttfs = null_hash ()
let fontpack_initialised = ref false
type args = type args =
{mutable op : op option; {mutable op : op option;
mutable preserve_objstm : bool; mutable preserve_objstm : bool;
@ -731,12 +733,13 @@ let reset_arguments () =
args.toc_title <- "Table of Contents"; args.toc_title <- "Table of Contents";
args.toc_bookmark <- true; args.toc_bookmark <- true;
args.idir_only_pdfs <- false; args.idir_only_pdfs <- false;
args.xobj_bbox <- (0., 0., 1000., 1000.) args.xobj_bbox <- (0., 0., 1000., 1000.);
(* Do not reset original_filename or cpdflin or was_encrypted or (* Do not reset original_filename or cpdflin or was_encrypted or
was_decrypted_with_owner or recrypt or producer or creator or path_to_* or was_decrypted_with_owner or recrypt or producer or creator or path_to_* or
gs_malformed or gs_quiet or no-warn-rotate, since we want these to work gs_malformed or gs_quiet or no-warn-rotate, since we want these to work
across ANDs. Or squeeze options: a little odd, but we want it to happen on across ANDs. Or squeeze options: a little odd, but we want it to happen on
eventual output. Or -debug-force (from v2.6). *) eventual output. Or -debug-force (from v2.6). *)
clear fontpack_initialised
(* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume (* Prefer a) the one given with -cpdflin b) a local cpdflin, c) otherwise assume
installed at a system place *) installed at a system place *)
@ -1728,7 +1731,6 @@ let setidironlypdfs () =
let setnowarnrotate () = let setnowarnrotate () =
args.no_warn_rotate <- true args.no_warn_rotate <- true
let setfontttfencoding s = let setfontttfencoding s =
args.fontencoding <- args.fontencoding <-
match s with match s with
@ -1751,6 +1753,7 @@ let xobjbbox s =
args.xobj_bbox <- Cpdfcoord.parse_rectangle (Pdf.empty ()) s args.xobj_bbox <- Cpdfcoord.parse_rectangle (Pdf.empty ()) s
let addop o = let addop o =
begin match o with Cpdfdraw.FontPack _ -> set fontpack_initialised | _ -> () end;
begin match args.op with Some Draw -> () | _ -> error "Need to be in drawing mode for this." end; begin match args.op with Some Draw -> () | _ -> error "Need to be in drawing mode for this." end;
match !drawops with match !drawops with
| (n, ops)::t -> drawops := (n, (o::ops))::t | (n, ops)::t -> drawops := (n, (o::ops))::t
@ -2118,14 +2121,23 @@ let loadttf n =
Some Draw -> addop (Cpdfdraw.FontPack (fontname, embed_font_inner (EmbeddedFont name), null_hash ())) | _ -> () end Some Draw -> addop (Cpdfdraw.FontPack (fontname, embed_font_inner (EmbeddedFont name), null_hash ())) | _ -> () end
with with
_ -> error "addjpeg: could not load JPEG" _ -> error "addjpeg: could not load JPEG"
let add_default_fontpack () =
if not !fontpack_initialised then
begin
addop (Cpdfdraw.FontPack (args.fontname, embed_font (), null_hash ()));
set fontpack_initialised
end
let addtext s = let addtext s =
begin match !drawops with _::_::_ -> () | _ -> error "-text must be in a -bt / -et section" end; begin match !drawops with _::_::_ -> () | _ -> error "-text must be in a -bt / -et section" end;
add_default_fontpack ();
addop (Cpdfdraw.Font (args.fontname, args.fontsize)); addop (Cpdfdraw.Font (args.fontname, args.fontsize));
addop (Cpdfdraw.Text s) addop (Cpdfdraw.Text s)
let addspecialtext s = let addspecialtext s =
begin match !drawops with _::_::_ -> () | _ -> error "-stext must be in a -bt / -et section" end; begin match !drawops with _::_::_ -> () | _ -> error "-stext must be in a -bt / -et section" end;
add_default_fontpack ();
addop (Cpdfdraw.Font (args.fontname, args.fontsize)); addop (Cpdfdraw.Font (args.fontname, args.fontsize));
addop (Cpdfdraw.SpecialText s) addop (Cpdfdraw.SpecialText s)
@ -2136,8 +2148,7 @@ let settextwidth s =
args.op <- Some (TextWidth s) args.op <- Some (TextWidth s)
let setdraw () = let setdraw () =
args.op <- Some Draw; args.op <- Some Draw
addop (Cpdfdraw.FontPack (args.fontname, embed_font (), null_hash ()))
(* Parse a control file, make an argv, and then make Arg parse it. *) (* Parse a control file, make an argv, and then make Arg parse it. *)
let rec make_control_argv_and_parse filename = let rec make_control_argv_and_parse filename =