3 Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
20 /* some dummy functions and variables so that a few ff source files can be ignored */
22 #include "ffdummies.h"
26 char **gww_errors
= NULL
;
27 int gww_error_count
= 0;
29 void gwwv_errors_free(void)
32 if (gww_error_count
> 0) {
33 for (i
= 0; i
< gww_error_count
; i
++) {
42 __attribute__ ((format(printf
, 1, 0)))
43 static void LUAUI_IError(const char *format
, ...)
47 char buffer
[400], *str
;
48 l
= strlen("Internal Error: ");
49 snprintf(buffer
, sizeof(buffer
), "Internal Error: ");
51 vsnprintf(buffer
+ l
, sizeof(buffer
) - l
, format
, ap
);
53 str
= xstrdup((char *) buffer
);
54 gww_errors
= realloc(gww_errors
, (gww_error_count
+ 2) * sizeof(char *));
55 if (gww_errors
== NULL
) {
56 perror("memory allocation failed");
59 gww_errors
[gww_error_count
] = str
;
61 gww_errors
[gww_error_count
] = NULL
;
64 __attribute__ ((format(printf
, 1, 0)))
65 static void LUAUI__LogError(const char *format
, va_list ap
)
67 char buffer
[400], *str
;
68 vsnprintf(buffer
, sizeof(buffer
), format
, ap
);
69 str
= xstrdup((char *) buffer
);
70 gww_errors
= realloc(gww_errors
, (gww_error_count
+ 2) * sizeof(char *));
71 if (gww_errors
== NULL
) {
72 perror("memory allocation failed");
75 gww_errors
[gww_error_count
] = str
;
77 gww_errors
[gww_error_count
] = NULL
;
80 /* this is not static because it is used by gwwiconv.c */
82 __attribute__ ((format(printf
, 1, 2)))
83 static void LUAUI_LogError(const char *format
, ...)
87 LUAUI__LogError(format
, ap
);
91 __attribute__ ((format(printf
, 2, 3)))
92 static void LUAUI_post_notice(const char *title
, const char *statement
, ...)
96 va_start(ap
, statement
);
97 LUAUI__LogError(statement
, ap
);
101 __attribute__ ((format(printf
, 2, 3)))
102 static void LUAUI_post_error(const char *title
, const char *statement
, ...)
106 va_start(ap
, statement
);
107 LUAUI__LogError(statement
, ap
);
111 static int LUAUI_ask(const char *title
, const char **answers
,
112 int def
, int cancel
, const char *question
, ...)
121 static int LUAUI_choose(const char *title
, const char **choices
, int cnt
,
122 int def
, const char *question
, ...)
131 static int LUAUI_choose_multiple(char *title
, const char **choices
, char *sel
,
132 int cnt
, char *buts
[2], const char *question
,
144 static char *LUAUI_ask_string(const char *title
, const char *def
,
145 const char *question
, ...)
150 return def
? strdup(def
) : NULL
;
153 static char *LUAUI_open_file(const char *title
, const char *defaultfile
,
154 const char *initial_filter
)
157 (void) initial_filter
;
162 static char *LUAUI_saveas_file(const char *title
, const char *defaultfile
,
163 const char *initial_filter
)
166 (void) initial_filter
;
167 return (copy(defaultfile
));
170 static void LUAUI_progress_start(int delay
, const char *title
,
171 const char *line1
, const char *line2
, int tot
,
182 static void LUAUI_void_void_noop(void)
186 static void LUAUI_void_int_noop(int useless
)
191 static int LUAUI_int_int_noop(int useless
)
197 static void LUAUI_void_str_noop(const char *useless
)
202 static int LUAUI_alwaystrue(void)
207 static int LUAUI_DefaultStrokeFlags(void)
209 return (sf_correctdir
);
212 struct ui_interface luaui_interface
= {
219 LUAUI_choose_multiple
,
221 LUAUI_ask_string
, /* password */
225 LUAUI_progress_start
,
226 LUAUI_void_void_noop
,
227 LUAUI_void_void_noop
,
234 LUAUI_void_void_noop
,
235 LUAUI_void_void_noop
,
240 LUAUI_void_void_noop
,
245 LUAUI_DefaultStrokeFlags
248 /* some bits and pieces */
250 int URLFromFile(char *url
, FILE * from
)
258 int pagewidth
= 0, pageheight
= 0; /* In points */
259 char *printlazyprinter
= NULL
;
260 char *printcommand
= NULL
;
263 void ScriptPrint(FontViewBase
* fv
, int type
, int32
* pointsizes
,
264 char *samplefile
, unichar_t
* sample
, char *outputfile
)
275 static int PdfDumpGlyphResources(void *pi
, SplineChar
* sc
)
284 int autotrace_ask
= 0, mf_ask
= 0, mf_clearbackgrounds
= 0, mf_showerrors
= 0;
285 char *mf_args
= NULL
;
286 int preferpotrace
= 0;
288 void *GetAutoTraceArgs(void)
293 void SetAutoTraceArgs(void *a
)
298 void FVAutoTrace(FontViewBase
* fv
, int ask
)
304 SplineFont
*SFFromMF(char *filename
)
312 FILE *URLToTempFile(char *url
, void *_lock
)
316 ff_post_error(_("Could not parse URL"),
317 _("FontForge only handles ftp and http URLs at the moment"));