Debian Codegraph @

fontforgeexe/savefontdlg.c

raw symbols SCIP
1 /* -*- coding: utf-8 -*- */
2 /* Copyright (C) 2000-2012 by George Williams */
3 /*
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13
14 * The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <fontforge-config.h>
30
31 #include "encoding.h"
32 #include "fontforgeui.h"
33 #include "gfile.h"
34 #include "gicons.h"
35 #include "gkeysym.h"
36 #include "macbinary.h"
37 #include "mm.h"
38 #include "namelist.h"
39 #include "psfont.h"
40 #include "savefont.h"
41 #include "splinefill.h"
42 #include "splinesaveafm.h"
43 #include "splineutil.h"
44 #include "tottf.h"
45 #include "ustring.h"
46 #include "utype.h"
47 #include "woff.h"
48
49 #include <locale.h>
50 #include <math.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <time.h>
54 #include <unistd.h>
55
56 int ask_user_for_resolution = true;
57 int old_fontlog=false;
58
59 static int nfnt_warned = false, post_warned = false;
60
61 #define CID_MergeTables 100
62 #define CID_TTC_CFF 101
63 #define CID_Family 2000
64
65 #define CID_AppendFontLog 400
66 #define CID_FontLogBit 401
67 #define CID_Layers 402
68 #define CID_PrependTimestamp 403
69
70 #define CID_OK 1001
71 #define CID_PS_AFM 1002
72 #define CID_PS_PFM 1003
73 #define CID_PS_TFM 1004
74 #define CID_PS_HintSubs 1005
75 #define CID_PS_Flex 1006
76 #define CID_PS_Hints 1007
77 #define CID_PS_Restrict256 1008
78 #define CID_PS_Round 1009
79 #define CID_PS_OFM 1010
80 #define CID_PS_AFMmarks 1011
81 #define CID_TTF_Hints 1101
82 #define CID_TTF_FullPS 1102
83 #define CID_TTF_AppleMode 1103
84 #define CID_TTF_PfEdComments 1104
85 #define CID_TTF_PfEdColors 1105
86 #define CID_TTF_PfEd 1106
87 #define CID_TTF_TeXTable 1107
88 #define CID_TTF_OpenTypeMode 1108
89 #define CID_TTF_OldKern 1109
90 #define CID_TTF_GlyphMap 1110
91 #define CID_TTF_OFM 1111
92 #define CID_TTF_NoMacNames 1112
93 #define CID_TTF_PfEdLookups 1113
94 #define CID_TTF_PfEdGuides 1114
95 #define CID_TTF_PfEdLayers 1115
96 #define CID_FontLog 1116
97 #define CID_TTF_DummyDSIG 1117
98 #define CID_NativeKern 1118
99 #define CID_TTF_OldKernMappedOnly 1119
100 #define CID_TTF_FFTMTable 1120
101
102 struct gfc_data {
103 int done;
104 int sod_done;
105 int sod_which;
106 int sod_invoked;
107 int ret;
108 int family, familycnt;
109 GWindow gw;
110 GGadget *gfc;
111 GGadget *pstype;
112 GGadget *bmptype;
113 GGadget *bmpsizes;
114 GGadget *options;
115 GGadget *rename;
116 GGadget *validate;
117 int ps_flags; /* The ordering of these flags fields is */
118 int sfnt_flags; /* important. We index into them */
119 /* WAS otf_flags */
120 int psotb_flags; /* don't reorder or put junk in between */
121 uint8_t optset[3];
122 SplineFont *sf;
123 EncMap *map;
124 int layer;
125 };
126
127 static GTextInfo formattypes[] = {
128 { (unichar_t *) N_("PS Type 1 (Ascii)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
129 { (unichar_t *) N_("PS Type 1 (Binary)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
130 #if __Mac
131 { (unichar_t *) N_("PS Type 1 (Resource)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
132 #else
133 { (unichar_t *) N_("PS Type 1 (MacBin)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
134 #endif
135 { (unichar_t *) N_("PS Type 1 (Multiple)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
136 { (unichar_t *) N_("PS Multiple Master(A)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
137 { (unichar_t *) N_("PS Multiple Master(B)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
138 { (unichar_t *) N_("PS Type 3"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
139 { (unichar_t *) N_("PS Type 0"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
140 { (unichar_t *) N_("PS CID"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
141 /* GT: "CFF (Bare)" means a CFF font without the normal OpenType wrapper */
142 /* GT: CFF is a font format that normally lives inside an OpenType font */
143 /* GT: but it is perfectly meaningful to remove all the OpenType complexity */
144 /* GT: and just leave a bare CFF font */
145 { (unichar_t *) N_("CFF (Bare)"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
146 { (unichar_t *) N_("CFF CID (Bare)"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
147 { (unichar_t *) N_("Type42"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
148 { (unichar_t *) N_("Type11 (CID 2)"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
149 { (unichar_t *) N_("TrueType"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
150 { (unichar_t *) N_("TrueType (Symbol)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
151 #if __Mac
152 { (unichar_t *) N_("TrueType (Resource)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
153 #else
154 { (unichar_t *) N_("TrueType (MacBin)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
155 #endif
156 { (unichar_t *) N_("TrueType (TTC)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
157 { (unichar_t *) N_("TrueType (Mac dfont)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
158 { (unichar_t *) N_("OpenType (CFF)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
159 { (unichar_t *) N_("OpenType (Mac dfont)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
160 { (unichar_t *) N_("OpenType CID"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
161 { (unichar_t *) N_("OpenType CID (dfont)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
162 { (unichar_t *) N_("SVG font"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
163 { (unichar_t *) N_("Unified Font Object (UFO3)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
164 { (unichar_t *) N_("Unified Font Object 2"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
165 { (unichar_t *) N_("Unified Font Object 3"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
166 { (unichar_t *) N_("Web Open Font (WOFF TTF)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
167 { (unichar_t *) N_("Web Open Font (WOFF OTF)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
168 { (unichar_t *) N_("Web Open Font (WOFF2 TTF)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
169 { (unichar_t *) N_("Web Open Font (WOFF2 OTF)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
170 { (unichar_t *) N_("No Outline Font"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
171 GTEXTINFO_EMPTY
172 };
173 static GTextInfo bitmaptypes[] = {
174 { (unichar_t *) N_("BDF"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
175 { (unichar_t *) N_("In TTF/OTF"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
176 { (unichar_t *) N_("Apple bitmap only sfnt (dfont)"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
177 { (unichar_t *) N_("(faked) MS bitmap only sfnt (ttf)"), NULL, 0, 0, NULL, NULL, 1, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
178 { (unichar_t *) N_("X11 bitmap only sfnt (otb)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
179 #if __Mac
180 { (unichar_t *) N_("NFNT (Resource)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
181 #else
182 { (unichar_t *) N_("NFNT (MacBin)"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
183 #endif
184 /* OS/X doesn't seem to support NFNTs, so there's no point in putting them in a dfont */
185 /* { (unichar_t *) "NFNT (dfont)", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },*/
186 { (unichar_t *) N_("Win FON"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
187 { (unichar_t *) N_("Win FNT"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
188 { (unichar_t *) N_("Palm OS Bitmap"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
189 { (unichar_t *) N_("PS Type3 Bitmap"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
190 { (unichar_t *) N_("No Bitmap Fonts"), NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0' },
191 GTEXTINFO_EMPTY
192 };
193
194 int old_validate = true;
195
196 extern int old_sfnt_flags;
197 extern int old_ps_flags;
198 extern int old_psotb_flags;
199
200 extern int oldformatstate;
201 extern int oldbitmapstate;
202
203 static const char *pfaeditflag = "SplineFontDB:";
204
205 static int32_t *ParseBitmapSizes(GGadget *g, int *err) {
206 const unichar_t *val = _GGadgetGetTitle(g), *pt; unichar_t *end, *end2;
207 const char *msg = _("Pixel List"); // Before switching to C locale
208 int i;
209 int32_t *sizes;
210
211 locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage.
212 switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale.
213
214 *err = false;
215 end2 = NULL;
216 for ( i=1, pt = val; (end = u_strchr(pt,',')) || (end2=u_strchr(pt,' ')); ++i ) {
217 if ( end!=NULL && end2!=NULL ) {
218 if ( end2<end ) end = end2;
219 } else if ( end2!=NULL )
220 end = end2;
221 pt = end+1;
222 end2 = NULL;
223 }
224 sizes = malloc((i+1)*sizeof(int32_t));
225
226 for ( i=0, pt = val; *pt!='\0' ; ) {
227 sizes[i]=rint(u_strtod(pt,&end));
228 if ( *end!='@' )
229 sizes[i] |= 0x10000;
230 else
231 sizes[i] |= (u_strtol(end+1,&end,10)<<16);
232 if ( sizes[i]>0 ) ++i;
233 if ( *end!=' ' && *end!=',' && *end!='\0' ) {
234 free(sizes);
235 GGadgetProtest8(msg);
236 *err = true;
237 break;
238 }
239 while ( *end==' ' || *end==',' ) ++end;
240 pt = end;
241 }
242 switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale.
243 if ( *err )
244 return( NULL );
245 sizes[i] = 0;
246 return( sizes );
247 }
248
249 static int OPT_PSHints(GGadget *g, GEvent *e) {
250 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
251 GWindow gw = GGadgetGetWindow(g);
252 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
253 if ( GGadgetIsChecked(g)) {
254 int which = d->sod_which>1? d->sod_which-1 : d->sod_which;
255 int flags = (&d->ps_flags)[which];
256 /*GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_HintSubs),true);*/
257 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Flex),true);
258 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Flex),!(flags&ps_flag_noflex));
259 } else {
260 /*GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_HintSubs),false);*/
261 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Flex),false);
262 /*GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_HintSubs),false);*/
263 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Flex),false);
264 }
265 }
266 return( true );
267 }
268
269 static int OPT_Applemode(GGadget *g, GEvent *e) {
270 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
271 GWindow gw = GGadgetGetWindow(g);
272 if ( GGadgetIsChecked(g))
273 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OldKern),false);
274 }
275 return( true );
276 }
277
278 static int OPT_OldKern(GGadget *g, GEvent *e) {
279 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
280 GWindow gw = GGadgetGetWindow(g);
281 if ( GGadgetIsChecked(g))
282 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_AppleMode),false);
283 }
284 return( true );
285 }
286
287 static int sod_e_h(GWindow gw, GEvent *event) {
288 if ( event->type==et_close ) {
289 struct gfc_data *d = GDrawGetUserData(gw);
290 d->sod_done = true;
291 } else if ( event->type == et_char ) {
292 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
293 help("ui/dialogs/generate.html", "#generate-options");
294 return( true );
295 }
296 return( false );
297 } else if ( event->type==et_controlevent && event->u.control.subtype == et_buttonactivate ) {
298 struct gfc_data *d = GDrawGetUserData(gw);
299 if ( GGadgetGetCid(event->u.control.g)==CID_OK ) {
300 if ( d->sod_which==0 ) { /* PostScript */
301 d->ps_flags = 0;
302 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_AFM)) )
303 d->ps_flags |= ps_flag_afm;
304 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_AFMmarks)) )
305 d->ps_flags |= ps_flag_afmwithmarks;
306 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_PFM)) )
307 d->ps_flags |= ps_flag_pfm;
308 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_TFM)) )
309 d->ps_flags |= ps_flag_tfm;
310 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Flex)) )
311 d->ps_flags |= ps_flag_noflex;
312 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Hints)) )
313 d->ps_flags |= ps_flag_nohints;
314 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Round)) )
315 d->ps_flags |= ps_flag_round;
316 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_FontLog)) )
317 d->ps_flags |= ps_flag_outputfontlog;
318 } else if ( d->sod_which==1 || d->sod_which==2 ) { /* Open/TrueType */
319 d->sfnt_flags = 0;
320 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_Hints)) )
321 d->sfnt_flags |= ttf_flag_nohints;
322 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_FullPS)) )
323 d->sfnt_flags |= ttf_flag_shortps;
324 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_AppleMode)) )
325 d->sfnt_flags |= ttf_flag_applemode;
326 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_OpenTypeMode)) )
327 d->sfnt_flags |= ttf_flag_otmode;
328 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_OldKern)) &&
329 !(d->sfnt_flags&ttf_flag_applemode) )
330 d->sfnt_flags |= ttf_flag_oldkern;
331 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_DummyDSIG)) )
332 d->sfnt_flags |= ttf_flag_dummyDSIG;
333 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdComments)) )
334 d->sfnt_flags |= ttf_flag_pfed_comments;
335 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdColors)) )
336 d->sfnt_flags |= ttf_flag_pfed_colors;
337 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdLookups)) )
338 d->sfnt_flags |= ttf_flag_pfed_lookupnames;
339 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdGuides)) )
340 d->sfnt_flags |= ttf_flag_pfed_guides;
341 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdLayers)) )
342 d->sfnt_flags |= ttf_flag_pfed_layers;
343 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_FFTMTable)) )
344 d->sfnt_flags |= ttf_flag_noFFTMtable;
345 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_TeXTable)) )
346 d->sfnt_flags |= ttf_flag_TeXtable;
347 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_GlyphMap)) )
348 d->sfnt_flags |= ttf_flag_glyphmap;
349 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_OFM)) )
350 d->sfnt_flags |= ttf_flag_ofm;
351
352 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_AFM)) )
353 d->sfnt_flags |= ps_flag_afm;
354 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_AFMmarks)) )
355 d->sfnt_flags |= ps_flag_afmwithmarks;
356 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Flex)) )
357 d->sfnt_flags |= ps_flag_noflex;
358 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Hints)) )
359 d->sfnt_flags |= ps_flag_nohints;
360 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Round)) )
361 d->sfnt_flags |= ps_flag_round;
362
363 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_FontLog)) )
364 d->sfnt_flags |= ps_flag_outputfontlog;
365 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_NativeKern)) )
366 d->sfnt_flags |= ttf_native_kern; // This applies mostly to U. F. O. right now.
367 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_OldKernMappedOnly)) )
368 d->sfnt_flags |= ttf_flag_oldkernmappedonly;
369 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_NoMacNames)) )
370 d->sfnt_flags |= ttf_flag_nomacnames;
371 } else { /* PS + OpenType Bitmap */
372 d->ps_flags = d->psotb_flags = 0;
373 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_AFMmarks)) )
374 d->psotb_flags = d->ps_flags |= ps_flag_afmwithmarks;
375 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Flex)) )
376 d->psotb_flags = d->ps_flags |= ps_flag_noflex;
377 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Hints)) )
378 d->psotb_flags = d->ps_flags |= ps_flag_nohints;
379 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_Round)) )
380 d->psotb_flags = d->ps_flags |= ps_flag_round;
381 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_PFM)) )
382 d->psotb_flags = d->ps_flags |= ps_flag_pfm;
383 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_PS_TFM)) )
384 d->psotb_flags = d->ps_flags |= ps_flag_tfm;
385
386 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_FullPS)) )
387 d->psotb_flags |= ttf_flag_shortps;
388 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdComments)) )
389 d->psotb_flags |= ttf_flag_pfed_comments;
390 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdColors)) )
391 d->psotb_flags |= ttf_flag_pfed_colors;
392 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdLookups)) )
393 d->psotb_flags |= ttf_flag_pfed_lookupnames;
394 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdGuides)) )
395 d->psotb_flags |= ttf_flag_pfed_guides;
396 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_PfEdLayers)) )
397 d->psotb_flags |= ttf_flag_pfed_layers;
398 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_FFTMTable)) )
399 d->psotb_flags |= ttf_flag_noFFTMtable;
400 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_TeXTable)) )
401 d->psotb_flags |= ttf_flag_TeXtable;
402 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_GlyphMap)) )
403 d->psotb_flags |= ttf_flag_glyphmap;
404 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_OFM)) )
405 d->psotb_flags |= ttf_flag_ofm;
406 if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_NoMacNames)) )
407 d->psotb_flags |= ttf_flag_nomacnames;
408 }
409 d->sod_invoked = true;
410 }
411 d->sod_done = true;
412 }
413 return( true );
414 }
415
416 static void OptSetDefaults(GWindow gw,struct gfc_data *d,int which,int iscid) {
417 int w = which>1 ? which-1 : which;
418 int flags = (&d->ps_flags)[w];
419 int fs = GGadgetGetFirstListSelectedItem(d->pstype);
420 int bf = GGadgetGetFirstListSelectedItem(d->bmptype);
421 /* which==0 => pure postscript */
422 /* which==1 => truetype or bitmap in sfnt wrapper */
423 /* which==2 => opentype (ps) */
424 /* which==3 => generating an sfnt based bitmap only font with a postscript outline font */
425
426 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Hints),!(flags&ps_flag_nohints));
427 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Flex),!(flags&ps_flag_noflex));
428 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Round),flags&ps_flag_round);
429
430 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_AFM),flags&ps_flag_afm);
431 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_AFMmarks),flags&ps_flag_afmwithmarks);
432 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_PFM),(flags&ps_flag_pfm) && !iscid);
433 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_TFM),flags&ps_flag_tfm);
434
435 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_Hints),!(flags&ttf_flag_nohints));
436 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_FullPS),!(flags&ttf_flag_shortps));
437 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OFM),flags&ttf_flag_ofm);
438 if ( d->optset[which] )
439 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_AppleMode),flags&ttf_flag_applemode);
440 else if ( which==0 || which==3 ) /* PostScript */
441 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_AppleMode),false);
442 else
443 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_AppleMode),(flags&ttf_flag_applemode));
444 if ( d->optset[which] )
445 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OpenTypeMode),flags&ttf_flag_otmode);
446 else if ( which==0 ) /* PostScript */
447 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OpenTypeMode),false);
448 else if ( (fs==ff_ttfmacbin || fs==ff_ttfdfont || fs==ff_otfdfont ||
449 fs==ff_otfciddfont || d->family==gf_macfamily || (fs==ff_none && bf==bf_sfnt_dfont)))
450 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OpenTypeMode),false);
451 else
452 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OpenTypeMode),(flags&ttf_flag_otmode));
453
454 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_PfEdComments),flags&ttf_flag_pfed_comments);
455 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_PfEdColors),flags&ttf_flag_pfed_colors);
456 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_PfEdLookups),flags&ttf_flag_pfed_lookupnames);
457 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_PfEdGuides),flags&ttf_flag_pfed_guides);
458 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_PfEdLayers),flags&ttf_flag_pfed_layers);
459 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_FFTMTable),
460 which!=0 && !(flags&ttf_flag_noFFTMtable));
461 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_TeXTable),flags&ttf_flag_TeXtable);
462 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_GlyphMap),flags&ttf_flag_glyphmap);
463 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OldKern),
464 (flags&ttf_flag_oldkern) && !GGadgetIsChecked(GWidgetGetControl(gw,CID_TTF_AppleMode)));
465 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_DummyDSIG),flags&ttf_flag_dummyDSIG);
466 GGadgetSetChecked(GWidgetGetControl(gw,CID_FontLog),flags&ps_flag_outputfontlog);
467 GGadgetSetChecked(GWidgetGetControl(gw,CID_NativeKern),flags&ttf_native_kern);
468 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_OldKernMappedOnly),flags&ttf_flag_oldkernmappedonly);
469 GGadgetSetChecked(GWidgetGetControl(gw,CID_TTF_NoMacNames),flags&ttf_flag_nomacnames);
470
471 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Hints),which!=1);
472 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Flex),which!=1);
473 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Round),which!=1);
474 if ( which!=1 && (flags&ps_flag_nohints)) {
475 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_Flex),false);
476 GGadgetSetChecked(GWidgetGetControl(gw,CID_PS_Flex),false);
477 }
478
479 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_AFM),which!=1);
480 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_AFMmarks),which!=1);
481 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_PFM),which==0 || which==3);
482 GGadgetSetEnabled(GWidgetGetControl(gw,CID_PS_TFM),which==0 || which==3);
483
484 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_Hints),which==1);
485 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_FullPS),which!=0);
486 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_AppleMode),which!=0 && which!=3);
487 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_OpenTypeMode),which!=0 && which!=3);
488 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_OldKern),which!=0 );
489 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_DummyDSIG),which!=0 );
490
491 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEd),which!=0);
492 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdComments),which!=0);
493 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdColors),which!=0);
494 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdLookups),which!=0);
495 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdGuides),which!=0);
496 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdColors),which!=0);
497 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_PfEdLayers),which!=0);
498 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_FFTMTable), which!=0);
499 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_TeXTable),which!=0);
500 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_GlyphMap),which!=0);
501 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_OFM),which!=0);
502
503 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_OldKernMappedOnly),which!=0 );
504 GGadgetSetEnabled(GWidgetGetControl(gw,CID_TTF_NoMacNames),which!=0 );
505
506 d->optset[which] = true;
507 }
508
509 #define OPT_Width 230
510 #define OPT_Height 233
511
512 static void SaveOptionsDlg(struct gfc_data *d,int which,int iscid) {
513 int k,group,group2;
514 GWindow gw;
515 GWindowAttrs wattrs;
516 GGadgetCreateData gcd[36];
517 GTextInfo label[36];
518 GRect pos;
519 GGadgetCreateData *hvarray1[21], *hvarray2[44], *hvarray3[8], *harray[7], *varray[11];
520 GGadgetCreateData boxes[6];
521
522 d->sod_done = false;
523 d->sod_which = which;
524
525 memset(&wattrs,0,sizeof(wattrs));
526 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
527 wattrs.event_masks = ~(1<<et_charup);
528 wattrs.restrict_input_to_me = 1;
529 wattrs.undercursor = 1;
530 wattrs.cursor = ct_pointer;
531 wattrs.utf8_window_title = _("Options");
532 wattrs.is_dlg = true;
533 pos.x = pos.y = 0;
534 pos.width = GGadgetScale(GDrawPointsToPixels(NULL,OPT_Width));
535 pos.height = GDrawPointsToPixels(NULL,OPT_Height);
536 gw = GDrawCreateTopWindow(NULL,&pos,sod_e_h,d,&wattrs);
537
538 memset(&label,0,sizeof(label));
539 memset(&gcd,0,sizeof(gcd));
540 memset(boxes,0,sizeof(boxes));
541
542 k = 0;
543 gcd[k].gd.pos.x = 2; gcd[k].gd.pos.y = 2;
544 gcd[k].gd.pos.width = pos.width-4; gcd[k].gd.pos.height = pos.height-4;
545 gcd[k].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels;
546 gcd[k++].creator = GGroupCreate;
547
548 label[k].text = (unichar_t *) U_("PostScriptÂź");
549 label[k].text_is_1byte = true;
550 gcd[k].gd.label = &label[k];
551 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = 5;
552 gcd[k].gd.flags = gg_enabled | gg_visible;
553 gcd[k++].creator = GLabelCreate;
554
555 group = k;
556 gcd[k].gd.pos.x = 4; gcd[k].gd.pos.y = 9;
557 gcd[k].gd.pos.width = OPT_Width-8; gcd[k].gd.pos.height = 72;
558 gcd[k].gd.flags = gg_enabled | gg_visible ;
559 gcd[k++].creator = GGroupCreate;
560
561 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 16;
562 gcd[k].gd.flags = gg_visible;
563 label[k].text = (unichar_t *) _("Round");
564 label[k].text_is_1byte = true;
565 gcd[k].gd.popup_msg = _("Do you want to round coordinates to integers (this saves space)?");
566 gcd[k].gd.label = &label[k];
567 gcd[k].gd.cid = CID_PS_Round;
568 gcd[k++].creator = GCheckBoxCreate;
569 hvarray1[0] = &gcd[k-1]; hvarray1[1] = GCD_ColSpan;
570
571 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
572 gcd[k].gd.flags = gg_visible;
573 label[k].text = (unichar_t *) _("Hints");
574 label[k].text_is_1byte = true;
575 gcd[k].gd.popup_msg = _("Do you want the font file to contain PostScript hints?");
576 gcd[k].gd.label = &label[k];
577 gcd[k].gd.handle_controlevent = OPT_PSHints;
578 gcd[k].gd.cid = CID_PS_Hints;
579 gcd[k++].creator = GCheckBoxCreate;
580 hvarray1[5] = &gcd[k-1]; hvarray1[6] = GCD_ColSpan;
581
582 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+4; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
583 gcd[k].gd.flags = gg_visible;
584 label[k].text = (unichar_t *) _("Flex Hints");
585 label[k].text_is_1byte = true;
586 gcd[k].gd.popup_msg = _("Do you want the font file to contain PostScript flex hints?");
587 gcd[k].gd.label = &label[k];
588 gcd[k].gd.cid = CID_PS_Flex;
589 gcd[k++].creator = GCheckBoxCreate;
590 hvarray1[10] = GCD_HPad10; hvarray1[11] = &gcd[k-1];
591 hvarray1[15] = GCD_Glue; hvarray1[16] = GCD_Glue;
592
593 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
594 gcd[k].gd.flags = 0;
595 label[k].text = (unichar_t *) _("Hint Substitution");
596 label[k].text_is_1byte = true;
597 gcd[k].gd.popup_msg = _("Do you want the font file to do hint substitution?");
598 gcd[k].gd.label = &label[k];
599 gcd[k].gd.cid = CID_PS_HintSubs;
600 gcd[k++].creator = GCheckBoxCreate;
601
602 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
603 gcd[k].gd.flags = 0;
604 label[k].text = (unichar_t *) _("First 256");
605 label[k].text_is_1byte = true;
606 gcd[k].gd.popup_msg = _("Limit the font so that only the glyphs referenced in the first 256 encodings\nwill be included in the file");
607 gcd[k].gd.label = &label[k];
608 gcd[k].gd.cid = CID_PS_Restrict256;
609 gcd[k++].creator = GCheckBoxCreate;
610
611 gcd[k].gd.pos.x = 110; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
612 gcd[k].gd.flags = gg_visible;
613 label[k].text = (unichar_t *) _("Output AFM");
614 label[k].text_is_1byte = true;
615 gcd[k].gd.popup_msg = U_("The AFM file contains metrics information that many word-processors will read when using a PostScriptÂź font.");
616 gcd[k].gd.label = &label[k];
617 gcd[k].gd.cid = CID_PS_AFM;
618 gcd[k++].creator = GCheckBoxCreate;
619 hvarray1[2] = &gcd[k-1]; hvarray1[3] = GCD_ColSpan; hvarray1[4] = NULL;
620
621 gcd[k].gd.pos.x = 112; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
622 gcd[k].gd.flags = gg_visible;
623 label[k].text = (unichar_t *) _("Composites in AFM");
624 label[k].text_is_1byte = true;
625 gcd[k].gd.popup_msg = U_("The AFM format allows some information about composites\n(roughly the same as mark to base anchor classes) to be\nincluded. However it tends to make AFM files huge as it\nis not stored in an efficient manner.");
626 gcd[k].gd.label = &label[k];
627 gcd[k].gd.cid = CID_PS_AFMmarks;
628 gcd[k++].creator = GCheckBoxCreate;
629 hvarray1[7] = GCD_HPad10; hvarray1[8] = &gcd[k-1]; hvarray1[9] = NULL;
630
631 gcd[k].gd.pos.x = gcd[k-2].gd.pos.x; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
632 gcd[k].gd.flags = gg_visible;
633 label[k].text = (unichar_t *) _("Output PFM");
634 label[k].text_is_1byte = true;
635 gcd[k].gd.popup_msg = U_("The PFM file contains information Windows needs to install a PostScriptÂź font.");
636 gcd[k].gd.label = &label[k];
637 gcd[k].gd.cid = CID_PS_PFM;
638 gcd[k++].creator = GCheckBoxCreate;
639 hvarray1[12] = &gcd[k-1]; hvarray1[13] = GCD_ColSpan; hvarray1[14] = NULL;
640
641 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
642 gcd[k].gd.flags = gg_visible;
643 label[k].text = (unichar_t *) _("Output TFM & ENC");
644 label[k].text_is_1byte = true;
645 gcd[k].gd.popup_msg = U_("The tfm and enc files contain information TeX needs to install a PostScriptÂź font.");
646 gcd[k].gd.label = &label[k];
647 gcd[k].gd.cid = CID_PS_TFM;
648 gcd[k++].creator = GCheckBoxCreate;
649 hvarray1[17] = &gcd[k-1]; hvarray1[18] = GCD_ColSpan; hvarray1[19] = NULL;
650 hvarray1[20] = NULL;
651
652 boxes[2].gd.flags = gg_enabled|gg_visible;
653 boxes[2].gd.u.boxelements = hvarray1;
654 boxes[2].gd.label = (GTextInfo *) &gcd[1];
655 boxes[2].creator = GHVGroupCreate;
656
657
658 label[k].text = (unichar_t *) _("SFNT");
659 label[k].text_is_1byte = true;
660 gcd[k].gd.label = &label[k];
661 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[group].gd.pos.y+gcd[group].gd.pos.height+6;
662 gcd[k].gd.flags = gg_enabled | gg_visible;
663 gcd[k++].creator = GLabelCreate;
664
665 group2 = k;
666 gcd[k].gd.pos.x = 4; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+4;
667 gcd[k].gd.pos.width = OPT_Width-8; gcd[k].gd.pos.height = 100;
668 gcd[k].gd.flags = gg_enabled | gg_visible ;
669 gcd[k++].creator = GGroupCreate;
670
671 gcd[k].gd.pos.x = gcd[group+1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+8;
672 gcd[k].gd.flags = gg_visible;
673 label[k].text = (unichar_t *) _("TrueType Hints");
674 label[k].text_is_1byte = true;
675 gcd[k].gd.popup_msg = _("Do you want the font file to contain truetype hints? This will not\ngenerate new instructions, it will just make use of whatever is associated\nwith each character.");
676 gcd[k].gd.label = &label[k];
677 gcd[k].gd.cid = CID_TTF_Hints;
678 gcd[k++].creator = GCheckBoxCreate;
679 hvarray2[0] = &gcd[k-1]; hvarray2[1] = GCD_ColSpan;
680
681 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
682 gcd[k].gd.flags = gg_visible;
683 label[k].text = (unichar_t *) _("PS Glyph Names");
684 label[k].text_is_1byte = true;
685 gcd[k].gd.popup_msg = _("Do you want the font file to contain the names of each glyph in the font?");
686 gcd[k].gd.label = &label[k];
687 gcd[k].gd.cid = CID_TTF_FullPS;
688 gcd[k++].creator = GCheckBoxCreate;
689 hvarray2[5] = &gcd[k-1]; hvarray2[6] = GCD_ColSpan;
690
691 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
692 gcd[k].gd.flags = gg_visible;
693 label[k].text = (unichar_t *) _("Apple");
694 label[k].text_is_1byte = true;
695 gcd[k].gd.popup_msg = _("Apple and MS/Adobe differ about the format of truetype and opentype files\nThis allows you to select which standard to follow for your font.\nThe main differences are:\n The requirements for the 'postscript' name in the name table conflict\n Bitmap data are stored in different tables\n Scaled composite characters are treated differently\n Use of GSUB rather than morx(t)/feat\n Use of GPOS rather than kern/opbd\n Use of GDEF rather than lcar/prop");
696 gcd[k].gd.label = &label[k];
697 gcd[k].gd.cid = CID_TTF_AppleMode;
698 gcd[k].gd.handle_controlevent = OPT_Applemode;
699 gcd[k++].creator = GCheckBoxCreate;
700 hvarray2[10] = &gcd[k-1]; hvarray2[11] = GCD_ColSpan;
701
702 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
703 gcd[k].gd.flags = gg_visible;
704 label[k].text = (unichar_t *) _("OpenType");
705 label[k].text_is_1byte = true;
706 gcd[k].gd.popup_msg = _("Apple and MS/Adobe differ about the format of truetype and opentype files\nThis allows you to select which standard to follow for your font.\nThe main differences are:\n The requirements for the 'postscript' name in the name table conflict\n Bitmap data are stored in different tables\n Scaled composite glyphs are treated differently\n Use of GSUB rather than morx(t)/feat\n Use of GPOS rather than kern/opbd\n Use of GDEF rather than lcar/prop");
707 gcd[k].gd.label = &label[k];
708 gcd[k].gd.cid = CID_TTF_OpenTypeMode;
709 gcd[k++].creator = GCheckBoxCreate;
710 hvarray2[15] = &gcd[k-1]; hvarray2[16] = GCD_ColSpan;
711
712 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+4; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
713 gcd[k].gd.flags = gg_visible;
714 label[k].text = (unichar_t *) _("Old style 'kern'");
715 label[k].text_is_1byte = true;
716 gcd[k].gd.popup_msg = _("Many applications still don't support 'GPOS' kerning.\nIf you want to include both 'GPOS' and old-style 'kern'\ntables set this check box.\nIt may not be set in conjunction with the Apple checkbox.\nThis may confuse other applications though.");
717 gcd[k].gd.label = &label[k];
718 gcd[k].gd.cid = CID_TTF_OldKern;
719 gcd[k].gd.handle_controlevent = OPT_OldKern;
720 gcd[k++].creator = GCheckBoxCreate;
721 hvarray2[20] = GCD_HPad10; hvarray2[21] = &gcd[k-1];
722
723 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+4; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
724 gcd[k].gd.flags = gg_visible;
725 label[k].text = (unichar_t *) _("Dummy 'DSIG'");
726 label[k].text_is_1byte = true;
727 gcd[k].gd.popup_msg = _(
728 "MS uses the presence of a 'DSIG' table to determine whether to use an OpenType\n"
729 "icon for the tt font. FontForge can't generate a useful 'DSIG' table, but it can\n"
730 "generate an empty one with no signature info. A pointless table.");
731 gcd[k].gd.label = &label[k];
732 gcd[k].gd.cid = CID_TTF_DummyDSIG;
733 gcd[k++].creator = GCheckBoxCreate;
734 hvarray2[25] = GCD_HPad10; hvarray2[26] = &gcd[k-1];
735
736 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
737 gcd[k].gd.flags = gg_visible;
738 label[k].text = (unichar_t *) _("Output Glyph Map");
739 label[k].text_is_1byte = true;
740 gcd[k].gd.popup_msg = _("When generating a truetype or opentype font it is occasionally\nuseful to know the mapping between truetype glyph ids and\nglyph names. Setting this option will cause FontForge to\nproduce a file (with extension .g2n) containing those data.");
741 gcd[k].gd.label = &label[k];
742 gcd[k].gd.cid = CID_TTF_GlyphMap;
743 gcd[k++].creator = GCheckBoxCreate;
744 hvarray2[30] = &gcd[k-1]; hvarray2[31] = GCD_ColSpan;
745
746 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
747 gcd[k].gd.flags = gg_visible;
748 label[k].text = (unichar_t *) _("Output OFM & CFG");
749 label[k].text_is_1byte = true;
750 gcd[k].gd.popup_msg = _("The ofm and cfg files contain information Omega needs to process a font.");
751 gcd[k].gd.label = &label[k];
752 gcd[k].gd.cid = CID_TTF_OFM;
753 gcd[k++].creator = GCheckBoxCreate;
754 hvarray2[35] = &gcd[k-1]; hvarray2[36] = GCD_ColSpan;
755
756 gcd[k].gd.pos.x = gcd[group+6].gd.pos.x; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
757 gcd[k].gd.flags = gg_visible;
758 label[k].text = (unichar_t *) _("PfaEdit Table");
759 label[k].text_is_1byte = true;
760 gcd[k].gd.popup_msg = _("The PfaEdit table is an extension to the TrueType format\nand contains various data used by FontForge\n(It should be called the FontForge table,\nbut isn't for historical reasons)");
761 gcd[k].gd.label = &label[k];
762 gcd[k].gd.cid = CID_TTF_PfEd;
763 gcd[k++].creator = GLabelCreate;
764 hvarray2[2] = &gcd[k-1]; hvarray2[3] = GCD_ColSpan; hvarray2[4] = NULL;
765
766 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x+2; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y-4;
767 gcd[k].gd.flags = gg_visible;
768 label[k].text = (unichar_t *) _("Save Comments");
769 label[k].text_is_1byte = true;
770 gcd[k].gd.popup_msg = _("Save glyph comments in the PfEd table");
771 gcd[k].gd.label = &label[k];
772 gcd[k].gd.cid = CID_TTF_PfEdComments;
773 gcd[k++].creator = GCheckBoxCreate;
774 hvarray2[7] = GCD_HPad10; hvarray2[8] = &gcd[k-1]; hvarray2[9] = NULL;
775
776 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y-4;
777 gcd[k].gd.flags = gg_visible;
778 label[k].text = (unichar_t *) _("Save Colors");
779 label[k].text_is_1byte = true;
780 gcd[k].gd.popup_msg = _("Save glyph colors in the PfEd table");
781 gcd[k].gd.label = &label[k];
782 gcd[k].gd.cid = CID_TTF_PfEdColors;
783 gcd[k++].creator = GCheckBoxCreate;
784 hvarray2[12] = GCD_HPad10; hvarray2[13] = &gcd[k-1]; hvarray2[14] = NULL;
785
786 gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
787 gcd[k].gd.flags = gg_visible;
788 label[k].text = (unichar_t *) _("Lookup Names");
789 label[k].text_is_1byte = true;
790 gcd[k].gd.popup_msg = _("Preserve the names of the GPOS/GSUB lookups and subtables");
791 gcd[k].gd.label = &label[k];
792 gcd[k].gd.cid = CID_TTF_PfEdLookups;
793 gcd[k++].creator = GCheckBoxCreate;
794 hvarray2[17] = GCD_HPad10; hvarray2[18] = &gcd[k-1]; hvarray2[19] = NULL;
795
796 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
797 gcd[k].gd.flags = gg_visible;
798 label[k].text = (unichar_t *) _("Save Guides");
799 label[k].text_is_1byte = true;
800 gcd[k].gd.popup_msg = _("Save the guidelines in the Guide layer.");
801 gcd[k].gd.label = &label[k];
802 gcd[k].gd.cid = CID_TTF_PfEdGuides;
803 gcd[k++].creator = GCheckBoxCreate;
804 hvarray2[22] = GCD_HPad10; hvarray2[23] = &gcd[k-1]; hvarray2[24] = NULL;
805
806 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14;
807 gcd[k].gd.flags = gg_visible;
808 label[k].text = (unichar_t *) _("Save Layers");
809 label[k].text_is_1byte = true;
810 gcd[k].gd.popup_msg = _(
811 "Preserve any background and spiro layers.\n"
812 "Also if we output a truetype font from a\n"
813 "cubic database, save the cubic splines.");
814 gcd[k].gd.label = &label[k];
815 gcd[k].gd.cid = CID_TTF_PfEdLayers;
816 gcd[k++].creator = GCheckBoxCreate;
817 hvarray2[27] = GCD_HPad10; hvarray2[28] = &gcd[k-1]; hvarray2[29] = NULL;
818
819 gcd[k].gd.pos.x = gcd[k-3].gd.pos.x; gcd[k].gd.pos.y = gcd[k-5].gd.pos.y;
820 gcd[k].gd.flags = gg_visible;
821 label[k].text = (unichar_t *) _("FFTM Table");
822 label[k].text_is_1byte = true;
823 gcd[k].gd.popup_msg = _("The FFTM table is an extension to the TrueType format\nand contains a series of timestamps defined by FontForge\n");
824 gcd[k].gd.label = &label[k];
825 gcd[k].gd.cid = CID_TTF_FFTMTable;
826 gcd[k++].creator = GCheckBoxCreate;
827 hvarray2[32] = &gcd[k-1]; hvarray2[33] = GCD_ColSpan; hvarray2[34] = NULL;
828
829 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;
830 gcd[k].gd.flags = gg_visible;
831 label[k].text = (unichar_t *) _("TeX Table");
832 label[k].text_is_1byte = true;
833 gcd[k].gd.popup_msg = _("The TeX table is an extension to the TrueType format\nand the various data you would expect to find in\na tfm file (that isn't already stored elsewhere\nin the ttf file)\n");
834 gcd[k].gd.label = &label[k];
835 gcd[k].gd.cid = CID_TTF_TeXTable;
836 gcd[k++].creator = GCheckBoxCreate;
837 hvarray2[37] = &gcd[k-1]; hvarray2[38] = GCD_ColSpan; hvarray2[39] = NULL;
838 hvarray2[40] = GCD_Glue; hvarray2[41] = GCD_Glue; hvarray2[42] = NULL;
839 hvarray2[43] = NULL;
840
841 boxes[3].gd.flags = gg_enabled|gg_visible;
842 boxes[3].gd.u.boxelements = hvarray2;
843 boxes[3].gd.label = (GTextInfo *) &gcd[group2-1];
844 boxes[3].creator = GHVGroupCreate;
845
846 gcd[k].gd.flags = gg_visible | gg_enabled;
847 label[k].text = (unichar_t *) _("Output FONTLOG.txt");
848 label[k].text_is_1byte = true;
849 gcd[k].gd.popup_msg = _(
850 "The FONTLOG is a text file containing relevant information\n"
851 "about the font including such things as its changelog.\n"
852 "(A general template is available in the OFL FAQ on http://scripts.sil.org/OFL-FAQ_web)\n"
853 "Usage within an open font project is highly recommended but not required.\n"
854 "If your font already contains a fontlog table (see the Element->Font Info)\n"
855 "and you check this box, then the internal fontlog information will be\n"
856 "appended to the file \"FONTLOG.txt\" in the same directory\n"
857 "as the font itself.");
858 gcd[k].gd.label = &label[k];
859 gcd[k].gd.cid = CID_FontLog;
860 gcd[k++].creator = GCheckBoxCreate;
861 hvarray3[0] = &gcd[k-1];
862
863 gcd[k].gd.pos.y = gcd[k-1].gd.pos.y; gcd[k].gd.pos.x = gcd[k-2].gd.pos.x;
864 gcd[k].gd.flags = gg_visible | gg_enabled;
865 label[k].text = (unichar_t *) _("Prefer native kerning");
866 label[k].text_is_1byte = true;
867 gcd[k].gd.popup_msg = _(
868 "Use native kerning structures (instead of a feature file) even when this might lose information.\n");
869 gcd[k].gd.label = &label[k];
870 gcd[k].gd.cid = CID_NativeKern;
871 gcd[k++].creator = GCheckBoxCreate;
872 hvarray3[1] = &gcd[k-1]; hvarray3[2]=NULL;
873
874 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;
875 gcd[k].gd.flags = gg_visible | gg_enabled;
876 label[k].text = (unichar_t *) _("Windows-compatible \'kern\'");
877 label[k].text_is_1byte = true;
878 gcd[k].gd.popup_msg = _("If the old-style \'kern\' table contains unencoded glyphs\n(or glyphs encoded outside of the BMP), many Windows applications\nwon't have any kerning at all. This option excludes such\nproblematic glyphs from the old-style \'kern\' table.");
879 gcd[k].gd.label = &label[k];
880 gcd[k].gd.cid = CID_TTF_OldKernMappedOnly;
881 gcd[k++].creator = GCheckBoxCreate;
882 hvarray3[3] = &gcd[k-1]; hvarray3[4] = NULL;
883
884 gcd[k].gd.pos.x = gcd[k-1].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y;
885 gcd[k].gd.flags = gg_visible | gg_enabled;
886 label[k].text = (unichar_t *) _("No Mac Names");
887 label[k].text_is_1byte = true;
888 gcd[k].gd.popup_msg = _("Do not add duplicated name entries for legacy Mac platform. These name entries are only needed for some legacy Mac applications.");
889 gcd[k].gd.label = &label[k];
890 gcd[k].gd.cid = CID_TTF_NoMacNames;
891 gcd[k++].creator = GCheckBoxCreate;
892 hvarray3[5] = &gcd[k-1];
893
894 hvarray3[6] = NULL; hvarray3[7] = NULL;
895
896 boxes[4].gd.flags = gg_enabled|gg_visible;
897 boxes[4].gd.u.boxelements = hvarray3;
898 boxes[4].gd.label = NULL;
899 boxes[4].creator = GHVGroupCreate;
900
901 gcd[k].gd.pos.x = 30-3; gcd[k].gd.pos.y = gcd[group2].gd.pos.y+gcd[group2].gd.pos.height+10-3;
902 gcd[k].gd.pos.width = -1;
903 gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default;
904 label[k].text = (unichar_t *) _("_OK");
905 label[k].text_is_1byte = true;
906 label[k].text_in_resource = true;
907 gcd[k].gd.label = &label[k];
908 gcd[k].gd.cid = CID_OK;
909 gcd[k++].creator = GButtonCreate;
910 harray[0] = GCD_Glue; harray[1] = &gcd[k-1]; harray[2] = GCD_Glue;
911
912 gcd[k].gd.pos.x = -30; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+3;
913 gcd[k].gd.pos.width = -1;
914 gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
915 label[k].text = (unichar_t *) _("_Cancel");
916 label[k].text_is_1byte = true;
917 label[k].text_in_resource = true;
918 gcd[k].gd.label = &label[k];
919 gcd[k++].creator = GButtonCreate;
920 harray[3] = GCD_Glue; harray[4] = &gcd[k-1]; harray[5] = GCD_Glue;
921 harray[6] = NULL;
922
923 boxes[5].gd.flags = gg_enabled|gg_visible;
924 boxes[5].gd.u.boxelements = harray;
925 boxes[5].creator = GHBoxCreate;
926
927 varray[0] = &boxes[2]; varray[1] = NULL;
928 varray[2] = &boxes[3]; varray[3] = NULL;
929 varray[4] = &boxes[4]; varray[5] = NULL;
930 varray[6] = GCD_Glue; varray[7] = NULL;
931 varray[8] = &boxes[5]; varray[9] = NULL;
932 varray[10] = NULL;
933
934 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
935 boxes[0].gd.flags = gg_enabled|gg_visible;
936 boxes[0].gd.u.boxelements = varray;
937 boxes[0].creator = GHVGroupCreate;
938
939 GGadgetsCreate(gw,boxes);
940 GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue);
941 GHVBoxSetExpandableCol(boxes[4].ret,gb_expandgluesame);
942 GHVBoxFitWindow(boxes[0].ret);
943
944 OptSetDefaults(gw,d,which,iscid);
945
946 GDrawSetVisible(gw,true);
947 while ( !d->sod_done )
948 GDrawProcessOneEvent(NULL);
949 GDrawDestroyWindow(gw);
950 }
951
952 static int br_e_h(GWindow gw, GEvent *event) {
953 if ( event->type==et_close ) {
954 int *done = GDrawGetUserData(gw);
955 *done = -1;
956 } else if ( event->type == et_char ) {
957 return( false );
958 } else if ( event->type == et_map ) {
959 /* Above palettes */
960 GDrawRaise(gw);
961 } else if ( event->type==et_controlevent && event->u.control.subtype == et_buttonactivate ) {
962 int *done = GDrawGetUserData(gw);
963 if ( GGadgetGetCid(event->u.control.g)==1001 )
964 *done = true;
965 else
966 *done = -1;
967 } else if ( event->type==et_controlevent && event->u.control.subtype == et_textchanged &&
968 GGadgetGetCid(event->u.control.g)==1003 ) {
969 GGadgetSetChecked(GWidgetGetControl(gw,1004),true);
970 }
971 return( true );
972 }
973
974 static int AskResolution(int bf,BDFFont *bdf) {
975 GRect pos;
976 static GWindow bdf_gw, fon_gw;
977 GWindow gw;
978 GWindowAttrs wattrs;
979 GGadgetCreateData gcd[10], *varray[22], *harray[7], *harray2[4], boxes[4];
980 GTextInfo label[10];
981 int done=-3;
982 int def_res = -1;
983 char buf[20];
984
985 if ( bdf!=NULL )
986 def_res = bdf->res;
987
988 if ( no_windowing_ui )
989 return( -1 );
990
991 gw = bf==bf_bdf ? bdf_gw : fon_gw;
992 if ( gw==NULL ) {
993 memset(&wattrs,0,sizeof(wattrs));
994 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
995 wattrs.event_masks = ~(1<<et_charup);
996 wattrs.restrict_input_to_me = 1;
997 wattrs.undercursor = 1;
998 wattrs.cursor = ct_pointer;
999 wattrs.utf8_window_title = _("BDF Resolution");
1000 wattrs.is_dlg = true;
1001 pos.x = pos.y = 0;
1002 pos.width = GGadgetScale(GDrawPointsToPixels(NULL,150));
1003 pos.height = GDrawPointsToPixels(NULL,130);
1004 gw = GDrawCreateTopWindow(NULL,&pos,br_e_h,&done,&wattrs);
1005 if ( bf==bf_bdf )
1006 bdf_gw = gw;
1007 else
1008 fon_gw = gw;
1009
1010 memset(&label,0,sizeof(label));
1011 memset(&gcd,0,sizeof(gcd));
1012 memset(&boxes,0,sizeof(boxes));
1013
1014 label[0].text = (unichar_t *) _("BDF Resolution");
1015 label[0].text_is_1byte = true;
1016 gcd[0].gd.label = &label[0];
1017 gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 7;
1018 gcd[0].gd.flags = gg_enabled|gg_visible;
1019 gcd[0].creator = GLabelCreate;
1020 harray2[0] = GCD_Glue; harray2[1] = &gcd[0]; harray2[2] = GCD_Glue; harray2[3] = NULL;
1021
1022 boxes[3].gd.flags = gg_enabled|gg_visible;
1023 boxes[3].gd.u.boxelements = harray2;
1024 boxes[3].creator = GHBoxCreate;
1025 varray[0] = &boxes[3]; varray[1] = GCD_ColSpan; varray[2] = NULL;
1026
1027 label[1].text = (unichar_t *) (bf==bf_bdf ? "75" : "96");
1028 label[1].text_is_1byte = true;
1029 gcd[1].gd.label = &label[1];
1030 gcd[1].gd.mnemonic = (bf==bf_bdf ? '7' : '9');
1031 gcd[1].gd.pos.x = 20; gcd[1].gd.pos.y = 13+7;
1032 gcd[1].gd.flags = gg_enabled|gg_visible;
1033 if ( (bf==bf_bdf ? 75 : 96)==def_res )
1034 gcd[1].gd.flags |= gg_cb_on;
1035 gcd[1].gd.cid = 75;
1036 gcd[1].creator = GRadioCreate;
1037 varray[3] = &gcd[1]; varray[4] = GCD_Glue; varray[5] = NULL;
1038
1039 label[2].text = (unichar_t *) (bf==bf_bdf ? "100" : "120");
1040 label[2].text_is_1byte = true;
1041 gcd[2].gd.label = &label[2];
1042 gcd[2].gd.mnemonic = '1';
1043 gcd[2].gd.pos.x = 20; gcd[2].gd.pos.y = gcd[1].gd.pos.y+17;
1044 gcd[2].gd.flags = gg_enabled|gg_visible;
1045 if ( (bf==bf_bdf ? 100 : 120)==def_res )
1046 gcd[2].gd.flags |= gg_cb_on;
1047 gcd[2].gd.cid = 100;
1048 gcd[2].creator = GRadioCreate;
1049 varray[6] = &gcd[2]; varray[7] = GCD_Glue; varray[8] = NULL;
1050
1051 label[3].text = (unichar_t *) _("_Guess");
1052 label[3].text_is_1byte = true;
1053 label[3].text_in_resource = true;
1054 gcd[3].gd.label = &label[3];
1055 gcd[3].gd.pos.x = 20; gcd[3].gd.pos.y = gcd[2].gd.pos.y+17;
1056 gcd[3].gd.flags = gg_enabled|gg_visible;
1057 if ( !((gcd[1].gd.flags|gcd[2].gd.flags)&gg_cb_on) )
1058 gcd[3].gd.flags |= gg_cb_on;
1059 gcd[3].gd.cid = -1;
1060 gcd[3].gd.popup_msg = _("Guess each font's resolution based on its pixel size");
1061 gcd[3].creator = GRadioCreate;
1062 varray[9] = &gcd[3]; varray[10] = GCD_Glue; varray[11] = NULL;
1063
1064 label[4].text = (unichar_t *) _("_Other");
1065 label[4].text_is_1byte = true;
1066 label[4].text_in_resource = true;
1067 gcd[4].gd.label = &label[4];
1068 gcd[4].gd.pos.x = 20; gcd[4].gd.pos.y = gcd[3].gd.pos.y+17;
1069 gcd[4].gd.flags = gg_enabled|gg_visible;
1070 gcd[4].gd.cid = 1004;
1071 gcd[4].creator = GRadioCreate;
1072
1073 label[5].text = (unichar_t *) (bf == bf_bdf ? "96" : "72");
1074 if ( def_res>0 ) {
1075 sprintf( buf, "%d", def_res );
1076 label[5].text = (unichar_t *) buf;
1077 }
1078 label[5].text_is_1byte = true;
1079 gcd[5].gd.label = &label[5];
1080 gcd[5].gd.pos.x = 70; gcd[5].gd.pos.y = gcd[4].gd.pos.y-3; gcd[5].gd.pos.width = 40;
1081 gcd[5].gd.flags = gg_enabled|gg_visible;
1082 gcd[5].gd.cid = 1003;
1083 gcd[5].creator = GTextFieldCreate;
1084 varray[12] = &gcd[4]; varray[13] = &gcd[5]; varray[14] = NULL;
1085 varray[15] = GCD_Glue; varray[16] = GCD_Glue; varray[17] = NULL;
1086
1087 gcd[6].gd.pos.x = 15-3; gcd[6].gd.pos.y = gcd[4].gd.pos.y+24;
1088 gcd[6].gd.pos.width = -1; gcd[6].gd.pos.height = 0;
1089 gcd[6].gd.flags = gg_visible | gg_enabled | gg_but_default;
1090 label[6].text = (unichar_t *) _("_OK");
1091 label[6].text_is_1byte = true;
1092 label[6].text_in_resource = true;
1093 gcd[6].gd.mnemonic = 'O';
1094 gcd[6].gd.label = &label[6];
1095 gcd[6].gd.cid = 1001;
1096 gcd[6].creator = GButtonCreate;
1097 harray[0] = GCD_Glue; harray[1] = &gcd[6]; harray[2] = GCD_Glue;
1098
1099 gcd[7].gd.pos.x = -15; gcd[7].gd.pos.y = gcd[6].gd.pos.y+3;
1100 gcd[7].gd.pos.width = -1; gcd[7].gd.pos.height = 0;
1101 gcd[7].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
1102 label[7].text = (unichar_t *) _("_Cancel");
1103 label[7].text_is_1byte = true;
1104 label[7].text_in_resource = true;
1105 gcd[7].gd.label = &label[7];
1106 gcd[7].gd.mnemonic = 'C';
1107 /*gcd[7].gd.handle_controlevent = CH_Cancel;*/
1108 gcd[7].gd.cid = 1002;
1109 gcd[7].creator = GButtonCreate;
1110 harray[3] = GCD_Glue; harray[4] = &gcd[7]; harray[5] = GCD_Glue;
1111 harray[6] = NULL;
1112
1113 boxes[2].gd.flags = gg_enabled|gg_visible;
1114 boxes[2].gd.u.boxelements = harray;
1115 boxes[2].creator = GHBoxCreate;
1116 varray[18] = &boxes[2]; varray[19] = GCD_ColSpan; varray[20] = NULL;
1117 varray[21] = NULL;
1118
1119 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
1120 boxes[0].gd.flags = gg_enabled|gg_visible;
1121 boxes[0].gd.u.boxelements = varray;
1122 boxes[0].creator = GHVGroupCreate;
1123
1124 gcd[8].gd.pos.x = 2; gcd[8].gd.pos.y = 2;
1125 gcd[8].gd.pos.width = pos.width-4; gcd[8].gd.pos.height = pos.height-2;
1126 gcd[8].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels;
1127 gcd[8].creator = GGroupCreate;
1128
1129 GGadgetsCreate(gw,boxes);
1130 GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue);
1131 GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame);
1132 } else
1133 GDrawSetUserData(gw,&done);
1134
1135 GDrawSetVisible(gw,true);
1136 while ( true ) {
1137 done = 0;
1138 while ( !done )
1139 GDrawProcessOneEvent(NULL);
1140 if ( GGadgetIsChecked(GWidgetGetControl(gw,1004)) ) {
1141 int err = false;
1142 int res = GetInt8(gw,1003,_("Other ..."),&err);
1143 if ( res<10 )
1144 GGadgetProtest8( _("_Other"));
1145 else if ( !err ) {
1146 GDrawSetVisible(gw,false);
1147 return( res );
1148 }
1149 continue;
1150 }
1151 GDrawSetVisible(gw,false);
1152 if ( done==-1 )
1153 return( -2 );
1154 if ( GGadgetIsChecked(GWidgetGetControl(gw,75)) )
1155 return( bf == bf_bdf ? 75 : 96 );
1156 if ( GGadgetIsChecked(GWidgetGetControl(gw,100)) )
1157 return( bf == bf_bdf ? 100 : 120 );
1158 /*if ( GGadgetIsChecked(GWidgetGetControl(gw,-1)) )*/
1159 return( -1 );
1160 }
1161 }
1162
1163 static char *SearchDirForWernerFile(const char *dir,char *filename) {
1164 char buffer[1025], buf2[200];
1165 FILE *file;
1166 int good = 0;
1167
1168 if ( dir==NULL || filename==NULL || \
1169 strlen(dir)+strlen(filename)>sizeof(buffer)-2 )
1170 return( NULL );
1171
1172 strcpy(buffer,dir);
1173 strcat(buffer,"/");
1174 strcat(buffer,filename);
1175 if ( (file=fopen(buffer,"r"))==NULL )
1176 return( NULL );
1177 if ( fgets(buf2,sizeof(buf2),file)!=NULL && \
1178 strncmp(buf2,pfaeditflag,strlen(pfaeditflag))==0 )
1179 good = 1;
1180 fclose( file );
1181 if ( good )
1182 return( copy(buffer) );
1183
1184 return( NULL );
1185 }
1186
1187 static enum fchooserret GFileChooserFilterWernerSFDs(GGadget *g,const struct gdirentry *ent,
1188 const char *dir) {
1189 enum fchooserret ret = GFileChooserDefFilter(g,ent,dir);
1190 char buf2[200];
1191 FILE *file;
1192
1193 if ( ret==fc_show && !ent->isdir ) {
1194 file = fopen(ent->fullpath,"r");
1195 if ( file==NULL )
1196 ret = fc_hide;
1197 else {
1198 if ( fgets(buf2,sizeof(buf2),file)==NULL ||
1199 strncmp(buf2,pfaeditflag,strlen(pfaeditflag))==0 )
1200 ret = fc_hide;
1201 fclose(file);
1202 }
1203 }
1204 return( ret );
1205 }
1206
1207 static char *GetWernerSFDFile(SplineFont *sf,EncMap *map) {
1208 char *def=NULL, *ret;
1209 char buffer[100];
1210 int supl = sf->supplement;
1211
1212 for ( supl = sf->supplement; supl<sf->supplement+10 ; ++supl ) {
1213 if ( no_windowing_ui ) {
1214 if ( sf->subfontcnt!=0 ) {
1215 sprintf(buffer,"%.40s-%.40s-%d.sfd", sf->cidregistry,sf->ordering,supl);
1216 def = buffer;
1217 } else if ( strstrmatch(map->enc->enc_name,"big")!=NULL &&
1218 strchr(map->enc->enc_name,'5')!=NULL ) {
1219 if (strstrmatch(map->enc->enc_name,"hkscs")!=NULL )
1220 def = "Big5HKSCS.sfd";
1221 else
1222 def = "Big5.sfd";
1223 } else if ( strstrmatch(map->enc->enc_name,"sjis")!=NULL )
1224 def = "Sjis.sfd";
1225 else if ( strstrmatch(map->enc->enc_name,"Wansung")!=NULL ||
1226 strstrmatch(map->enc->enc_name,"EUC-KR")!=NULL )
1227 def = "Wansung.sfd";
1228 else if ( strstrmatch(map->enc->enc_name,"johab")!=NULL )
1229 def = "Johab.sfd";
1230 else if ( map->enc->is_unicodebmp || map->enc->is_unicodefull )
1231 def = "Unicode.sfd";
1232 }
1233 if ( def!=NULL ) {
1234 ret = SearchDirForWernerFile(".",def);
1235 if ( ret==NULL )
1236 ret = SearchDirForWernerFile(getFontForgeShareDir(),def);
1237 if ( ret!=NULL )
1238 return( ret );
1239 }
1240 if ( sf->subfontcnt!=0 )
1241 break;
1242 }
1243
1244 if ( no_windowing_ui )
1245 return( NULL );
1246
1247 /*if ( def==NULL )*/
1248 def = "*.sfd";
1249 ret = gwwv_open_filename(_("Find Sub Font Definition file"),NULL,"*.sfd",GFileChooserFilterWernerSFDs);
1250 return( ret );
1251 }
1252
1253 static int AnyRefs(RefChar *refs) {
1254 int j;
1255 while ( refs!=NULL ) {
1256 for ( j=0; j<refs->layer_cnt; ++j )
1257 if ( refs->layers[j].splines!=NULL )
1258 return( true );
1259 refs = refs->next;
1260 }
1261 return( false );
1262 }
1263
1264 int will_prepend_timestamp = false;
1265
1266 static void prepend_timestamp(struct gfc_data *d){
1267
1268 if (d->sf->familyname_with_timestamp)
1269 free(d->sf->familyname_with_timestamp);
1270 d->sf->familyname_with_timestamp = NULL;
1271
1272 if (will_prepend_timestamp){
1273 //prepend "YYMMDDHHMM-"
1274
1275 time_t rawtime;
1276 struct tm * timeinfo;
1277 time(&rawtime);
1278 timeinfo = localtime(&rawtime);
1279 char timestamp[11];
1280 strftime(timestamp, 11, "%y%m%d%H%M", timeinfo);
1281
1282 char* new_name;
1283 char* original_name = (d->sf->familyname) ? d->sf->familyname : d->sf->fontname;
1284 int i;
1285
1286 if (original_name!=NULL){
1287 //if we already have a timestamp prepended, we should remove it before appending a new one
1288 int timestamp_found = (original_name[10]=='-');
1289 for (i=0;i<10;i++)
1290 if (original_name[i]<'0' || original_name[i]>'9')
1291 timestamp_found = false;
1292
1293 if (timestamp_found)
1294 original_name = original_name + 11; //skip previous timestamp
1295
1296 new_name = malloc (sizeof(char) * (strlen(original_name) + 12));
1297 sprintf(new_name, "%s-%s", timestamp, original_name);
1298
1299 d->sf->familyname_with_timestamp = new_name;
1300 }
1301 }
1302 }
1303
1304 static void DoSave(struct gfc_data *d,unichar_t *path) {
1305 int err=false;
1306 char *temp;
1307 int32_t *sizes=NULL;
1308 int iscid, i;
1309 struct sflist *sfs=NULL, *cur, *last=NULL;
1310 static int psscalewarned=0, ttfscalewarned=0, psfnlenwarned=0;
1311 int flags;
1312 struct sflist *sfl;
1313 char **former;
1314 NameList *rename_to;
1315 GTextInfo *ti = GGadgetGetListItemSelected(d->rename);
1316 char *nlname = u2utf8_copy(ti->text);
1317 extern NameList *force_names_when_saving;
1318 int notdef_pos = SFFindNotdef(d->sf,-1);
1319 int layer = ly_fore;
1320 int likecff;
1321 char *buts[3];
1322
1323 prepend_timestamp(d);
1324
1325 buts[0] = _("_Yes");
1326 buts[1] = _("_No");
1327 buts[2] = NULL;
1328
1329 rename_to = NameListByName(nlname);
1330 free(nlname);
1331 if ( rename_to!=NULL && rename_to->uses_unicode ) {
1332 /* I'll let someone generate a font with utf8 names, but I won't let */
1333 /* them take a font and force it to unicode here. */
1334 ff_post_error(_("Namelist contains non-ASCII names"),_("Glyph names should be limited to characters in the ASCII character set, but there are names in this namelist which use characters outside that range."));
1335 return;
1336 }
1337
1338 for ( i=d->sf->glyphcnt-1; i>=1; --i ) if ( i!=notdef_pos )
1339 if ( d->sf->glyphs[i]!=NULL && strcmp(d->sf->glyphs[i]->name,".notdef")==0 &&
1340 (d->sf->glyphs[i]->layers[ly_fore].splines!=NULL || AnyRefs(d->sf->glyphs[i]->layers[ly_fore].refs )))
1341 break;
1342 if ( i>0 ) {
1343 if ( gwwv_ask(_("Notdef name"),(const char **) buts,0,1,_("The glyph at encoding %d is named \".notdef\" but contains an outline. Because it is called \".notdef\" it will not be included in the generated font. You may give it a new name using Element->Glyph Info. Do you wish to continue font generation (and omit this character)?"),d->map->backmap[i])==1 )
1344 return;
1345 }
1346
1347 if ( d->family==gf_none )
1348 layer = (intptr_t) GGadgetGetListItemSelected(GWidgetGetControl(d->gw,CID_Layers))->userdata;
1349
1350 temp = u2def_copy(path);
1351 oldformatstate = GGadgetGetFirstListSelectedItem(d->pstype);
1352 iscid = oldformatstate==ff_cid || oldformatstate==ff_cffcid ||
1353 oldformatstate==ff_otfcid || oldformatstate==ff_otfciddfont;
1354 if ( !iscid && (d->sf->cidmaster!=NULL || d->sf->subfontcnt>1)) {
1355 if ( gwwv_ask(_("Not a CID format"),(const char **) buts,0,1,_("You are attempting to save a CID font in a non-CID format. This is ok, but it means that only the current sub-font will be saved.\nIs that what you want?"))==1 )
1356 return;
1357 }
1358 if ( oldformatstate == ff_ttf || oldformatstate==ff_ttfsym ||
1359 oldformatstate==ff_ttfmacbin || oldformatstate==ff_ttfdfont ) {
1360 SplineChar *sc; RefChar *ref;
1361 for ( i=0; i<d->sf->glyphcnt; ++i ) if ( (sc = d->sf->glyphs[i])!=NULL ) {
1362 if ( sc->ttf_instrs_len!=0 && sc->instructions_out_of_date ) {
1363 if ( gwwv_ask(_("Instructions out of date"),(const char **) buts,0,1,_("The truetype instructions on glyph %s are out of date.\nDo you want to proceed anyway?"), sc->name)==1 ) {
1364 CharViewCreate(sc,(FontView *) d->sf->fv,-1);
1365 return;
1366 } else
1367 break;
1368 }
1369 for ( ref=sc->layers[ly_fore].refs; ref!=NULL ; ref=ref->next )
1370 if ( ref->point_match_out_of_date && ref->point_match ) {
1371 if ( gwwv_ask(_("Reference point match out of date"),(const char **) buts,0,1,_("In glyph %s the reference to %s is positioned by point matching, and the point numbers may no longer reflect the original intent.\nDo you want to proceed anyway?"), sc->name, ref->sc->name)==1 ) {
1372 CharViewCreate(sc,(FontView *) d->sf->fv,-1);
1373 return;
1374 } else
1375 goto end_of_loop;
1376 }
1377 }
1378 end_of_loop:;
1379 }
1380
1381 if ( d->sf->os2_version==1 && (oldformatstate>=ff_otf && oldformatstate<=ff_otfciddfont)) {
1382 ff_post_error(_("Bad OS/2 version"), _("OpenType fonts must have a version greater than 1\nUse Element->Font Info->OS/2->Misc to change this."));
1383 return;
1384 }
1385
1386 likecff = 0;
1387 if ( oldformatstate==ff_ttc ) {
1388 likecff = GGadgetIsChecked(GWidgetGetControl(d->gw,CID_TTC_CFF));
1389 }
1390
1391 if ( likecff || oldformatstate<=ff_cffcid ||
1392 (oldformatstate>=ff_otf && oldformatstate<=ff_otfciddfont) ||
1393 oldformatstate==ff_woff_otf || oldformatstate==ff_woff2_otf) {
1394 if ( d->sf->ascent+d->sf->descent!=1000 && !psscalewarned ) {
1395 if ( gwwv_ask(_("Non-standard Em-Size"),(const char **) buts,0,1,_("The convention is that PostScript fonts should have an Em-Size of 1000. But this font has a size of %d. This is not an error, but you might consider altering the Em-Size with the Element->Font Info->General dialog.\nDo you wish to continue to generate your font in spite of this?"),
1396 d->sf->ascent+d->sf->descent)==1 )
1397 return;
1398 psscalewarned = true;
1399 }
1400 if ( (strlen(d->sf->fontname)>31 || (d->sf->familyname!=NULL && strlen(d->sf->familyname)>31)) && !psfnlenwarned ) {
1401 if ( gwwv_ask(_("Bad Font Name"),(const char **) buts,0,1,_("Some versions of Windows will refuse to install postscript fonts if the fontname is longer than 31 characters. Do you want to continue anyway?"))==1 )
1402 return;
1403 psfnlenwarned = true;
1404 }
1405 } else if ( oldformatstate!=ff_none && oldformatstate!=ff_svg &&
1406 oldformatstate!=ff_ufo && oldformatstate!=ff_ufo2 && oldformatstate!=ff_ufo3 ) {
1407 int val = d->sf->ascent+d->sf->descent;
1408 int bit;
1409 for ( bit=0x800000; bit!=0; bit>>=1 )
1410 if ( bit==val )
1411 break;
1412 if ( bit==0 && !ttfscalewarned ) {
1413 if ( gwwv_ask(_("Non-standard Em-Size"),(const char **) buts,0,1,_("The convention is that TrueType fonts should have an Em-Size which is a power of 2. But this font has a size of %d. This is not an error, but you might consider altering the Em-Size with the Element->Font Info->General dialog.\nDo you wish to continue to generate your font in spite of this?"),val)==1 )
1414 return;
1415 ttfscalewarned = true;
1416 }
1417 }
1418
1419 if ( oldformatstate==ff_ttfsym && AlreadyMSSymbolArea(d->sf,d->map))
1420 /* Don't complain */;
1421 else if ( ((oldformatstate<ff_ptype0 && oldformatstate!=ff_multiple) ||
1422 oldformatstate==ff_ttfsym || oldformatstate==ff_cff ) &&
1423 d->map->enc->has_2byte ) {
1424 char *buts[3];
1425 buts[0] = _("_Yes");
1426 buts[1] = _("_Cancel");
1427 buts[2] = NULL;
1428 if ( gwwv_ask(_("Encoding Too Large"),(const char **) buts,0,1,_("Your font has a 2 byte encoding, but you are attempting to save it in a format that only supports one byte encodings. This means that you won't be able to access anything after the first 256 characters without reencoding the font.\n\nDo you want to proceed anyway?"))==1 )
1429 return;
1430 }
1431
1432 oldbitmapstate = GGadgetGetFirstListSelectedItem(d->bmptype);
1433 if ( oldbitmapstate!=bf_none )
1434 sizes = ParseBitmapSizes(d->bmpsizes,&err);
1435 if ( err )
1436 return;
1437 if ( oldbitmapstate==bf_nfntmacbin && oldformatstate!=ff_pfbmacbin && !nfnt_warned ) {
1438 nfnt_warned = true;
1439 ff_post_notice(_("The 'NFNT' bitmap format is obsolete"),_("The 'NFNT' bitmap format is not used under OS/X (though you still need to create a (useless) bitmap font if you are saving a type1 PostScript resource)"));
1440 } else if ( oldformatstate==ff_pfbmacbin &&
1441 (oldbitmapstate!=bf_nfntmacbin || sizes[0]==0)) {
1442 ff_post_error(_("Needs bitmap font"),_("When generating a Mac Type1 resource font, you MUST generate at least one NFNT bitmap font to go with it. If you have not created any bitmaps for this font, cancel this dlg and use the Element->Bitmaps Available command to create one"));
1443 return;
1444 } else if ( oldformatstate==ff_pfbmacbin && !post_warned) {
1445 post_warned = true;
1446 ff_post_notice(_("The 'POST' type1 format is probably deprecated"),_("The 'POST' type1 format is probably deprecated and may not work in future version of the mac."));
1447 }
1448
1449 if ( d->family ) {
1450 cur = chunkalloc(sizeof(struct sflist));
1451 cur->next = NULL;
1452 sfs = last = cur;
1453 cur->sf = d->sf;
1454 cur->map = EncMapCopy(d->map);
1455 cur->sizes = sizes;
1456 for ( i=0; i<d->familycnt; ++i ) {
1457 if ( GGadgetIsChecked(GWidgetGetControl(d->gw,CID_Family+10*i)) ) {
1458 cur = chunkalloc(sizeof(struct sflist));
1459 last->next = cur;
1460 last = cur;
1461 cur->sf = GGadgetGetUserData(GWidgetGetControl(d->gw,CID_Family+10*i));
1462 if ( oldbitmapstate!=bf_none )
1463 cur->sizes = ParseBitmapSizes(GWidgetGetControl(d->gw,CID_Family+10*i+1),&err);
1464 if ( err ) {
1465 SfListFree(sfs);
1466 return;
1467 }
1468 cur->map = EncMapFromEncoding(cur->sf,d->map->enc);
1469 }
1470 }
1471 } else if ( !d->sf->multilayer && !d->sf->strokedfont && !d->sf->onlybitmaps ) {
1472 if ( oldformatstate == ff_ptype3 || oldformatstate == ff_none )
1473 /* No point in validating type3 fonts */;
1474 else if ( (old_validate = GGadgetIsChecked(d->validate))) {
1475 int vs = SFValidate(d->sf,layer,false);
1476 enum validation_state mask = VSMaskFromFormat(d->sf,layer,oldformatstate);
1477 int blues = ValidatePrivate(d->sf)& ~pds_missingblue;
1478 if ( (vs&mask) || blues!=0 ) {
1479 const char *rsb[3];
1480 char *errs;
1481 int ret;
1482
1483 rsb[0] = _("_Review");
1484 rsb[1] = _("_Generate");
1485 rsb[2]=NULL;
1486 errs = VSErrorsFromMask(vs&mask,blues);
1487 ret = gwwv_ask(_("Errors detected"),rsb,0,0,_("The font contains errors.\n%sWould you like to review the errors or save the font anyway?"),errs);
1488 free(errs);
1489 if ( ret==0 ) {
1490 d->done = true;
1491 d->ret = false;
1492 SFValidationWindow(d->sf,layer,oldformatstate);
1493 return;
1494 }
1495 /* Ok... they want to proceed */
1496 }
1497 }
1498 }
1499
1500 switch ( d->sod_which ) {
1501 case 0: /* PostScript */
1502 flags = old_ps_flags = d->ps_flags;
1503 break;
1504 case 1: /* TrueType */
1505 flags = old_sfnt_flags = d->sfnt_flags;
1506 break;
1507 case 2: /* OpenType */
1508 flags = old_sfnt_flags = d->sfnt_flags;
1509 break;
1510 case 3: /* PostScript & OpenType bitmaps */
1511 old_ps_flags = d->ps_flags;
1512 flags = old_psotb_flags = d->psotb_flags;
1513 break;
1514 }
1515
1516 former = NULL;
1517 if ( d->family && sfs!=NULL ) {
1518 for ( sfl=sfs; sfl!=NULL; sfl=sfl->next ) {
1519 PrepareUnlinkRmOvrlp(sfl->sf,temp,layer);
1520 if ( rename_to!=NULL && !iscid )
1521 sfl->former_names = SFTemporaryRenameGlyphsToNamelist(sfl->sf,rename_to);
1522 }
1523 } else {
1524 PrepareUnlinkRmOvrlp(d->sf,temp,layer);
1525 if ( rename_to!=NULL && !iscid )
1526 former = SFTemporaryRenameGlyphsToNamelist(d->sf,rename_to);
1527 }
1528
1529 if ( d->family==gf_none ) {
1530 char *wernersfdname = NULL;
1531 char *old_fontlog_contents;
1532 int res = -1;
1533 if ( oldformatstate == ff_multiple )
1534 wernersfdname = GetWernerSFDFile(d->sf,d->map);
1535 if (( oldbitmapstate==bf_bdf || oldbitmapstate==bf_fnt ||
1536 oldbitmapstate==bf_fon ) && ask_user_for_resolution ) {
1537 ff_progress_pause_timer();
1538 res = AskResolution(oldbitmapstate,d->sf->bitmaps);
1539 ff_progress_resume_timer();
1540 }
1541 old_fontlog = GGadgetIsChecked(GWidgetGetControl(d->gw,CID_AppendFontLog));
1542 old_fontlog_contents = NULL;
1543 if ( old_fontlog ) {
1544 char *new = GGadgetGetTitle8(GWidgetGetControl(d->gw,CID_FontLogBit));
1545 if ( new!=NULL && *new!='\0' ) {
1546 old_fontlog_contents=d->sf->fontlog;
1547 if ( d->sf->fontlog==NULL )
1548 d->sf->fontlog = new;
1549 else {
1550 d->sf->fontlog = strconcat3(d->sf->fontlog,"\n\n",new);
1551 free(new);
1552 }
1553 d->sf->changed = true;
1554 }
1555 }
1556 if ( res!=-2 )
1557 err = _DoSave(d->sf,temp,sizes,res,d->map, wernersfdname, layer );
1558 if ( err && old_fontlog ) {
1559 free(d->sf->fontlog);
1560 d->sf->fontlog = old_fontlog_contents;
1561 } else
1562 free( old_fontlog_contents );
1563 free(wernersfdname);
1564 } else if ( d->family == gf_macfamily )
1565 err = !WriteMacFamily(temp,sfs,oldformatstate,oldbitmapstate,flags,layer);
1566 else {
1567 int ttcflags =
1568 (GGadgetIsChecked(GWidgetGetControl(d->gw,CID_MergeTables))?ttc_flag_trymerge:0) |
1569 (GGadgetIsChecked(GWidgetGetControl(d->gw,CID_TTC_CFF))?ttc_flag_cff:0);
1570 err = !WriteTTC(temp,sfs,oldformatstate,oldbitmapstate,flags,layer,ttcflags);
1571 }
1572
1573 if ( d->family && sfs!=NULL ) {
1574 for ( sfl=sfs; sfl!=NULL; sfl=sfl->next ) {
1575 RestoreUnlinkRmOvrlp(sfl->sf,temp,layer);
1576 if ( rename_to!=NULL && !iscid )
1577 SFTemporaryRestoreGlyphNames(sfl->sf,sfl->former_names);
1578 }
1579 } else {
1580 RestoreUnlinkRmOvrlp(d->sf,temp,layer);
1581 if ( rename_to!=NULL && !iscid )
1582 SFTemporaryRestoreGlyphNames(d->sf,former);
1583 }
1584 if ( !iscid )
1585 force_names_when_saving = rename_to;
1586
1587 free(temp);
1588 d->done = !err;
1589 d->ret = !err;
1590 }
1591
1592 static void _GFD_SaveOk(struct gfc_data *d) {
1593 GGadget *tf;
1594 unichar_t *ret;
1595 char *tmp;
1596 int formatstate = GGadgetGetFirstListSelectedItem(d->pstype);
1597 bool save = true;
1598
1599 GFileChooserGetChildren(d->gfc,NULL,NULL,&tf);
1600 if ( *_GGadgetGetTitle(tf)!='\0' ) {
1601 ret = GGadgetGetTitle(d->gfc);
1602 tmp = u2def_copy(ret);
1603 /* No point in bugging the user if we aren't doing anything */
1604 if (formatstate != ff_none && GFileExists(tmp)) {
1605 const char *rcb[3];
1606
1607 rcb[2]=NULL;
1608 rcb[0] = _("_Replace");
1609 rcb[1] = _("_Cancel");
1610
1611 save = gwwv_ask(_("File Exists"),rcb,0,1,_("File, %s, exists. Replace it?"),tmp) == 0;
1612 }
1613 if (save) {
1614 DoSave(d, ret);
1615 }
1616 free(ret);
1617 free(tmp);
1618 }
1619 }
1620
1621 static int GFD_SaveOk(GGadget *g, GEvent *e) {
1622 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1623 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1624 _GFD_SaveOk(d);
1625 }
1626 return( true );
1627 }
1628
1629 static int GFD_Cancel(GGadget *g, GEvent *e) {
1630 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1631 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1632 d->done = true;
1633 d->ret = false;
1634 }
1635 return( true );
1636 }
1637
1638 static void GFD_FigureWhich(struct gfc_data *d) {
1639 int fs = GGadgetGetFirstListSelectedItem(d->pstype);
1640 int bf = GGadgetGetFirstListSelectedItem(d->bmptype);
1641 int which;
1642 if ( fs==ff_none )
1643 which = 1; /* Some bitmaps get stuffed int ttf files */
1644 else if ( fs<=ff_cffcid )
1645 which = 0; /* PostScript options */
1646 else if ( fs<=ff_ttfdfont )
1647 which = 1; /* truetype options */ /* type42 also */
1648 else
1649 which = 2; /* opentype options */
1650
1651 if ( fs==ff_woff_ttf || fs==ff_woff2_ttf )
1652 which = 1; /* truetype */
1653 else if ( fs==ff_woff_otf || fs==ff_woff2_otf )
1654 which = 2; /* opentype */
1655
1656 if ( bf == bf_otb && which==0 )
1657 which = 3; /* postscript options with opentype bitmap options */
1658 d->sod_which = which;
1659 }
1660
1661 static int GFD_Options(GGadget *g, GEvent *e) {
1662 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1663 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1664 int fs = GGadgetGetFirstListSelectedItem(d->pstype);
1665 int iscid = fs==ff_cid || fs==ff_cffcid || fs==ff_otfcid ||
1666 fs==ff_otfciddfont || fs==ff_type42cid;
1667 GFD_FigureWhich(d);
1668 SaveOptionsDlg(d,d->sod_which,iscid);
1669 }
1670 return( true );
1671 }
1672
1673 static int GFD_NewDir(GGadget *g, GEvent *e) {
1674 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1675 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1676 char *newdir;
1677 unichar_t *temp = NULL;
1678 newdir = gwwv_ask_string(_("Create directory..."),NULL,_("Directory name?"));
1679 if ( newdir==NULL )
1680 return( true );
1681 if ( !GFileIsAbsolute(newdir)) {
1682 char *olddir = u2utf8_copy(GFileChooserGetDir(d->gfc));
1683 char *temp = GFileAppendFile(olddir,newdir,false);
1684 free(newdir); free(olddir);
1685 newdir = temp;
1686 }
1687 if (GFileMkDir(newdir, 0755)) {
1688 ff_post_notice(_("Couldn't create directory"),_("Couldn't create directory: %s"),
1689 newdir);
1690 } else {
1691 temp = utf82u_copy(newdir);
1692 GFileChooserSetDir(d->gfc, temp);
1693 }
1694 free(newdir); free(temp);
1695 }
1696 return( true );
1697 }
1698
1699 static void BitmapName(struct gfc_data *d) {
1700 int bf = GGadgetGetFirstListSelectedItem(d->bmptype);
1701 int format = GGadgetGetFirstListSelectedItem(d->pstype);
1702
1703 if ( bf<0 || format<0 || format!=ff_none )
1704 return;
1705
1706 unichar_t *ret = GGadgetGetTitle(d->gfc);
1707 unichar_t *dup, *pt, *tpt;
1708
1709 dup = malloc((u_strlen(ret)+30)*sizeof(unichar_t));
1710 u_strcpy(dup,ret);
1711 free(ret);
1712 pt = u_strrchr(dup,'.');
1713 tpt = u_strrchr(dup,'/');
1714 if ( pt<tpt )
1715 pt = NULL;
1716 if ( pt==NULL ) pt = dup+u_strlen(dup);
1717 if ( uc_strcmp(pt-5, ".bmap.bin" )==0 ) pt -= 5;
1718 if ( uc_strcmp(pt-4, ".ttf.bin" )==0 ) pt -= 4;
1719 if ( uc_strcmp(pt-4, ".otf.dfont" )==0 ) pt -= 4;
1720 if ( uc_strncmp(pt-2, "%s", 2 )==0 ) pt -= 2;
1721 if ( uc_strncmp(pt-2, "-*", 2 )==0 ) pt -= 2;
1722 uc_strcpy(pt,bitmapextensions[bf]);
1723 GGadgetSetTitle(d->gfc,dup);
1724 free(dup);
1725 }
1726
1727 static int GFD_Format(GGadget *g, GEvent *e) {
1728 if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
1729 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1730 unichar_t *pt, *dup, *tpt, *ret;
1731 int format = GGadgetGetFirstListSelectedItem(d->pstype);
1732 int32_t len; int bf;
1733 static unichar_t nullstr[] = { 0 };
1734 GTextInfo **list;
1735 SplineFont *temp;
1736
1737 list = GGadgetGetList(d->bmptype,&len);
1738 temp = d->sf->cidmaster ? d->sf->cidmaster : d->sf;
1739 if ( format==ff_none ) {
1740 if ( temp->bitmaps!=NULL ) {
1741 list[bf_sfnt_dfont]->disabled = false;
1742 list[bf_sfnt_ms]->disabled = false;
1743 list[bf_otb]->disabled = false;
1744 list[bf_ttf]->disabled = true;
1745 }
1746 BitmapName(d);
1747 return( true );
1748 }
1749
1750 ret = GGadgetGetTitle(d->gfc);
1751 dup = malloc((u_strlen(ret)+30)*sizeof(unichar_t));
1752 u_strcpy(dup,ret);
1753 free(ret);
1754 pt = u_strrchr(dup,'.');
1755 tpt = u_strrchr(dup,'/');
1756 if ( pt<tpt )
1757 pt = NULL;
1758 if ( pt==NULL ) pt = dup+u_strlen(dup);
1759 if ( uc_strcmp(pt-5, ".bmap.bin" )==0 ) pt -= 5;
1760 if ( uc_strcmp(pt-4, ".ttf.bin" )==0 ) pt -= 4;
1761 if ( uc_strcmp(pt-4, ".otf.dfont" )==0 ) pt -= 4;
1762 if ( uc_strcmp(pt-4, ".cid.t42" )==0 ) pt -= 4;
1763 if ( uc_strncmp(pt-2, "%s", 2 )==0 ) pt -= 2;
1764 if ( uc_strncmp(pt-2, "-*", 2 )==0 ) pt -= 2;
1765 uc_strcpy(pt,savefont_extensions[format]);
1766 GGadgetSetTitle(d->gfc,dup);
1767 free(dup);
1768
1769 if ( d->sf->cidmaster!=NULL ) {
1770 if ( format!=ff_none && format != ff_cid && format != ff_cffcid &&
1771 format != ff_otfcid && format!=ff_otfciddfont ) {
1772 GGadgetSetTitle(d->bmpsizes,nullstr);
1773 }
1774 }
1775
1776 bf = GGadgetGetFirstListSelectedItem(d->bmptype);
1777 list[bf_sfnt_dfont]->disabled = true;
1778 if ( temp->bitmaps==NULL )
1779 /* Don't worry about what formats are possible, they're disabled */;
1780 else if ( format!=ff_ttf && format!=ff_ttfsym && format!=ff_otf &&
1781 format!=ff_ttfdfont && format!=ff_otfdfont && format!=ff_otfciddfont &&
1782 format!=ff_otfcid && format!=ff_ttfmacbin && format!=ff_none ) {
1783 /* If we're not in a ttf format then we can't output ttf bitmaps */
1784 list[bf_ttf]->disabled = true;
1785 list[bf_sfnt_dfont]->disabled = false;
1786 list[bf_sfnt_ms]->disabled = false;
1787 list[bf_otb]->disabled = false;
1788 if ( bf==bf_ttf )
1789 GGadgetSelectOneListItem(d->bmptype,bf_otb);
1790 if ( format==ff_pfbmacbin )
1791 GGadgetSelectOneListItem(d->bmptype,bf_nfntmacbin);
1792 bf = GGadgetGetFirstListSelectedItem(d->bmptype);
1793 GGadgetSetEnabled(d->bmpsizes, format!=ff_multiple && bf!=bf_none ); /* We know there are bitmaps */
1794 } else {
1795 list[bf_ttf]->disabled = false;
1796 list[bf_sfnt_dfont]->disabled = true;
1797 list[bf_sfnt_ms]->disabled = true;
1798 list[bf_otb]->disabled = true;
1799 if ( bf==bf_none )
1800 /* Do nothing, always appropriate */;
1801 else if ( format==ff_ttf || format==ff_ttfsym || format==ff_otf ||
1802 format==ff_otfcid ||
1803 bf==bf_sfnt_dfont || bf == bf_sfnt_ms || bf == bf_otb )
1804 GGadgetSelectOneListItem(d->bmptype,bf_ttf);
1805 }
1806 #if __Mac
1807 { GGadget *pulldown, *list, *tf;
1808 /* The name of the postscript file is fixed and depends solely on */
1809 /* the font name. If the user tried to change it, the font would */
1810 /* not be found */
1811 /* See MakeMacPSName for a full description */
1812 GFileChooserGetChildren(d->gfc,&pulldown,&list,&tf);
1813 GGadgetSetVisible(tf,format!=ff_pfbmacbin);
1814 }
1815 #endif
1816 GGadgetSetEnabled(d->bmptype, format!=ff_multiple );
1817 }
1818 return( true );
1819 }
1820
1821 static int GFD_BitmapFormat(GGadget *g, GEvent *e) {
1822 if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
1823 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1824 /*int format = GGadgetGetFirstListSelectedItem(d->pstype);*/
1825 int bf = GGadgetGetFirstListSelectedItem(d->bmptype);
1826 int i;
1827
1828 GGadgetSetEnabled(d->bmpsizes,bf!=bf_none);
1829 if ( d->family ) {
1830 for ( i=0; i<d->familycnt; ++i )
1831 GGadgetSetEnabled(GWidgetGetControl(d->gw,CID_Family+10*i+1),
1832 bf!=bf_none);
1833 }
1834 BitmapName(d);
1835 }
1836 return( true );
1837 }
1838
1839 static int GFD_TogglePrependTimestamp(GGadget *g, GEvent *e) {
1840 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
1841 will_prepend_timestamp = GGadgetIsChecked(g);
1842 }
1843 return( true );
1844 }
1845
1846 static int GFD_ToggleFontLog(GGadget *g, GEvent *e) {
1847 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
1848 struct gfc_data *d = GDrawGetUserData(GGadgetGetWindow(g));
1849 static int cids[] = {
1850 CID_FontLogBit,
1851 0 };
1852 int i, visible = GGadgetIsChecked(g);
1853
1854 for ( i=0; cids[i]!=0; ++i )
1855 GGadgetSetVisible(GWidgetGetControl(d->gw,cids[i]),visible);
1856
1857 GWidgetToDesiredSize(d->gw);
1858 }
1859 return( true );
1860 }
1861
1862 static int e_h(GWindow gw, GEvent *event) {
1863 if ( event->type==et_close ) {
1864 struct gfc_data *d = GDrawGetUserData(gw);
1865 d->done = true;
1866 d->ret = false;
1867 } else if ( event->type == et_char ) {
1868 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
1869 help("ui/dialogs/generate.html", NULL);
1870 return( true );
1871 } else if ( (event->u.chr.keysym=='s' || event->u.chr.keysym=='g' ||
1872 event->u.chr.keysym=='G' ) &&
1873 (event->u.chr.state&ksm_control) ) {
1874 _GFD_SaveOk(GDrawGetUserData(gw));
1875 return( true );
1876 }
1877 return( false );
1878 } else if ( event->type == et_mousemove ||
1879 (event->type==et_mousedown && event->u.mouse.button==3 )) {
1880 struct gfc_data *d = GDrawGetUserData(gw);
1881 if ( !GGadgetWithin(d->gfc,event->u.mouse.x,event->u.mouse.y))
1882 return( false );
1883 GFileChooserPopupCheck(d->gfc,event);
1884 } else if (( event->type==et_mouseup || event->type==et_mousedown ) &&
1885 (event->u.mouse.button>=4 && event->u.mouse.button<=7) ) {
1886 struct gfc_data *d = GDrawGetUserData(gw);
1887 return( GGadgetDispatchEvent((GGadget *) (d->gfc),event));
1888 }
1889 return( true );
1890 }
1891
1892 static unichar_t *BitmapList(SplineFont *sf) {
1893 BDFFont *bdf;
1894 int i;
1895 char *cret, *pt;
1896 unichar_t *uret;
1897
1898 for ( bdf=sf->bitmaps, i=0; bdf!=NULL; bdf=bdf->next, ++i );
1899 pt = cret = malloc((i+1)*20);
1900 for ( bdf=sf->bitmaps; bdf!=NULL; bdf=bdf->next ) {
1901 if ( pt!=cret ) *pt++ = ',';
1902 if ( bdf->clut==NULL )
1903 sprintf( pt, "%d", bdf->pixelsize );
1904 else
1905 sprintf( pt, "%d@%d", bdf->pixelsize, BDFDepth(bdf) );
1906 pt += strlen(pt);
1907 }
1908 *pt = '\0';
1909 uret = uc_copy(cret);
1910 free(cret);
1911 return( uret );
1912 }
1913
1914 static const char *styleName(SplineFont *sf) {
1915 int stylecode = MacStyleCode(sf,NULL);
1916
1917 if ( stylecode&sf_bold )
1918 return " Bold";
1919 if ( stylecode&sf_italic )
1920 return " Italic";
1921 if ( stylecode&sf_outline )
1922 return " Outline";
1923 if ( stylecode&sf_shadow )
1924 return " Shadow";
1925 if ( stylecode&sf_condense )
1926 return " Condensed";
1927 if ( stylecode&sf_extend )
1928 return " Extended";
1929 return " Plain";
1930 }
1931
1932 static GTextInfo *SFUsableLayerNames(SplineFont *sf,int def_layer) {
1933 int gid, layer, cnt = 1, k, known;
1934 SplineFont *_sf;
1935 SplineChar *sc;
1936 GTextInfo *ti;
1937
1938 for ( layer=0; layer<sf->layer_cnt; ++layer )
1939 sf->layers[layer].ticked = false;
1940 sf->layers[ly_fore].ticked = true;
1941 for ( layer=0; layer<sf->layer_cnt; ++layer ) if ( !sf->layers[layer].background ) {
1942 known = -1;
1943 k = 0;
1944 do {
1945 _sf = sf->subfontcnt==0 ? sf : sf->subfonts[k];
1946 for ( gid = 0; gid<_sf->glyphcnt; ++gid ) if ( (sc=_sf->glyphs[gid])!=NULL ) {
1947 if ( sc->layers[layer].images!=NULL ) {
1948 known = 0;
1949 break;
1950 }
1951 if ( sc->layers[layer].splines!=NULL )
1952 known = 1;
1953 }
1954 ++k;
1955 } while ( known!=0 && k<sf->subfontcnt );
1956 if ( known == 1 ) {
1957 sf->layers[layer].ticked = true;
1958 ++cnt;
1959 } else if ( layer==def_layer )
1960 def_layer = ly_fore;
1961 }
1962
1963 ti = calloc(cnt+1,sizeof(GTextInfo));
1964 cnt=0;
1965 for ( layer=0; layer<sf->layer_cnt; ++layer ) if ( sf->layers[layer].ticked ) {
1966 ti[cnt].text = (unichar_t *) sf->layers[layer].name;
1967 ti[cnt].text_is_1byte = true;
1968 ti[cnt].selected = layer==def_layer;
1969 ti[cnt++].userdata = (void *) (intptr_t) layer;
1970 }
1971 return( ti );
1972 }
1973
1974 typedef SplineFont *SFArray[48];
1975
1976 int SFGenerateFont(SplineFont *sf,int layer,int family,EncMap *map) {
1977 GRect pos;
1978 GWindow gw;
1979 GWindowAttrs wattrs;
1980 GGadgetCreateData gcd[20+2*48+5+1], *varray[13], *hvarray[33], *famarray[3*52+1],
1981 *harray[10], boxes[7];
1982 GTextInfo label[20+2*48+4+1];
1983 struct gfc_data d;
1984 GGadget *pulldown, *files, *tf;
1985 int hvi, i, j, k, f, old, ofs, y, fc, dupfc, dupstyle, rk, vk;
1986 int bs = GIntGetResource(_NUM_Buttonsize), bsbigger, totwid, spacing;
1987 SplineFont *temp;
1988 int familycnt=0;
1989 int fondcnt = 0, fondmax = 10;
1990 SFArray *familysfs=NULL;
1991 uint16_t psstyle;
1992 static int done=false;
1993 extern NameList *force_names_when_saving;
1994 char **nlnames;
1995 int cnt, any;
1996 GTextInfo *namelistnames, *lynames=NULL;
1997
1998 memset(&d,'\0',sizeof(d));
1999 d.sf = sf;
2000 d.layer = layer;
2001
2002 if ( !done ) {
2003 done = true;
2004 for ( i=0; formattypes[i].text; ++i )
2005 formattypes[i].text = (unichar_t *) _((char *) formattypes[i].text);
2006 for ( i=0; bitmaptypes[i].text; ++i )
2007 bitmaptypes[i].text = (unichar_t *) _((char *) bitmaptypes[i].text);
2008 }
2009
2010 if ( family ) {
2011 /* I could just disable the menu item, but I think it's a bit confusing*/
2012 /* and I want people to know why they can't generate a family */
2013 FontView *fv;
2014 SplineFont *dup=NULL/*, *badenc=NULL*/;
2015 familysfs = malloc((fondmax=10)*sizeof(SFArray));
2016 memset(familysfs[0],0,sizeof(familysfs[0]));
2017 familysfs[0][0] = sf;
2018 fondcnt = 1;
2019 for ( fv=fv_list; fv!=NULL; fv=(FontView *) (fv->b.next) ) {
2020 if ( fv->b.sf==sf )
2021 continue;
2022 if ( family==gf_ttc ) {
2023 fc = fondcnt;
2024 psstyle = 0;
2025 } else if ( family==gf_macfamily && sf->familyname && fv->b.sf->familyname && strcmp(fv->b.sf->familyname,sf->familyname)==0 ) {
2026 MacStyleCode(fv->b.sf,&psstyle);
2027 if ( fv->b.sf->fondname==NULL ) {
2028 fc = 0;
2029 if ( familysfs[0][0]->fondname==NULL &&
2030 (familysfs[0][psstyle]==NULL || familysfs[0][psstyle]==fv->b.sf))
2031 familysfs[0][psstyle] = fv->b.sf;
2032 else {
2033 for ( fc=0; fc<fondcnt; ++fc ) {
2034 for ( i=0; i<48; ++i )
2035 if ( familysfs[fc][i]!=NULL )
2036 break;
2037 if ( i<48 && familysfs[fc][i]->fondname==NULL &&
2038 familysfs[fc][psstyle]==fv->b.sf )
2039 break;
2040 }
2041 }
2042 } else {
2043 for ( fc=0; fc<fondcnt; ++fc ) {
2044 for ( i=0; i<48; ++i )
2045 if ( familysfs[fc][i]!=NULL )
2046 break;
2047 if ( i<48 && familysfs[fc][i]->fondname!=NULL &&
2048 strcmp(familysfs[fc][i]->fondname,fv->b.sf->fondname)==0 ) {
2049 if ( familysfs[fc][psstyle]==fv->b.sf )
2050 /* several windows may point to same font */;
2051 else if ( familysfs[fc][psstyle]!=NULL ) {
2052 dup = fv->b.sf;
2053 dupstyle = psstyle;
2054 dupfc = fc;
2055 } else
2056 familysfs[fc][psstyle] = fv->b.sf;
2057 break;
2058 }
2059 }
2060 }
2061 }
2062 if ( fc==fondcnt ) {
2063 /* Create a new fond containing just this font */
2064 if ( fondcnt>=fondmax )
2065 familysfs = realloc(familysfs,(fondmax+=10)*sizeof(SFArray));
2066 memset(familysfs[fondcnt],0,sizeof(SFArray));
2067 familysfs[fondcnt++][psstyle] = fv->b.sf;
2068 }
2069 }
2070 if ( family==gf_macfamily ) {
2071 for ( fc=0; fc<fondcnt; ++fc ) for ( i=0; i<48; ++i ) {
2072 if ( familysfs[fc][i]!=NULL ) {
2073 ++familycnt;
2074 }
2075 }
2076 if ( MacStyleCode(sf,NULL)!=0 || familycnt<=1 || sf->multilayer ) {
2077 ff_post_error(_("Bad Mac Family"),_("To generate a Mac family file, the current font must have plain (Normal, Regular, etc.) style, and there must be other open fonts with the same family name."));
2078 return( 0 );
2079 } else if ( dup ) {
2080 MacStyleCode(dup,&psstyle);
2081 ff_post_error(_("Bad Mac Family"),_("There are two open fonts with the current family name and the same style. %.30s and %.30s"),
2082 dup->fontname, familysfs[dupfc][dupstyle]->fontname);
2083 return( 0 );
2084 }
2085 } else {
2086 familycnt = fondcnt;
2087 }
2088 }
2089
2090 memset(&wattrs,0,sizeof(wattrs));
2091 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
2092 wattrs.event_masks = ~(1<<et_charup);
2093 wattrs.is_dlg = true;
2094 wattrs.restrict_input_to_me = 1;
2095 wattrs.undercursor = 1;
2096 wattrs.cursor = ct_pointer;
2097 {
2098 const char *label = _("Generate Fonts");
2099 switch (family) {
2100 case gf_ttc:
2101 label = _("Generate TTC");
2102 break;
2103 case gf_macfamily:
2104 label = _("Generate Mac Family");
2105 break;
2106 }
2107 wattrs.utf8_window_title = label;
2108 }
2109 pos.x = pos.y = 0;
2110 totwid = GGadgetScale(295);
2111 bsbigger = 4*bs+4*14>totwid; totwid = bsbigger?4*bs+4*12:totwid;
2112 spacing = (totwid-4*bs-2*12)/3;
2113 pos.width = GDrawPointsToPixels(NULL,totwid);
2114 if ( family )
2115 pos.height = GDrawPointsToPixels(NULL,310+13+26*(familycnt-1));
2116 else
2117 pos.height = GDrawPointsToPixels(NULL,310);
2118 gw = GDrawCreateTopWindow(NULL,&pos,e_h,&d,&wattrs);
2119
2120 memset(&label,0,sizeof(label));
2121 memset(&gcd,0,sizeof(gcd));
2122 memset(&boxes,0,sizeof(boxes));
2123 gcd[0].gd.pos.x = 12; gcd[0].gd.pos.y = 6; gcd[0].gd.pos.width = 100*totwid/GIntGetResource(_NUM_ScaleFactor)-24; gcd[0].gd.pos.height = 182;
2124 gcd[0].gd.flags = gg_visible | gg_enabled;
2125 gcd[0].creator = GFileChooserCreate;
2126 varray[0] = &gcd[0]; varray[1] = NULL;
2127
2128 y = 276;
2129 if ( family )
2130 y += 13 + 26*(familycnt-1);
2131
2132 gcd[1].gd.pos.x = 12; gcd[1].gd.pos.y = y-3;
2133 gcd[1].gd.pos.width = -1;
2134 gcd[1].gd.flags = gg_visible | gg_enabled | gg_but_default;
2135 label[1].text = (unichar_t *) _("_Generate");
2136 label[1].text_is_1byte = true;
2137 label[1].text_in_resource = true;
2138 gcd[1].gd.mnemonic = 'S';
2139 gcd[1].gd.label = &label[1];
2140 gcd[1].gd.handle_controlevent = GFD_SaveOk;
2141 gcd[1].creator = GButtonCreate;
2142 harray[0] = GCD_Glue; harray[1] = &gcd[1];
2143
2144 gcd[2].gd.pos.x = -(spacing+bs)*100/GIntGetResource(_NUM_ScaleFactor)-12; gcd[2].gd.pos.y = y;
2145 gcd[2].gd.pos.width = -1;
2146 gcd[2].gd.flags = gg_visible | gg_enabled;
2147 label[2].text = (unichar_t *) _("_Filter");
2148 label[2].text_is_1byte = true;
2149 label[2].text_in_resource = true;
2150 gcd[2].gd.mnemonic = 'F';
2151 gcd[2].gd.label = &label[2];
2152 gcd[2].gd.handle_controlevent = GFileChooserFilterEh;
2153 gcd[2].creator = GButtonCreate;
2154 harray[2] = GCD_Glue; harray[3] = &gcd[2];
2155
2156 gcd[3].gd.pos.x = -12; gcd[3].gd.pos.y = y; gcd[3].gd.pos.width = -1; gcd[3].gd.pos.height = 0;
2157 gcd[3].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
2158 label[3].text = (unichar_t *) _("_Cancel");
2159 label[3].text_is_1byte = true;
2160 label[3].text_in_resource = true;
2161 gcd[3].gd.label = &label[3];
2162 gcd[3].gd.mnemonic = 'C';
2163 gcd[3].gd.handle_controlevent = GFD_Cancel;
2164 gcd[3].creator = GButtonCreate;
2165 harray[6] = GCD_Glue; harray[7] = &gcd[3]; harray[8] = GCD_Glue; harray[9] = NULL;
2166
2167 gcd[4].gd.pos.x = (spacing+bs)*100/GIntGetResource(_NUM_ScaleFactor)+12; gcd[4].gd.pos.y = y; gcd[4].gd.pos.width = -1; gcd[4].gd.pos.height = 0;
2168 gcd[4].gd.flags = gg_visible | gg_enabled;
2169 label[4].text = (unichar_t *) S_("Directory|_New");
2170 label[4].text_is_1byte = true;
2171 label[4].text_in_resource = true;
2172 label[4].image = &_GIcon_dir;
2173 label[4].image_precedes = false;
2174 gcd[4].gd.mnemonic = 'N';
2175 gcd[4].gd.label = &label[4];
2176 gcd[4].gd.handle_controlevent = GFD_NewDir;
2177 gcd[4].creator = GButtonCreate;
2178 harray[4] = GCD_Glue; harray[5] = &gcd[4];
2179
2180 boxes[2].gd.flags = gg_enabled|gg_visible;
2181 boxes[2].gd.u.boxelements = harray;
2182 boxes[2].creator = GHBoxCreate;
2183
2184 gcd[5].gd.pos.x = 12; gcd[5].gd.pos.y = 218; gcd[5].gd.pos.width = 0; gcd[5].gd.pos.height = 0;
2185 gcd[5].gd.flags = gg_visible | gg_enabled;
2186 label[5].text = (unichar_t *) _("Options");
2187 label[5].text_is_1byte = true;
2188 gcd[5].gd.popup_msg = _("Allows you to select optional behavior when generating the font");
2189 gcd[5].gd.label = &label[5];
2190 gcd[5].gd.handle_controlevent = GFD_Options;
2191 gcd[5].creator = GButtonCreate;
2192 hvarray[4] = &gcd[5]; hvarray[5] = GCD_Glue;
2193
2194 gcd[6].gd.pos.x = 12; gcd[6].gd.pos.y = 190; gcd[6].gd.pos.width = 0; gcd[6].gd.pos.height = 0;
2195 gcd[6].gd.flags = gg_visible | gg_enabled ;
2196 gcd[6].gd.u.list = formattypes;
2197 gcd[6].creator = GListButtonCreate;
2198 hvarray[0] = &gcd[6]; hvarray[1] = GCD_ColSpan;
2199
2200 any = false;
2201 for ( i=0; i<sf->glyphcnt; ++i ) if ( SCWorthOutputting(sf->glyphs[i])) {
2202 any = true;
2203 break;
2204 }
2205 for ( i=0; i<sizeof(formattypes)/sizeof(formattypes[0])-1; ++i )
2206 formattypes[i].disabled = !any;
2207 formattypes[ff_ptype0].disabled = sf->onlybitmaps || map->enc->only_1byte;
2208 formattypes[ff_mma].disabled = formattypes[ff_mmb].disabled =
2209 sf->mm==NULL || sf->mm->apple || !MMValid(sf->mm,false);
2210 formattypes[ff_cffcid].disabled = sf->cidmaster==NULL;
2211 formattypes[ff_cid].disabled = sf->cidmaster==NULL;
2212 formattypes[ff_otfcid].disabled = sf->cidmaster==NULL;
2213 formattypes[ff_otfciddfont].disabled = sf->cidmaster==NULL;
2214 if ( map->enc->is_unicodefull )
2215 formattypes[ff_type42cid].disabled = true; /* Identity CMap only handles BMP */
2216 ofs = oldformatstate;
2217 if (( ofs==ff_ptype0 && formattypes[ff_ptype0].disabled ) ||
2218 ((ofs==ff_mma || ofs==ff_mmb) && sf->mm==NULL) ||
2219 ((ofs==ff_cid || ofs==ff_cffcid || ofs==ff_otfcid || ofs==ff_otfciddfont) && formattypes[ff_cid].disabled))
2220 ofs = ff_pfb;
2221 else if ( (ofs!=ff_cid && ofs!=ff_cffcid && ofs!=ff_otfcid && ofs!=ff_otfciddfont) && sf->cidmaster!=NULL )
2222 ofs = ff_otfcid;
2223 else if ( !formattypes[ff_mmb].disabled && ofs!=ff_mma )
2224 ofs = ff_mmb;
2225 if ( ofs==ff_ttc )
2226 ofs = ff_ttf;
2227 if ( sf->onlybitmaps )
2228 ofs = ff_none;
2229 if ( sf->multilayer ) {
2230 formattypes[ff_pfa].disabled = true;
2231 formattypes[ff_pfb].disabled = true;
2232 formattypes[ff_pfbmacbin].disabled = true;
2233 formattypes[ff_mma].disabled = true;
2234 formattypes[ff_mmb].disabled = true;
2235 formattypes[ff_multiple].disabled = true;
2236 formattypes[ff_ptype0].disabled = true;
2237 formattypes[ff_cff].disabled = true;
2238 formattypes[ff_cffcid].disabled = true;
2239 formattypes[ff_cid].disabled = true;
2240 formattypes[ff_ttf].disabled = true;
2241 formattypes[ff_type42].disabled = true;
2242 formattypes[ff_type42cid].disabled = true;
2243 formattypes[ff_ttfsym].disabled = true;
2244 formattypes[ff_ttfmacbin].disabled = true;
2245 formattypes[ff_ttfdfont].disabled = true;
2246 formattypes[ff_otfdfont].disabled = true;
2247 formattypes[ff_otf].disabled = true;
2248 formattypes[ff_otfcid].disabled = true;
2249 formattypes[ff_cffcid].disabled = true;
2250 formattypes[ff_ufo].disabled = true;
2251 formattypes[ff_ufo2].disabled = true;
2252 formattypes[ff_ufo3].disabled = true;
2253 if ( ofs!=ff_svg )
2254 ofs = ff_ptype3;
2255 } else if ( sf->strokedfont ) {
2256 formattypes[ff_ttf].disabled = true;
2257 formattypes[ff_ttfsym].disabled = true;
2258 formattypes[ff_ttfmacbin].disabled = true;
2259 formattypes[ff_ttfdfont].disabled = true;
2260 formattypes[ff_ufo].disabled = true;
2261 formattypes[ff_ufo2].disabled = true;
2262 formattypes[ff_ufo3].disabled = true;
2263 if ( ofs==ff_ttf || ofs==ff_ttfsym || ofs==ff_ttfmacbin || ofs==ff_ttfdfont )
2264 ofs = ff_otf;
2265 }
2266 formattypes[ff_ttc].disabled = true;
2267 if ( family == gf_macfamily ) {
2268 if ( ofs==ff_pfa || ofs==ff_pfb || ofs==ff_multiple || ofs==ff_ptype3 ||
2269 ofs==ff_ptype0 || ofs==ff_mma || ofs==ff_mmb )
2270 ofs = ff_pfbmacbin;
2271 else if ( ofs==ff_cid || ofs==ff_otfcid || ofs==ff_cffcid )
2272 ofs = ff_otfciddfont;
2273 else if ( ofs==ff_ttf || ofs==ff_ttfsym )
2274 ofs = ff_ttfmacbin;
2275 else if ( ofs==ff_otf || ofs==ff_cff )
2276 ofs = ff_otfdfont;
2277 else if ( ofs==ff_ufo || ofs==ff_ufo2 || ofs==ff_ufo3 || ofs==ff_ttc )
2278 ofs = ff_ttfdfont;
2279 formattypes[ff_pfa].disabled = true;
2280 formattypes[ff_pfb].disabled = true;
2281 formattypes[ff_mma].disabled = true;
2282 formattypes[ff_mmb].disabled = true;
2283 formattypes[ff_multiple].disabled = true;
2284 formattypes[ff_ptype3].disabled = true;
2285 formattypes[ff_ptype0].disabled = true;
2286 formattypes[ff_type42].disabled = true;
2287 formattypes[ff_type42cid].disabled = true;
2288 formattypes[ff_ttf].disabled = true;
2289 formattypes[ff_ttfsym].disabled = true;
2290 formattypes[ff_otf].disabled = true;
2291 formattypes[ff_otfcid].disabled = true;
2292 formattypes[ff_cff].disabled = true;
2293 formattypes[ff_cffcid].disabled = true;
2294 formattypes[ff_svg].disabled = true;
2295 formattypes[ff_ufo].disabled = true;
2296 formattypes[ff_ufo2].disabled = true;
2297 formattypes[ff_ufo3].disabled = true;
2298 } else if ( family == gf_ttc ) {
2299 for ( i=0; i<=ff_none; ++i )
2300 formattypes[i].disabled = true;
2301 formattypes[ff_ttc].disabled = false;
2302 ofs = ff_ttc;
2303 }
2304 #ifndef FONTFORGE_CAN_USE_WOFF2
2305 formattypes[ff_woff2_ttf].disabled = true;
2306 formattypes[ff_woff2_otf].disabled = true;
2307 #endif
2308
2309 for ( i=0; i<sizeof(formattypes)/sizeof(formattypes[0]); ++i )
2310 formattypes[i].selected = false;
2311 formattypes[ofs].selected = true;
2312 gcd[6].gd.handle_controlevent = GFD_Format;
2313 gcd[6].gd.label = &formattypes[ofs];
2314
2315 gcd[7].gd.pos.x = 2; gcd[7].gd.pos.y = 2;
2316 gcd[7].gd.pos.width = pos.width-4; gcd[7].gd.pos.height = pos.height-4;
2317 gcd[7].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels;
2318 gcd[7].creator = GGroupCreate;
2319
2320 gcd[8].gd.pos.x = 155; gcd[8].gd.pos.y = 190; gcd[8].gd.pos.width = 126;
2321 gcd[8].gd.flags = gg_visible | gg_enabled;
2322 gcd[8].gd.u.list = bitmaptypes;
2323 gcd[8].creator = GListButtonCreate;
2324 for ( i=0; i<sizeof(bitmaptypes)/sizeof(bitmaptypes[0]); ++i ) {
2325 bitmaptypes[i].selected = false;
2326 bitmaptypes[i].disabled = false;
2327 }
2328 hvarray[2] = &gcd[8]; hvarray[3] = NULL;
2329 old = oldbitmapstate;
2330 if ( family==gf_macfamily ) {
2331 if ( old==bf_bdf || old==bf_fon || old==bf_fnt || old==bf_sfnt_ms ||
2332 old==bf_otb || old==bf_palm || old==bf_ptype3 ) {
2333 if ( ofs==ff_otfdfont || ofs==ff_otfciddfont || ofs==ff_ttfdfont )
2334 old = bf_ttf;
2335 else
2336 old = bf_sfnt_dfont;
2337 } else if ( old==bf_nfntmacbin &&
2338 ( ofs==ff_otfdfont || ofs==ff_otfciddfont || ofs==ff_ttfdfont ))
2339 old = bf_ttf;
2340 bitmaptypes[bf_bdf].disabled = true;
2341 bitmaptypes[bf_fon].disabled = true;
2342 bitmaptypes[bf_fnt].disabled = true;
2343 } else if ( family==gf_ttc ) {
2344 for ( i=0; i<bf_none; ++i )
2345 bitmaptypes[i].disabled = true;
2346 bitmaptypes[bf_ttf].disabled = false;
2347 if ( old!=bf_none )
2348 old = bf_ttf;
2349 }
2350 temp = sf->cidmaster ? sf->cidmaster : sf;
2351 if ( temp->bitmaps==NULL ) {
2352 old = bf_none;
2353 bitmaptypes[bf_bdf].disabled = true;
2354 bitmaptypes[bf_ttf].disabled = true;
2355 bitmaptypes[bf_sfnt_dfont].disabled = true;
2356 bitmaptypes[bf_sfnt_ms].disabled = true;
2357 bitmaptypes[bf_otb].disabled = true;
2358 bitmaptypes[bf_nfntmacbin].disabled = true;
2359 bitmaptypes[bf_fon].disabled = true;
2360 bitmaptypes[bf_fnt].disabled = true;
2361 bitmaptypes[bf_palm].disabled = true;
2362 bitmaptypes[bf_ptype3].disabled = true;
2363 } else if ( ofs==ff_ttf || ofs==ff_ttfsym || ofs==ff_ttfmacbin ||
2364 ofs==ff_ttfdfont || ofs==ff_otf || ofs==ff_otfdfont || ofs==ff_otfcid ||
2365 ofs==ff_otfciddfont ) {
2366 bitmaptypes[bf_ttf].disabled = false;
2367 bitmaptypes[bf_sfnt_dfont].disabled = true;
2368 bitmaptypes[bf_sfnt_ms].disabled = true;
2369 bitmaptypes[bf_otb].disabled = true;
2370 } else {
2371 bitmaptypes[bf_ttf].disabled = true;
2372 bitmaptypes[bf_sfnt_dfont].disabled = false;
2373 bitmaptypes[bf_sfnt_ms].disabled = false;
2374 bitmaptypes[bf_otb].disabled = false;
2375 }
2376 bitmaptypes[old].selected = true;
2377 gcd[8].gd.label = &bitmaptypes[old];
2378 gcd[8].gd.handle_controlevent = GFD_BitmapFormat;
2379
2380 gcd[9].gd.pos.x = gcd[8].gd.pos.x; gcd[9].gd.pos.y = 219; gcd[9].gd.pos.width = gcd[8].gd.pos.width;
2381 gcd[9].gd.flags = gg_visible | gg_enabled;
2382 if ( old==bf_none )
2383 gcd[9].gd.flags &= ~gg_enabled;
2384 gcd[9].creator = GTextFieldCreate;
2385 label[9].text = BitmapList(temp);
2386 gcd[9].gd.label = &label[9];
2387 hvarray[6] = &gcd[9]; hvarray[7] = NULL;
2388
2389 k = 10;
2390 label[k].text = (unichar_t *) _("Force glyph names to:");
2391 label[k].text_is_1byte = true;
2392 gcd[k].gd.label = &label[k];
2393 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24+6;
2394 gcd[k].gd.flags = gg_enabled | gg_visible;
2395 gcd[k].gd.popup_msg = _("In the saved font, force all glyph names to match those in the specified namelist");
2396 gcd[k++].creator = GLabelCreate;
2397 hvarray[8] = &gcd[k-1]; hvarray[9] = GCD_ColSpan;
2398
2399 rk = k;
2400 gcd[k].gd.pos.x = gcd[k-2].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6;
2401 gcd[k].gd.pos.width = gcd[k-2].gd.pos.width;
2402 gcd[k].gd.flags = gg_visible | gg_enabled;
2403 gcd[k].gd.popup_msg = _("In the saved font, force all glyph names to match those in the specified namelist");
2404 gcd[k].creator = GListButtonCreate;
2405 nlnames = AllNamelistNames();
2406 for ( cnt=0; nlnames[cnt]!=NULL; ++cnt);
2407 namelistnames = calloc(cnt+3,sizeof(GTextInfo));
2408 namelistnames[0].text = (unichar_t *) _("No Rename");
2409 namelistnames[0].text_is_1byte = true;
2410 if ( force_names_when_saving==NULL ) {
2411 namelistnames[0].selected = true;
2412 gcd[k].gd.label = &namelistnames[0];
2413 }
2414 namelistnames[1].line = true;
2415 for ( cnt=0; nlnames[cnt]!=NULL; ++cnt) {
2416 namelistnames[cnt+2].text = (unichar_t *) nlnames[cnt];
2417 namelistnames[cnt+2].text_is_1byte = true;
2418 if ( force_names_when_saving!=NULL &&
2419 strcmp(_(force_names_when_saving->title),nlnames[cnt])==0 ) {
2420 namelistnames[cnt+2].selected = true;
2421 gcd[k].gd.label = &namelistnames[cnt+2];
2422 }
2423 }
2424 gcd[k++].gd.u.list = namelistnames;
2425 free(nlnames);
2426 hvarray[10] = &gcd[k-1]; hvarray[11] = NULL;
2427
2428 if ( !family ) {
2429 /* Too annoying to check if all fonts in a family have the same set of*/
2430 /* useful layers. So only do this if not family */
2431 label[k].text = (unichar_t *) _("Layer:");
2432 label[k].text_is_1byte = true;
2433 gcd[k].gd.label = &label[k];
2434 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24+6;
2435 gcd[k].gd.flags = gg_enabled | gg_visible;
2436 gcd[k].gd.popup_msg = _("In the saved font, force all glyph names to match those in the specified namelist");
2437 gcd[k++].creator = GLabelCreate;
2438
2439 gcd[k].gd.pos.x = gcd[k-2].gd.pos.x; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y-6;
2440 gcd[k].gd.pos.width = gcd[k-2].gd.pos.width;
2441 gcd[k].gd.flags = gg_visible | gg_enabled;
2442 gcd[k].gd.popup_msg = _("Save a font based on the specified layer");
2443 gcd[k].creator = GListButtonCreate;
2444 gcd[k].gd.cid = CID_Layers;
2445 gcd[k++].gd.u.list = lynames = SFUsableLayerNames(sf,layer);
2446 if ( lynames[1].text==NULL ) {
2447 gcd[k-2].gd.flags &= ~gg_visible;
2448 gcd[k-1].gd.flags &= ~gg_visible;
2449 }
2450 hvi=12;
2451 hvarray[hvi++] = &gcd[k-2]; hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = &gcd[k-1];
2452 hvarray[hvi++] = NULL;
2453
2454 /* Too time consuming to validate lots of fonts, and what UI would I use? */
2455 /* so only do this if not family */
2456 vk = k;
2457 label[k].text = (unichar_t *) _("Validate Before Saving");
2458 label[k].text_is_1byte = true;
2459 gcd[k].gd.label = &label[k];
2460 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24+6;
2461 if ( sf->multilayer || sf->strokedfont || sf->onlybitmaps )
2462 gcd[k].gd.flags = gg_visible;
2463 else if ( old_validate )
2464 gcd[k].gd.flags = (gg_enabled | gg_visible | gg_cb_on);
2465 else
2466 gcd[k].gd.flags = (gg_enabled | gg_visible);
2467 gcd[k].gd.popup_msg = _("Check the glyph outlines for standard errors before saving\nThis can be slow.");
2468 gcd[k++].creator = GCheckBoxCreate;
2469 hvarray[hvi++] = &gcd[k-1]; hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = GCD_ColSpan;
2470 hvarray[hvi++] = NULL;
2471
2472 label[k].text = (unichar_t *) _("Append a FONTLOG entry");
2473 label[k].text_is_1byte = true;
2474 gcd[k].gd.label = &label[k];
2475 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24+6;
2476 gcd[k].gd.flags = (gg_enabled | gg_visible);
2477 if ( old_fontlog )
2478 gcd[k].gd.flags |= gg_cb_on;
2479 gcd[k].gd.popup_msg = _("The FONTLOG allows you to keep a log of changes made to your font.");
2480 gcd[k].gd.cid = CID_AppendFontLog;
2481 gcd[k].gd.handle_controlevent = GFD_ToggleFontLog;
2482 gcd[k++].creator = GCheckBoxCreate;
2483 hvarray[hvi++] = &gcd[k-1]; hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = GCD_ColSpan;
2484 hvarray[hvi++] = NULL;
2485
2486 gcd[k].gd.flags = old_fontlog ? (gg_visible | gg_enabled | gg_textarea_wrap) : (gg_enabled|gg_textarea_wrap);
2487 gcd[k].gd.cid = CID_FontLogBit;
2488 gcd[k++].creator = GTextAreaCreate;
2489 hvarray[hvi++] = &gcd[k-1];
2490 hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = NULL;
2491
2492 label[k].text = (unichar_t *) _("Prepend timestamp");
2493 label[k].text_is_1byte = true;
2494 gcd[k].gd.label = &label[k];
2495 gcd[k].gd.pos.x = 8; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24+6;
2496 gcd[k].gd.flags = (gg_enabled | gg_visible);
2497 gcd[k].gd.popup_msg = _("This option prepends a timestamp in the format YYMMDDHHMM to the filename and font-family name metadata.");
2498 gcd[k].gd.cid = CID_PrependTimestamp;
2499 gcd[k].gd.handle_controlevent = GFD_TogglePrependTimestamp;
2500 gcd[k++].creator = GCheckBoxCreate; //???
2501 hvarray[hvi++] = &gcd[k-1]; hvarray[hvi++] = GCD_ColSpan; hvarray[hvi++] = GCD_ColSpan;
2502 hvarray[hvi++] = NULL; hvarray[hvi++] = NULL;
2503 } else {
2504 hvarray[12] = NULL;
2505 }
2506
2507 boxes[3].gd.flags = gg_enabled|gg_visible;
2508 boxes[3].gd.u.boxelements = hvarray;
2509 boxes[3].creator = GHVBoxCreate;
2510 varray[2] = GCD_Glue; varray[3] = NULL;
2511 varray[4] = &boxes[3]; varray[5] = NULL;
2512 varray[6] = GCD_Glue; varray[7] = NULL;
2513 varray[8] = GCD_Glue; varray[9] = NULL;
2514 varray[10] = &boxes[2]; varray[11] = NULL;
2515 varray[12] = NULL;
2516
2517 if ( family ) {
2518 y = 276;
2519
2520 f = 0;
2521 gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = y;
2522 gcd[k].gd.pos.width = totwid-5-5;
2523 gcd[k].gd.flags = gg_visible | gg_enabled ;
2524 gcd[k++].creator = GLineCreate;
2525 famarray[f++] = &gcd[k-1]; famarray[f++] = GCD_ColSpan; famarray[f++] = NULL;
2526 y += 7;
2527
2528 for ( i=0, fc=0, j=1; i<familycnt && j<48 ; ++i ) {
2529 while ( fc<fondcnt ) {
2530 while ( j<48 && familysfs[fc][j]==NULL ) ++j;
2531 if ( j!=48 )
2532 break;
2533 ++fc;
2534 j=0;
2535 }
2536 if ( fc==fondcnt )
2537 break;
2538 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = y;
2539 gcd[k].gd.pos.width = gcd[8].gd.pos.x-gcd[k].gd.pos.x-5;
2540 gcd[k].gd.flags = gg_visible | gg_enabled | gg_cb_on ;
2541 label[k].text = (unichar_t *) (familysfs[fc][j]->fontname);
2542 label[k].text_is_1byte = true;
2543 gcd[k].gd.label = &label[k];
2544 gcd[k].gd.cid = CID_Family+i*10;
2545 gcd[k].data = familysfs[fc][j];
2546 gcd[k].gd.popup_msg = styleName(familysfs[fc][j]);
2547 gcd[k++].creator = GCheckBoxCreate;
2548 famarray[f++] = &gcd[k-1];
2549
2550 gcd[k].gd.pos.x = gcd[8].gd.pos.x; gcd[k].gd.pos.y = y; gcd[k].gd.pos.width = gcd[8].gd.pos.width;
2551 gcd[k].gd.flags = gg_visible | gg_enabled;
2552 if ( old==bf_none )
2553 gcd[k].gd.flags &= ~gg_enabled;
2554 temp = familysfs[fc][j]->cidmaster ? familysfs[fc][j]->cidmaster : familysfs[fc][j];
2555 label[k].text = BitmapList(temp);
2556 gcd[k].gd.label = &label[k];
2557 gcd[k].gd.cid = CID_Family+i*10+1;
2558 gcd[k].data = familysfs[fc][j];
2559 gcd[k++].creator = GTextFieldCreate;
2560 famarray[f++] = &gcd[k-1]; famarray[f++] = NULL;
2561 y+=26;
2562 ++j;
2563 }
2564
2565 gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = y;
2566 gcd[k].gd.pos.width = totwid-5-5;
2567 gcd[k].gd.flags = gg_visible | gg_enabled ;
2568 gcd[k++].creator = GLineCreate;
2569 famarray[f++] = &gcd[k-1]; famarray[f++] = GCD_ColSpan; famarray[f++] = NULL;
2570 if ( family == gf_ttc ) {
2571 gcd[k].gd.flags = gg_visible | gg_enabled | gg_cb_on;
2572 label[k].text = (unichar_t *) _("Merge tables across fonts");
2573 label[k].text_is_1byte = true;
2574 gcd[k].gd.label = &label[k];
2575 gcd[k].gd.cid = CID_MergeTables;
2576 gcd[k].gd.popup_msg = _(
2577 "FontForge can generate two styles of ttc file.\n"
2578 "In the first each font is a separate entity\n"
2579 "with no connection to other fonts. In the second\n"
2580 "FontForge will attempt to use the same glyph table\n"
2581 "for all fonts, merging duplicate glyphs. It will\n"
2582 "also attempt to use the same space for tables in\n"
2583 "different fonts which are bit by bit the same.\n\n"
2584 "FontForge isn't always able to perform a merge, in\n"
2585 "which case it falls back on generating independent\n"
2586 "fonts within the ttc.\n"
2587 " FontForge cannot merge if:\n"
2588 " * The fonts have different em-sizes\n"
2589 " * Bitmaps are involved\n"
2590 " * The merged glyf table has more than 65534 glyphs\n\n"
2591 "(Merging will take longer)" );
2592 gcd[k++].creator = GCheckBoxCreate;
2593 famarray[f++] = &gcd[k-1]; famarray[f++] = GCD_ColSpan; famarray[f++] = NULL;
2594
2595 gcd[k].gd.flags = gg_visible | gg_enabled;
2596 label[k].text = (unichar_t *) _("As CFF fonts");
2597 label[k].text_is_1byte = true;
2598 gcd[k].gd.label = &label[k];
2599 gcd[k].gd.cid = CID_TTC_CFF;
2600 gcd[k].gd.popup_msg = _(
2601 "Put CFF fonts into the ttc rather than TTF.\n These seem to work on the mac and linux\n but are documented not to work on Windows." );
2602 gcd[k++].creator = GCheckBoxCreate;
2603 famarray[f++] = &gcd[k-1]; famarray[f++] = GCD_ColSpan; famarray[f++] = NULL;
2604 }
2605 famarray[f++] = NULL;
2606
2607 free(familysfs);
2608
2609 boxes[4].gd.flags = gg_enabled|gg_visible;
2610 boxes[4].gd.u.boxelements = famarray;
2611 boxes[4].creator = GHVBoxCreate;
2612 varray[6] = &boxes[4];
2613 }
2614
2615 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
2616 boxes[0].gd.flags = gg_enabled|gg_visible;
2617 boxes[0].gd.u.boxelements = varray;
2618 boxes[0].creator = GHVGroupCreate;
2619
2620 GGadgetsCreate(gw,boxes);
2621 GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue);
2622 GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame);
2623 GHVBoxFitWindow(boxes[0].ret);
2624
2625 GGadgetSetUserData(gcd[2].ret,gcd[0].ret);
2626 free(namelistnames);
2627 free(lynames);
2628 free(label[9].text);
2629 GFileChooserConnectButtons(gcd[0].ret,gcd[1].ret,gcd[2].ret);
2630 {
2631 SplineFont *master = sf->cidmaster ? sf->cidmaster : sf;
2632 char *fn = master->defbasefilename!=NULL ? master->defbasefilename :
2633 master->fontname;
2634 unichar_t *temp = malloc(sizeof(unichar_t)*(strlen(fn)+30));
2635 uc_strcpy(temp,fn);
2636 if ( ofs==ff_none )
2637 uc_strcat(temp,bitmapextensions[old]);
2638 else
2639 uc_strcat(temp,savefont_extensions[ofs]);
2640 GGadgetSetTitle(gcd[0].ret,temp);
2641 free(temp);
2642 }
2643 GFileChooserGetChildren(gcd[0].ret,&pulldown,&files,&tf);
2644 GWidgetIndicateFocusGadget(tf);
2645 #if __Mac
2646 /* The name of the postscript file is fixed and depends solely on */
2647 /* the font name. If the user tried to change it, the font would */
2648 /* not be found */
2649 GGadgetSetVisible(tf,ofs!=ff_pfbmacbin);
2650 #endif
2651
2652 d.sf = sf;
2653 d.map = map;
2654 d.family = family;
2655 d.familycnt = familycnt-1; /* Don't include the "normal" instance */
2656 d.gfc = gcd[0].ret;
2657 d.pstype = gcd[6].ret;
2658 d.bmptype = gcd[8].ret;
2659 d.bmpsizes = gcd[9].ret;
2660 d.rename = gcd[rk].ret;
2661 d.validate = family ? NULL : gcd[vk].ret;
2662 d.gw = gw;
2663
2664 d.ps_flags = old_ps_flags;
2665 d.sfnt_flags = old_sfnt_flags;
2666 if ( family==gf_macfamily ) {
2667 d.sfnt_flags |= ttf_flag_applemode;
2668 d.sfnt_flags &= ~ttf_flag_otmode;
2669 }
2670 d.psotb_flags = old_ps_flags | (old_psotb_flags&~ps_flag_mask);
2671
2672 GFD_FigureWhich(&d);
2673
2674 GDrawSetVisible(gw,true);
2675 while ( !d.done )
2676 GDrawProcessOneEvent(NULL);
2677 GDrawDestroyWindow(gw);
2678 return(d.ret);
2679 }