LCOV - code coverage report
Current view: top level - fontforgeexe - savefontdlg.c (source / functions) Hit Total Coverage
Test: FontForge coverage report 2017-08-04 01:21:11+02:00 (commit d35f7e4107a9e1db65cce47c468fcc914cecb8fd) Lines: 0 1915 0.0 %
Date: 2017-08-04 Functions: 0 36 0.0 %

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

Generated by: LCOV version 1.10