Debian Codegraph @

fontforgeexe/lookupui.c

raw symbols SCIP
1 /* -*- coding: utf-8 -*- */
2 /* Copyright (C) 2007-2012 by George Williams */
3 /*
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13
14 * The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <fontforge-config.h>
30
31 #include "autowidth2.h"
32 #include "fontforgeui.h"
33 #include "fvfonts.h"
34 #include "gfile.h"
35 #include "gkeysym.h"
36 #include "gresedit.h"
37 #include "lookups.h"
38 #include "sfd.h"
39 #include "sfundo.h"
40 #include "splinefill.h"
41 #include "splinesaveafm.h"
42 #include "splineutil.h"
43 #include "tottfgpos.h"
44 #include "ttf.h"
45 #include "ustring.h"
46 #include "utype.h"
47 #include "gtk/simple_dialogs.hpp"
48
49 #include <locale.h>
50 #include <math.h>
51 #include <stdlib.h>
52
53 int add_char_to_name_list = true;
54 int default_autokern_dlg = true;
55 int fontlevel_undo_limit = 10;
56
57 void SFUntickAllPSTandKern(SplineFont *sf);
58 int kernsLength( KernPair *kp );
59
60 static int DEBUG = 1;
61 GResFont kernformat_font = GRESFONT_INIT("400 12pt " SANS_UI_FAMILIES);
62 GResFont kernformat_boldfont = GRESFONT_INIT("700 12pt " SANS_UI_FAMILIES);
63 Color fi_originlinescol = 0x808080;
64
65 /* ************************************************************************** */
66 /* ******************************* UI routines ****************************** */
67 /* ************************************************************************** */
68
69 GTextInfo **SFLookupListFromType(SplineFont *sf, int lookup_type ) {
70 int isgpos = (lookup_type>=gpos_start);
71 int k, cnt;
72 OTLookup *otl;
73 GTextInfo **ti;
74
75 for ( k=0; k<2; ++k ) {
76 cnt = 0;
77 for ( otl= isgpos ? sf->gpos_lookups : sf->gsub_lookups ; otl!=NULL; otl=otl->next ) {
78 if ( lookup_type==gsub_start || lookup_type==gpos_start ||
79 otl->lookup_type == lookup_type ) {
80 if ( k ) {
81 ti[cnt] = calloc(1,sizeof(GTextInfo));
82 ti[cnt]->userdata = (void *) otl;
83 ti[cnt]->fg = ti[cnt]->bg = COLOR_DEFAULT;
84 ti[cnt]->text = utf82u_copy(otl->lookup_name);
85 }
86 ++cnt;
87 }
88 }
89 if ( !k )
90 ti = calloc(cnt+2,sizeof(GTextInfo *));
91 else
92 ti[cnt] = calloc(1,sizeof(GTextInfo));
93 }
94 return( ti );
95 }
96
97 GTextInfo *SFLookupArrayFromType(SplineFont *sf, int lookup_type ) {
98 int isgpos = (lookup_type>=gpos_start);
99 int k, cnt;
100 OTLookup *otl;
101 GTextInfo *ti;
102
103 for ( k=0; k<2; ++k ) {
104 cnt = 0;
105 for ( otl= isgpos ? sf->gpos_lookups : sf->gsub_lookups ; otl!=NULL; otl=otl->next ) {
106 if ( lookup_type==gsub_start || lookup_type==gpos_start ||
107 otl->lookup_type == lookup_type ) {
108 if ( k ) {
109 ti[cnt].userdata = (void *) otl;
110 ti[cnt].fg = ti[cnt].bg = COLOR_DEFAULT;
111 ti[cnt].text = utf82u_copy(otl->lookup_name);
112 }
113 ++cnt;
114 }
115 }
116 if ( !k )
117 ti = calloc(cnt+2,sizeof(GTextInfo));
118 }
119 return( ti );
120 }
121
122 GTextInfo *SFLookupArrayFromMask(SplineFont *sf, int mask ) {
123 int k, cnt;
124 OTLookup *otl;
125 GTextInfo *ti;
126 int isgpos;
127
128 for ( k=0; k<2; ++k ) {
129 cnt = 0;
130 for ( isgpos = 0; isgpos<2; ++isgpos ) {
131 for ( otl= isgpos ? sf->gpos_lookups : sf->gsub_lookups ; otl!=NULL; otl=otl->next ) {
132 int lmask = isgpos ? (gpos_single_mask<<(otl->lookup_type-gpos_single))
133 : (gsub_single_mask<<(otl->lookup_type-gsub_single));
134 if ( mask==0 || (mask&lmask)) {
135 if ( k ) {
136 ti[cnt].userdata = (void *) otl;
137 ti[cnt].fg = ti[cnt].bg = COLOR_DEFAULT;
138 ti[cnt].text_is_1byte = true;
139 ti[cnt].text = (unichar_t *) copy(otl->lookup_name);
140 }
141 ++cnt;
142 }
143 }
144 }
145 if ( !k )
146 ti = calloc(cnt+2,sizeof(GTextInfo ));
147 }
148 return( ti );
149 }
150
151 /* ************************************************************************** */
152 /* ********************** Lookup dialog and subdialogs ********************** */
153 /* ************************************************************************** */
154
155 static GTextInfo gsub_lookuptypes[] = {
156 { (unichar_t *) N_("Lookup Type|Unspecified"), NULL, 0, 0, (void *) ot_undef, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
157 { (unichar_t *) N_("Single Substitution"), NULL, 0, 0, (void *) gsub_single, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
158 { (unichar_t *) N_("Multiple Substitution"), NULL, 0, 0, (void *) gsub_multiple, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
159 { (unichar_t *) N_("Alternate Substitution"), NULL, 0, 0, (void *) gsub_alternate, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
160 { (unichar_t *) N_("Ligature Substitution"), NULL, 0, 0, (void *) gsub_ligature, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
161 { (unichar_t *) N_("Contextual Substitution"), NULL, 0, 0, (void *) gsub_context, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
162 { (unichar_t *) N_("Contextual Chaining Substitution"), NULL, 0, 0, (void *) gsub_contextchain, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
163 { (unichar_t *) N_("Reverse Chaining Substitution"), NULL, 0, 0, (void *) gsub_reversecchain, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
164 { NULL, NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, '\0'}, /* Line */
165 { (unichar_t *) N_("Mac Indic State Machine"), NULL, 0, 0, (void *) morx_indic, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
166 { (unichar_t *) N_("Mac Contextual State Machine"), NULL, 0, 0, (void *) morx_context, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
167 { (unichar_t *) N_("Mac Insertion State Machine"), NULL, 0, 0, (void *) morx_insert, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
168 GTEXTINFO_EMPTY
169 };
170 static GTextInfo gpos_lookuptypes[] = {
171 { (unichar_t *) N_("Lookup Type|Unspecified"), NULL, 0, 0, (void *) ot_undef, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
172 { (unichar_t *) N_("Single Position"), NULL, 0, 0, (void *) gpos_single, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
173 { (unichar_t *) N_("Pair Position (kerning)"), NULL, 0, 0, (void *) gpos_pair, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
174 { (unichar_t *) N_("Cursive Position"), NULL, 0, 0, (void *) gpos_cursive, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
175 { (unichar_t *) N_("Mark to Base Position"), NULL, 0, 0, (void *) gpos_mark2base, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
176 { (unichar_t *) N_("Mark to Ligature Position"), NULL, 0, 0, (void *) gpos_mark2ligature, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
177 { (unichar_t *) N_("Mark to Mark Position"), NULL, 0, 0, (void *) gpos_mark2mark, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
178 { (unichar_t *) N_("Contextual Position"), NULL, 0, 0, (void *) gpos_context, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
179 { (unichar_t *) N_("Contextual Chaining Position"), NULL, 0, 0, (void *) gpos_contextchain, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
180 { NULL, NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, '\0'}, /* Line */
181 { (unichar_t *) N_("Mac Kerning State Machine"), NULL, 0, 0, (void *) kern_statemachine, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
182 GTEXTINFO_EMPTY
183 };
184 static GTextInfo *lookuptypes[2] = { gsub_lookuptypes, gpos_lookuptypes };
185
186 /* see also list in tottfgpos.c mapping code points to scripts */
187 /* see also list in lookups.c for non-ui access to these data */
188 GTextInfo scripts[] = {
189 { (unichar_t *) N_("Adlam"), NULL, 0, 0, (void *) CHR('a','d','l','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
190 { (unichar_t *) N_("Ahom"), NULL, 0, 0, (void *) CHR('a','h','o','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
191 { (unichar_t *) N_("Anatolian Hieroglyphs"), NULL, 0, 0, (void *) CHR('h','l','u','w'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
192 /* GT: See the long comment at "Property|New" */
193 /* GT: The msgstr should contain a translation of "Arabic", ignore "Script|" */
194 { (unichar_t *) N_("Script|Arabic"), NULL, 0, 0, (void *) CHR('a','r','a','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
195 { (unichar_t *) N_("Script|Aramaic"), NULL, 0, 0, (void *) CHR('s','a','m','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
196 { (unichar_t *) N_("Script|Armenian"), NULL, 0, 0, (void *) CHR('a','r','m','n'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
197 { (unichar_t *) N_("Script|Avestan"), NULL, 0, 0, (void *) CHR('a','v','s','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
198 { (unichar_t *) N_("Script|Balinese"), NULL, 0, 0, (void *) CHR('b','a','l','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
199 { (unichar_t *) N_("Bamum"), NULL, 0, 0, (void *) CHR('b','a','m','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
200 { (unichar_t *) N_("Bassa Vah"), NULL, 0, 0, (void *) CHR('b','a','s','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
201 { (unichar_t *) N_("Script|Batak"), NULL, 0, 0, (void *) CHR('b','a','t','k'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
202 { (unichar_t *) N_("Script|Bengali"), NULL, 0, 0, (void *) CHR('b','e','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
203 { (unichar_t *) N_("Script|Bengali2"), NULL, 0, 0, (void *) CHR('b','n','g','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
204 { (unichar_t *) N_("Beria Erfe"), NULL, 0, 0, (void *) CHR('b','e','r','f'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
205 { (unichar_t *) N_("Bhaiksuki"), NULL, 0, 0, (void *) CHR('b','h','k','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
206 { (unichar_t *) N_("Bopomofo"), NULL, 0, 0, (void *) CHR('b','o','p','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
207 { (unichar_t *) NU_("Brāhmī"), NULL, 0, 0, (void *) CHR('b','r','a','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
208 { (unichar_t *) N_("Braille"), NULL, 0, 0, (void *) CHR('b','r','a','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
209 { (unichar_t *) N_("Script|Buginese"), NULL, 0, 0, (void *) CHR('b','u','g','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
210 { (unichar_t *) N_("Script|Buhid"), NULL, 0, 0, (void *) CHR('b','u','h','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
211 { (unichar_t *) N_("Byzantine Music"), NULL, 0, 0, (void *) CHR('b','y','z','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
212 { (unichar_t *) N_("Canadian Syllabics"), NULL, 0, 0, (void *) CHR('c','a','n','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
213 { (unichar_t *) N_("Carian"), NULL, 0, 0, (void *) CHR('c','a','r','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
214 { (unichar_t *) N_("Caucasian Albanian"), NULL, 0, 0, (void *) CHR('a','g','h','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
215 { (unichar_t *) N_("Chakma"), NULL, 0, 0, (void *) CHR('c','a','k','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
216 { (unichar_t *) N_("Script|Cham"), NULL, 0, 0, (void *) CHR('c','h','a','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
217 { (unichar_t *) N_("Script|Cherokee"), NULL, 0, 0, (void *) CHR('c','h','e','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
218 { (unichar_t *) N_("Script|Chorasmian"), NULL, 0, 0, (void *) CHR('c','h','r','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
219 { (unichar_t *) N_("CJK Ideographic"), NULL, 0, 0, (void *) CHR('h','a','n','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
220 { (unichar_t *) N_("Script|Coptic"), NULL, 0, 0, (void *) CHR('c','o','p','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
221 { (unichar_t *) N_("Cypriot syllabary"), NULL, 0, 0, (void *) CHR('c','p','r','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
222 { (unichar_t *) N_("Cypro-Minoan"), NULL, 0, 0, (void *) CHR('c','p','m','n'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
223 { (unichar_t *) N_("Cyrillic"), NULL, 0, 0, (void *) CHR('c','y','r','l'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
224 { (unichar_t *) N_("Script|Default"), NULL, 0, 0, (void *) CHR('D','F','L','T'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
225 { (unichar_t *) N_("Deseret (Mormon)"), NULL, 0, 0, (void *) CHR('d','s','r','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
226 { (unichar_t *) N_("Devanagari"), NULL, 0, 0, (void *) CHR('d','e','v','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
227 { (unichar_t *) N_("Devanagari2"), NULL, 0, 0, (void *) CHR('d','e','v','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
228 { (unichar_t *) N_("Dives Akuru"), NULL, 0, 0, (void *) CHR('d','i','a','k'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
229 { (unichar_t *) N_("Dogra"), NULL, 0, 0, (void *) CHR('d','o','g','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
230 { (unichar_t *) N_("Duployan"), NULL, 0, 0, (void *) CHR('d','u','p','l'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
231 { (unichar_t *) N_("Egyptian Hieroglyphs"), NULL, 0, 0, (void *) CHR('e','g','y','p'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
232 { (unichar_t *) N_("Elbasan"), NULL, 0, 0, (void *) CHR('e','l','b','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
233 { (unichar_t *) N_("Elymaic"), NULL, 0, 0, (void *) CHR('e','l','y','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
234 { (unichar_t *) N_("Script|Ethiopic"), NULL, 0, 0, (void *) CHR('e','t','h','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
235 { (unichar_t *) N_("Garay"), NULL, 0, 0, (void *) CHR('g','a','r','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
236 { (unichar_t *) N_("Script|Georgian"), NULL, 0, 0, (void *) CHR('g','e','o','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
237 { (unichar_t *) N_("Glagolitic"), NULL, 0, 0, (void *) CHR('g','l','a','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
238 { (unichar_t *) N_("Gothic"), NULL, 0, 0, (void *) CHR('g','o','t','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
239 { (unichar_t *) N_("Grantha"), NULL, 0, 0, (void *) CHR('g','r','a','n'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
240 { (unichar_t *) N_("Script|Greek"), NULL, 0, 0, (void *) CHR('g','r','e','k'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
241 { (unichar_t *) N_("Script|Gujarati"), NULL, 0, 0, (void *) CHR('g','u','j','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
242 { (unichar_t *) N_("Script|Gujarati2"), NULL, 0, 0, (void *) CHR('g','j','r','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
243 { (unichar_t *) N_("Gunjala Gondi"), NULL, 0, 0, (void *) CHR('g','o','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
244 { (unichar_t *) N_("Gurmukhi"), NULL, 0, 0, (void *) CHR('g','u','r','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
245 { (unichar_t *) N_("Gurmukhi2"), NULL, 0, 0, (void *) CHR('g','u','r','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
246 { (unichar_t *) N_("Gurung Khema"), NULL, 0, 0, (void *) CHR('g','u','k','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
247 { (unichar_t *) N_("Hangul Jamo"), NULL, 0, 0, (void *) CHR('j','a','m','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
248 { (unichar_t *) N_("Hangul"), NULL, 0, 0, (void *) CHR('h','a','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
249 { (unichar_t *) N_("Hanifi Rohingya"), NULL, 0, 0, (void *) CHR('r','o','h','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
250 { (unichar_t *) NU_("Script|HanunĂło"), NULL, 0, 0, (void *) CHR('h','a','n','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
251 { (unichar_t *) N_("Hatran"), NULL, 0, 0, (void *) CHR('h','a','t','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
252 { (unichar_t *) N_("Script|Hebrew"), NULL, 0, 0, (void *) CHR('h','e','b','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
253 { (unichar_t *) N_("Hiragana & Katakana"), NULL, 0, 0, (void *) CHR('k','a','n','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
254 { (unichar_t *) N_("Imperial Aramaic"), NULL, 0, 0, (void *) CHR('a','r','m','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
255 { (unichar_t *) N_("Inscriptional Pahlavi"), NULL, 0, 0, (void *) CHR('p','h','l','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
256 { (unichar_t *) N_("Inscriptional Parthian"), NULL, 0, 0, (void *) CHR('p','r','t','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
257 { (unichar_t *) N_("Script|Javanese"), NULL, 0, 0, (void *) CHR('j','a','v','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
258 { (unichar_t *) N_("Kaithi"), NULL, 0, 0, (void *) CHR('k','t','h','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
259 { (unichar_t *) N_("Script|Kannada"), NULL, 0, 0, (void *) CHR('k','n','d','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
260 { (unichar_t *) N_("Script|Kannada2"), NULL, 0, 0, (void *) CHR('k','n','d','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
261 { (unichar_t *) N_("Script|Kawi"), NULL, 0, 0, (void *) CHR('k','a','w','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
262 { (unichar_t *) N_("Kayah Li"), NULL, 0, 0, (void *) CHR('k','a','l','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
263 { (unichar_t *) N_("Script|Kharosthi"), NULL, 0, 0, (void *) CHR('k','h','a','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
264 { (unichar_t *) N_("Khitan Small Script"), NULL, 0, 0, (void *) CHR('k','i','t','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
265 { (unichar_t *) N_("Script|Khmer"), NULL, 0, 0, (void *) CHR('k','h','m','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
266 { (unichar_t *) N_("Khojki"), NULL, 0, 0, (void *) CHR('k','h','o','j'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
267 { (unichar_t *) N_("Khudawadi"), NULL, 0, 0, (void *) CHR('s','i','n','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
268 { (unichar_t *) N_("Kirat Rai"), NULL, 0, 0, (void *) CHR('k','r','a','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
269 { (unichar_t *) N_("Script|Lao"), NULL, 0, 0, (void *) CHR('l','a','o',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
270 { (unichar_t *) N_("Script|Latin"), NULL, 0, 0, (void *) CHR('l','a','t','n'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
271 { (unichar_t *) NU_("Lepcha (RĂłng)"), NULL, 0, 0, (void *) CHR('l','e','p','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
272 { (unichar_t *) N_("Script|Limbu"), NULL, 0, 0, (void *) CHR('l','i','m','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
273 { (unichar_t *) N_("Linear A"), NULL, 0, 0, (void *) CHR('l','i','n','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
274 { (unichar_t *) N_("Linear B"), NULL, 0, 0, (void *) CHR('l','i','n','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
275 { (unichar_t *) N_("Lisu"), NULL, 0, 0, (void *) CHR('l','i','s','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
276 { (unichar_t *) N_("Lycian"), NULL, 0, 0, (void *) CHR('l','y','c','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
277 { (unichar_t *) N_("Lydian"), NULL, 0, 0, (void *) CHR('l','y','d','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
278 { (unichar_t *) N_("Mahajani"), NULL, 0, 0, (void *) CHR('m','a','h','j'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
279 { (unichar_t *) N_("Makasar"), NULL, 0, 0, (void *) CHR('m','a','k','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
280 { (unichar_t *) NU_("Script|Malayālam"), NULL, 0, 0, (void *) CHR('m','l','y','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
281 { (unichar_t *) NU_("Script|Malayālam2"), NULL, 0, 0, (void *) CHR('m','l','m','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
282 { (unichar_t *) N_("Script|Mandaean"), NULL, 0, 0, (void *) CHR('m','a','n','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
283 { (unichar_t *) N_("Manichaean"), NULL, 0, 0, (void *) CHR('m','a','n','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
284 { (unichar_t *) N_("Marchen"), NULL, 0, 0, (void *) CHR('m','a','r','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
285 { (unichar_t *) N_("Masaram Gondi"), NULL, 0, 0, (void *) CHR('g','o','n','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
286 { (unichar_t *) N_("Mathematical text layout"), NULL, 0, 0, (void *) CHR('m','a','t','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
287 { (unichar_t *) N_("Medefaidrin"), NULL, 0, 0, (void *) CHR('m','e','d','f'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
288 { (unichar_t *) N_("Meetei Mayek"), NULL, 0, 0, (void *) CHR('m','t','e','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
289 { (unichar_t *) N_("Mende Kikakui"), NULL, 0, 0, (void *) CHR('m','e','n','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
290 { (unichar_t *) N_("Meroitic Cursive"), NULL, 0, 0, (void *) CHR('m','e','r','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
291 { (unichar_t *) N_("Meroitic Hieroglyphs"), NULL, 0, 0, (void *) CHR('m','e','r','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
292 { (unichar_t *) N_("Miao"), NULL, 0, 0, (void *) CHR('p','l','r','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
293 { (unichar_t *) N_("Modi"), NULL, 0, 0, (void *) CHR('m','o','d','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
294 { (unichar_t *) N_("Script|Mongolian"), NULL, 0, 0, (void *) CHR('m','o','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
295 { (unichar_t *) N_("Mro"), NULL, 0, 0, (void *) CHR('m','r','o','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
296 { (unichar_t *) N_("Multani"), NULL, 0, 0, (void *) CHR('m','u','l','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
297 { (unichar_t *) N_("Musical"), NULL, 0, 0, (void *) CHR('m','u','s','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
298 { (unichar_t *) N_("Script|Myanmar"), NULL, 0, 0, (void *) CHR('m','y','m','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
299 { (unichar_t *) N_("Script|Myanmar2"), NULL, 0, 0, (void *) CHR('m','y','m','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
300 { (unichar_t *) N_("N'Ko"), NULL, 0, 0, (void *) CHR('n','k','o',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
301 { (unichar_t *) N_("Nabataean"), NULL, 0, 0, (void *) CHR('n','b','a','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
302 { (unichar_t *) N_("Nag Mundari"), NULL, 0, 0, (void *) CHR('n','a','g','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
303 { (unichar_t *) N_("Nandinagari"), NULL, 0, 0, (void *) CHR('n','a','n','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
304 { (unichar_t *) N_("New Tai Lue"), NULL, 0, 0, (void *) CHR('t','a','l','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
305 { (unichar_t *) N_("Newa"), NULL, 0, 0, (void *) CHR('n','e','w','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
306 { (unichar_t *) N_("Nushu"), NULL, 0, 0, (void *) CHR('n','s','h','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
307 { (unichar_t *) N_("Nyiakeng Puachue Hmong"), NULL, 0, 0, (void *) CHR('h','m','n','p'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
308 { (unichar_t *) N_("Ogham"), NULL, 0, 0, (void *) CHR('o','g','a','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
309 { (unichar_t *) N_("Ol Chiki"), NULL, 0, 0, (void *) CHR('o','l','c','k'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
310 { (unichar_t *) N_("Ol Onal"), NULL, 0, 0, (void *) CHR('o','n','a','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
311 { (unichar_t *) N_("Old Hungarian"), NULL, 0, 0, (void *) CHR('h','u','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
312 { (unichar_t *) N_("Old Italic (Etruscan, Oscan, etc.)"), NULL, 0, 0, (void *) CHR('i','t','a','l'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
313 { (unichar_t *) N_("Old North Arabian"), NULL, 0, 0, (void *) CHR('n','a','r','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
314 { (unichar_t *) N_("Script|Old Permic"), NULL, 0, 0, (void *) CHR('p','e','r','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
315 { (unichar_t *) N_("Old Persian cuneiform"), NULL, 0, 0, (void *) CHR('x','p','e','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
316 { (unichar_t *) N_("Old Sogdian"), NULL, 0, 0, (void *) CHR('s','o','g','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
317 { (unichar_t *) N_("Old South Arabian"), NULL, 0, 0, (void *) CHR('s','a','r','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
318 { (unichar_t *) N_("Old Turkic"), NULL, 0, 0, (void *) CHR('o','r','k','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
319 { (unichar_t *) N_("Old Uyghur"), NULL, 0, 0, (void *) CHR('o','u','g','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
320 { (unichar_t *) N_("Script|Oriya"), NULL, 0, 0, (void *) CHR('o','r','y','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
321 { (unichar_t *) N_("Script|Oriya2"), NULL, 0, 0, (void *) CHR('o','r','y','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
322 { (unichar_t *) N_("Osage"), NULL, 0, 0, (void *) CHR('o','s','g','e'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
323 { (unichar_t *) N_("Osmanya"), NULL, 0, 0, (void *) CHR('o','s','m','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
324 { (unichar_t *) N_("Pahawh Hmong"), NULL, 0, 0, (void *) CHR('h','m','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
325 { (unichar_t *) N_("Palmyrene"), NULL, 0, 0, (void *) CHR('p','a','l','m'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
326 { (unichar_t *) N_("Pau Cin Hau"), NULL, 0, 0, (void *) CHR('p','a','u','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
327 { (unichar_t *) N_("Script|Phags-pa"), NULL, 0, 0, (void *) CHR('p','h','a','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
328 { (unichar_t *) N_("Script|Phoenician"), NULL, 0, 0, (void *) CHR('p','h','n','x'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
329 { (unichar_t *) N_("Psalter Pahlavi"), NULL, 0, 0, (void *) CHR('p','h','l','p'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
330 { (unichar_t *) N_("Rejang"), NULL, 0, 0, (void *) CHR('r','j','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
331 { (unichar_t *) N_("Runic"), NULL, 0, 0, (void *) CHR('r','u','n','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
332 { (unichar_t *) N_("Saurashtra"), NULL, 0, 0, (void *) CHR('s','a','u','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
333 { (unichar_t *) N_("Sharada"), NULL, 0, 0, (void *) CHR('s','h','r','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
334 { (unichar_t *) N_("Shavian"), NULL, 0, 0, (void *) CHR('s','h','a','w'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
335 { (unichar_t *) N_("Siddham"), NULL, 0, 0, (void *) CHR('s','i','d','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
336 { (unichar_t *) N_("Script|Sidetic"), NULL, 0, 0, (void *) CHR('s','i','d','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
337 { (unichar_t *) N_("Sutton SignWriting"), NULL, 0, 0, (void *) CHR('s','g','n','w'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
338 { (unichar_t *) N_("Script|Sinhala"), NULL, 0, 0, (void *) CHR('s','i','n','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
339 { (unichar_t *) N_("Sogdian"), NULL, 0, 0, (void *) CHR('s','o','g','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
340 { (unichar_t *) N_("Sora Sompeng"), NULL, 0, 0, (void *) CHR('s','o','r','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
341 { (unichar_t *) N_("Soyombo"), NULL, 0, 0, (void *) CHR('s','o','y','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
342 { (unichar_t *) N_("Script|Sumero-Akkadian Cuneiform"), NULL, 0, 0, (void *) CHR('x','s','u','x'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
343 { (unichar_t *) N_("Script|Sundanese"), NULL, 0, 0, (void *) CHR('s','u','n','d'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
344 { (unichar_t *) N_("Script|Sunuwar"), NULL, 0, 0, (void *) CHR('s','u','n','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
345 { (unichar_t *) N_("Script|Syloti Nagri"), NULL, 0, 0, (void *) CHR('s','y','l','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
346 { (unichar_t *) N_("Script|Syriac"), NULL, 0, 0, (void *) CHR('s','y','r','c'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
347 { (unichar_t *) N_("Script|Tagalog"), NULL, 0, 0, (void *) CHR('t','g','l','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
348 { (unichar_t *) N_("Script|Tagbanwa"), NULL, 0, 0, (void *) CHR('t','a','g','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
349 { (unichar_t *) N_("Tai Le"), NULL, 0, 0, (void *) CHR('t','a','l','e'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
350 { (unichar_t *) N_("Tai Tham"), NULL, 0, 0, (void *) CHR('l','a','n','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
351 { (unichar_t *) N_("Tai Viet"), NULL, 0, 0, (void *) CHR('t','a','v','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
352 { (unichar_t *) N_("Script|Tai Yo"), NULL, 0, 0, (void *) CHR('t','a','y','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
353 { (unichar_t *) N_("Takri"), NULL, 0, 0, (void *) CHR('t','a','k','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
354 { (unichar_t *) N_("Tangsa"), NULL, 0, 0, (void *) CHR('t','n','s','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
355 { (unichar_t *) N_("Script|Tamil"), NULL, 0, 0, (void *) CHR('t','a','m','l'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
356 { (unichar_t *) N_("Script|Tamil2"), NULL, 0, 0, (void *) CHR('t','m','l','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
357 { (unichar_t *) N_("Tangut"), NULL, 0, 0, (void *) CHR('t','a','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
358 { (unichar_t *) N_("Script|Telugu"), NULL, 0, 0, (void *) CHR('t','e','l','u'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
359 { (unichar_t *) N_("Script|Telugu2"), NULL, 0, 0, (void *) CHR('t','e','l','2'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
360 { (unichar_t *) N_("Thaana"), NULL, 0, 0, (void *) CHR('t','h','a','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
361 { (unichar_t *) N_("Script|Thai"), NULL, 0, 0, (void *) CHR('t','h','a','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
362 { (unichar_t *) N_("Script|Tibetan"), NULL, 0, 0, (void *) CHR('t','i','b','t'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
363 { (unichar_t *) N_("Tifinagh (Berber)"), NULL, 0, 0, (void *) CHR('t','f','n','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
364 { (unichar_t *) N_("Tirhuta"), NULL, 0, 0, (void *) CHR('t','i','r','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
365 { (unichar_t *) N_("Todhri"), NULL, 0, 0, (void *) CHR('t','o','d','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
366 { (unichar_t *) N_("Tolong Siki"), NULL, 0, 0, (void *) CHR('t','o','l','s'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
367 { (unichar_t *) N_("Toto"), NULL, 0, 0, (void *) CHR('t','o','t','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
368 { (unichar_t *) N_("Tulu-Tigalari"), NULL, 0, 0, (void *) CHR('t','u','t','g'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
369 { (unichar_t *) N_("Script|Ugaritic"), NULL, 0, 0, (void *) CHR('u','g','a','r'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
370 { (unichar_t *) N_("Script|Vai"), NULL, 0, 0, (void *) CHR('v','a','i',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
371 { (unichar_t *) N_("Vithkuqi"), NULL, 0, 0, (void *) CHR('v','i','t','h'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
372 { (unichar_t *) N_("Script|Wancho"), NULL, 0, 0, (void *) CHR('w','c','h','o'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
373 { (unichar_t *) N_("Warang Citi"), NULL, 0, 0, (void *) CHR('w','a','r','a'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
374 { (unichar_t *) N_("Script|Yezidi"), NULL, 0, 0, (void *) CHR('y','e','z','i'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
375 { (unichar_t *) N_("Script|Yi"), NULL, 0, 0, (void *) CHR('y','i',' ',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
376 { (unichar_t *) N_("Zanabazar Square"), NULL, 0, 0, (void *) CHR('z','a','n','b'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
377 GTEXTINFO_EMPTY
378 };
379
380 GTextInfo languages[] = {
381 { (unichar_t *) N_("Eastern Abenaki"), NULL, 0, 0, (void *) CHR('A','A','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
382 { (unichar_t *) N_("Abaza"), NULL, 0, 0, (void *) CHR('A','B','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
383 { (unichar_t *) N_("Abkhazian"), NULL, 0, 0, (void *) CHR('A','B','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
384 { (unichar_t *) N_("Acholi"), NULL, 0, 0, (void *) CHR('A','C','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
385 { (unichar_t *) N_("Achi"), NULL, 0, 0, (void *) CHR('A','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
386 { (unichar_t *) N_("Cypriot Arabic"), NULL, 0, 0, (void *) CHR('A','C','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
387 { (unichar_t *) N_("Adyghe"), NULL, 0, 0, (void *) CHR('A','D','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
388 { (unichar_t *) N_("Afrikaans"), NULL, 0, 0, (void *) CHR('A','F','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
389 { (unichar_t *) N_("Afar"), NULL, 0, 0, (void *) CHR('A','F','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
390 { (unichar_t *) N_("Agaw"), NULL, 0, 0, (void *) CHR('A','G','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
391 { (unichar_t *) N_("Aiton"), NULL, 0, 0, (void *) CHR('A','I','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
392 { (unichar_t *) N_("Akan"), NULL, 0, 0, (void *) CHR('A','K','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
393 { (unichar_t *) N_("Batak Angkola"), NULL, 0, 0, (void *) CHR('A','K','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
394 { (unichar_t *) N_("Alsatian"), NULL, 0, 0, (void *) CHR('A','L','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
395 { (unichar_t *) N_("Altai"), NULL, 0, 0, (void *) CHR('A','L','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
396 /* GT: See the long comment at "Property|New" */
397 /* GT: The msgstr should contain a translation of "Amharic", ignore "Lang|" */
398 { (unichar_t *) N_("Lang|Amharic"), NULL, 0, 0, (void *) CHR('A','M','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
399 { (unichar_t *) N_("Anglo-Saxon"), NULL, 0, 0, (void *) CHR('A','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
400 { (unichar_t *) N_("Americanist IPA"), NULL, 0, 0, (void *) CHR('A','P','P','H'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
401 { (unichar_t *) N_("Lang|Arabic"), NULL, 0, 0, (void *) CHR('A','R','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
402 { (unichar_t *) N_("Aragonese"), NULL, 0, 0, (void *) CHR('A','R','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
403 { (unichar_t *) N_("Aari"), NULL, 0, 0, (void *) CHR('A','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
404 { (unichar_t *) N_("Rakhine"), NULL, 0, 0, (void *) CHR('A','R','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
405 { (unichar_t *) N_("Assamese"), NULL, 0, 0, (void *) CHR('A','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
406 { (unichar_t *) N_("Asturian"), NULL, 0, 0, (void *) CHR('A','S','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
407 { (unichar_t *) N_("Athapaskan languages"), NULL, 0, 0, (void *) CHR('A','T','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
408 { (unichar_t *) N_("Gros Ventre"), NULL, 0, 0, (void *) CHR('A','T','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
409 { (unichar_t *) N_("Avatime"), NULL, 0, 0, (void *) CHR('A','V','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
410 { (unichar_t *) N_("Lang|Avar"), NULL, 0, 0, (void *) CHR('A','V','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
411 { (unichar_t *) N_("Awadhi"), NULL, 0, 0, (void *) CHR('A','W','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
412 { (unichar_t *) N_("Aymara"), NULL, 0, 0, (void *) CHR('A','Y','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
413 { (unichar_t *) N_("Torki"), NULL, 0, 0, (void *) CHR('A','Z','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
414 { (unichar_t *) N_("Azerbaijani"), NULL, 0, 0, (void *) CHR('A','Z','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
415 { (unichar_t *) N_("Badaga"), NULL, 0, 0, (void *) CHR('B','A','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
416 { (unichar_t *) N_("Banda"), NULL, 0, 0, (void *) CHR('B','A','D','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
417 { (unichar_t *) N_("Baghelkhandi"), NULL, 0, 0, (void *) CHR('B','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
418 { (unichar_t *) N_("Balkar"), NULL, 0, 0, (void *) CHR('B','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
419 { (unichar_t *) N_("Lang|Balinese"), NULL, 0, 0, (void *) CHR('B','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
420 { (unichar_t *) N_("Bavarian"), NULL, 0, 0, (void *) CHR('B','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
421 { (unichar_t *) NU_("Baulé"), NULL, 0, 0, (void *) CHR('B','A','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
422 { (unichar_t *) N_("Batak Toba"), NULL, 0, 0, (void *) CHR('B','B','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
423 { (unichar_t *) N_("Lang|Berber"), NULL, 0, 0, (void *) CHR('B','B','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
424 { (unichar_t *) N_("Bench"), NULL, 0, 0, (void *) CHR('B','C','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
425 { (unichar_t *) N_("Bible Cree"), NULL, 0, 0, (void *) CHR('B','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
426 { (unichar_t *) NU_("EmberĂĄ-BaudĂł"), NULL, 0, 0, (void *) CHR('B','D','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
427 { (unichar_t *) N_("Bandjalang"), NULL, 0, 0, (void *) CHR('B','D','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
428 { (unichar_t *) N_("Belarussian"), NULL, 0, 0, (void *) CHR('B','E','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
429 { (unichar_t *) N_("Bemba"), NULL, 0, 0, (void *) CHR('B','E','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
430 { (unichar_t *) N_("Lang|Bengali"), NULL, 0, 0, (void *) CHR('B','E','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
431 { (unichar_t *) N_("Haryanvi"), NULL, 0, 0, (void *) CHR('B','G','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
432 { (unichar_t *) N_("Bagri"), NULL, 0, 0, (void *) CHR('B','G','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
433 { (unichar_t *) N_("Bulgarian"), NULL, 0, 0, (void *) CHR('B','G','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
434 { (unichar_t *) N_("Bhili"), NULL, 0, 0, (void *) CHR('B','H','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
435 { (unichar_t *) N_("Bhojpuri"), NULL, 0, 0, (void *) CHR('B','H','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
436 { (unichar_t *) N_("Bikol"), NULL, 0, 0, (void *) CHR('B','I','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
437 { (unichar_t *) N_("Bilen"), NULL, 0, 0, (void *) CHR('B','I','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
438 { (unichar_t *) N_("Bislama"), NULL, 0, 0, (void *) CHR('B','I','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
439 { (unichar_t *) N_("Kanauji"), NULL, 0, 0, (void *) CHR('B','J','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
440 { (unichar_t *) N_("Blackfoot"), NULL, 0, 0, (void *) CHR('B','K','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
441 { (unichar_t *) N_("Baluchi"), NULL, 0, 0, (void *) CHR('B','L','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
442 { (unichar_t *) N_("Pa'o Karen"), NULL, 0, 0, (void *) CHR('B','L','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
443 { (unichar_t *) N_("Balante"), NULL, 0, 0, (void *) CHR('B','L','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
444 { (unichar_t *) N_("Balti"), NULL, 0, 0, (void *) CHR('B','L','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
445 { (unichar_t *) N_("Bambara"), NULL, 0, 0, (void *) CHR('B','M','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
446 { (unichar_t *) N_("Bamileke"), NULL, 0, 0, (void *) CHR('B','M','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
447 { (unichar_t *) N_("Bosnian"), NULL, 0, 0, (void *) CHR('B','O','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
448 { (unichar_t *) N_("Bishnupriya Manipuri"), NULL, 0, 0, (void *) CHR('B','P','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
449 { (unichar_t *) N_("Breton"), NULL, 0, 0, (void *) CHR('B','R','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
450 { (unichar_t *) N_("Brahui"), NULL, 0, 0, (void *) CHR('B','R','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
451 { (unichar_t *) N_("Braj Bhasha"), NULL, 0, 0, (void *) CHR('B','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
452 { (unichar_t *) N_("Burmese"), NULL, 0, 0, (void *) CHR('B','R','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
453 { (unichar_t *) N_("Bodo"), NULL, 0, 0, (void *) CHR('B','R','X',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
454 { (unichar_t *) N_("Bashkir"), NULL, 0, 0, (void *) CHR('B','S','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
455 { (unichar_t *) N_("Burushaski"), NULL, 0, 0, (void *) CHR('B','S','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
456 { (unichar_t *) N_("Batak Dairi (Pakpak)"), NULL, 0, 0, (void *) CHR('B','T','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
457 { (unichar_t *) N_("Beti"), NULL, 0, 0, (void *) CHR('B','T','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
458 { (unichar_t *) N_("Batak languages"), NULL, 0, 0, (void *) CHR('B','T','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
459 { (unichar_t *) N_("Batak Mandailing"), NULL, 0, 0, (void *) CHR('B','T','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
460 { (unichar_t *) N_("Batak Simalungun"), NULL, 0, 0, (void *) CHR('B','T','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
461 { (unichar_t *) N_("Batak Karo"), NULL, 0, 0, (void *) CHR('B','T','X',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
462 { (unichar_t *) N_("Batak Alas-Kluet"), NULL, 0, 0, (void *) CHR('B','T','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
463 { (unichar_t *) N_("Lang|Bugis"), NULL, 0, 0, (void *) CHR('B','U','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
464 { (unichar_t *) N_("Medumba"), NULL, 0, 0, (void *) CHR('B','Y','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
465 { (unichar_t *) N_("Kaqchikel"), NULL, 0, 0, (void *) CHR('C','A','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
466 { (unichar_t *) N_("Catalan"), NULL, 0, 0, (void *) CHR('C','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
467 { (unichar_t *) N_("Cayuga"), NULL, 0, 0, (void *) CHR('C','A','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
468 { (unichar_t *) N_("Chimila"), NULL, 0, 0, (void *) CHR('C','B','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
469 { (unichar_t *) N_("Zamboanga Chavacano"), NULL, 0, 0, (void *) CHR('C','B','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
470 { (unichar_t *) N_("Chinantec"), NULL, 0, 0, (void *) CHR('C','C','H','N'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
471 { (unichar_t *) N_("Cebuano"), NULL, 0, 0, (void *) CHR('C','E','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
472 { (unichar_t *) N_("Chiga"), NULL, 0, 0, (void *) CHR('C','G','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
473 { (unichar_t *) N_("Chamorro"), NULL, 0, 0, (void *) CHR('C','H','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
474 { (unichar_t *) N_("Chechen"), NULL, 0, 0, (void *) CHR('C','H','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
475 { (unichar_t *) N_("Chaha Gurage"), NULL, 0, 0, (void *) CHR('C','H','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
476 { (unichar_t *) N_("Chattisgarhi"), NULL, 0, 0, (void *) CHR('C','H','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
477 { (unichar_t *) N_("Chichewa"), NULL, 0, 0, (void *) CHR('C','H','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
478 { (unichar_t *) N_("Chukchi"), NULL, 0, 0, (void *) CHR('C','H','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
479 { (unichar_t *) N_("Chuukese"), NULL, 0, 0, (void *) CHR('C','H','K','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
480 { (unichar_t *) N_("Choctaw"), NULL, 0, 0, (void *) CHR('C','H','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
481 { (unichar_t *) N_("Chipewyan"), NULL, 0, 0, (void *) CHR('C','H','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
482 { (unichar_t *) N_("Lang|Cherokee"), NULL, 0, 0, (void *) CHR('C','H','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
483 { (unichar_t *) N_("Chuvash"), NULL, 0, 0, (void *) CHR('C','H','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
484 { (unichar_t *) N_("Cheyenne"), NULL, 0, 0, (void *) CHR('C','H','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
485 { (unichar_t *) N_("Lang|Western Cham"), NULL, 0, 0, (void *) CHR('C','J','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
486 { (unichar_t *) N_("Eastern Cham"), NULL, 0, 0, (void *) CHR('C','J','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
487 { (unichar_t *) NU_("EmberĂĄ-ChamĂ­"), NULL, 0, 0, (void *) CHR('C','M','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
488 { (unichar_t *) N_("Comorian"), NULL, 0, 0, (void *) CHR('C','M','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
489 { (unichar_t *) N_("Comox"), NULL, 0, 0, (void *) CHR('C','O','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
490 { (unichar_t *) N_("Lang|Coptic"), NULL, 0, 0, (void *) CHR('C','O','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
491 { (unichar_t *) N_("Cornish"), NULL, 0, 0, (void *) CHR('C','O','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
492 { (unichar_t *) N_("Corsican"), NULL, 0, 0, (void *) CHR('C','O','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
493 { (unichar_t *) N_("Creoles"), NULL, 0, 0, (void *) CHR('C','P','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
494 { (unichar_t *) N_("Cree"), NULL, 0, 0, (void *) CHR('C','R','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
495 { (unichar_t *) N_("Carrier"), NULL, 0, 0, (void *) CHR('C','R','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
496 { (unichar_t *) N_("Crimean Tatar"), NULL, 0, 0, (void *) CHR('C','R','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
497 { (unichar_t *) N_("Kashubian"), NULL, 0, 0, (void *) CHR('C','S','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
498 { (unichar_t *) N_("Church Slavonic"), NULL, 0, 0, (void *) CHR('C','S','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
499 { (unichar_t *) N_("Czech"), NULL, 0, 0, (void *) CHR('C','S','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
500 { (unichar_t *) N_("Chittagonian"), NULL, 0, 0, (void *) CHR('C','T','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
501 { (unichar_t *) NU_("EmberĂĄ-CatĂ­o"), NULL, 0, 0, (void *) CHR('C','T','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
502 { (unichar_t *) N_("Wayanad Chetti"), NULL, 0, 0, (void *) CHR('C','T','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
503 { (unichar_t *) N_("San Blas Kuna"), NULL, 0, 0, (void *) CHR('C','U','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
504 { (unichar_t *) N_("Dagbani"), NULL, 0, 0, (void *) CHR('D','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
505 { (unichar_t *) N_("Danish"), NULL, 0, 0, (void *) CHR('D','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
506 { (unichar_t *) N_("Dargwa"), NULL, 0, 0, (void *) CHR('D','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
507 { (unichar_t *) N_("Dayi"), NULL, 0, 0, (void *) CHR('D','A','X',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
508 { (unichar_t *) N_("Woods Cree"), NULL, 0, 0, (void *) CHR('D','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
509 { (unichar_t *) N_("German"), NULL, 0, 0, (void *) CHR('D','E','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
510 { (unichar_t *) N_("Lang|Default"), NULL, 0, 0, (void *) DEFAULT_LANG, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
511 { (unichar_t *) N_("Dogri (individual language)"), NULL, 0, 0, (void *) CHR('D','G','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
512 { (unichar_t *) N_("Dogri (macrolanguage)"), NULL, 0, 0, (void *) CHR('D','G','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
513 { (unichar_t *) N_("Dhangu"), NULL, 0, 0, (void *) CHR('D','H','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
514 { (unichar_t *) N_("Divehi (Obsolete)"), NULL, 0, 0, (void *) CHR('D','H','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
515 { (unichar_t *) N_("Dimli"), NULL, 0, 0, (void *) CHR('D','I','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
516 { (unichar_t *) N_("Divehi"), NULL, 0, 0, (void *) CHR('D','I','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
517 { (unichar_t *) N_("Zarma"), NULL, 0, 0, (void *) CHR('D','J','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
518 { (unichar_t *) N_("Djambarrpuyngu"), NULL, 0, 0, (void *) CHR('D','J','R','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
519 { (unichar_t *) N_("Dangme"), NULL, 0, 0, (void *) CHR('D','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
520 { (unichar_t *) N_("Dan"), NULL, 0, 0, (void *) CHR('D','N','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
521 { (unichar_t *) N_("Dinka"), NULL, 0, 0, (void *) CHR('D','N','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
522 { (unichar_t *) N_("Dari"), NULL, 0, 0, (void *) CHR('D','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
523 { (unichar_t *) N_("Dhuwal"), NULL, 0, 0, (void *) CHR('D','U','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
524 { (unichar_t *) N_("Dungan"), NULL, 0, 0, (void *) CHR('D','U','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
525 { (unichar_t *) N_("Dzongkha"), NULL, 0, 0, (void *) CHR('D','Z','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
526 { (unichar_t *) N_("Ebira"), NULL, 0, 0, (void *) CHR('E','B','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
527 { (unichar_t *) N_("Eastern Cree"), NULL, 0, 0, (void *) CHR('E','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
528 { (unichar_t *) N_("Edo"), NULL, 0, 0, (void *) CHR('E','D','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
529 { (unichar_t *) N_("Efik"), NULL, 0, 0, (void *) CHR('E','F','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
530 { (unichar_t *) N_("Lang|Greek"), NULL, 0, 0, (void *) CHR('E','L','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
531 { (unichar_t *) N_("Eastern Maninkakan"), NULL, 0, 0, (void *) CHR('E','M','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
532 { (unichar_t *) NU_("Northern EmberĂĄ"), NULL, 0, 0, (void *) CHR('E','M','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
533 { (unichar_t *) N_("English"), NULL, 0, 0, (void *) CHR('E','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
534 { (unichar_t *) N_("Erzya"), NULL, 0, 0, (void *) CHR('E','R','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
535 { (unichar_t *) N_("Spanish"), NULL, 0, 0, (void *) CHR('E','S','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
536 { (unichar_t *) N_("Central Yupik"), NULL, 0, 0, (void *) CHR('E','S','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
537 { (unichar_t *) N_("Estonian"), NULL, 0, 0, (void *) CHR('E','T','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
538 { (unichar_t *) N_("Basque"), NULL, 0, 0, (void *) CHR('E','U','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
539 { (unichar_t *) N_("Evenki"), NULL, 0, 0, (void *) CHR('E','V','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
540 { (unichar_t *) N_("Even"), NULL, 0, 0, (void *) CHR('E','V','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
541 { (unichar_t *) N_("Ewe"), NULL, 0, 0, (void *) CHR('E','W','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
542 { (unichar_t *) N_("French Antillean"), NULL, 0, 0, (void *) CHR('F','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
543 { (unichar_t *) N_("Fang"), NULL, 0, 0, (void *) CHR('F','A','N','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
544 { (unichar_t *) N_("Lang|Persian"), NULL, 0, 0, (void *) CHR('F','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
545 { (unichar_t *) N_("Fanti"), NULL, 0, 0, (void *) CHR('F','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
546 { (unichar_t *) N_("Finnish"), NULL, 0, 0, (void *) CHR('F','I','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
547 { (unichar_t *) N_("Fijian"), NULL, 0, 0, (void *) CHR('F','J','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
548 { (unichar_t *) N_("Flemish"), NULL, 0, 0, (void *) CHR('F','L','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
549 { (unichar_t *) N_("Fe'fe'"), NULL, 0, 0, (void *) CHR('F','M','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
550 { (unichar_t *) N_("Forest Enets"), NULL, 0, 0, (void *) CHR('F','N','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
551 { (unichar_t *) N_("Fon"), NULL, 0, 0, (void *) CHR('F','O','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
552 { (unichar_t *) N_("Faroese"), NULL, 0, 0, (void *) CHR('F','O','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
553 { (unichar_t *) N_("French"), NULL, 0, 0, (void *) CHR('F','R','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
554 { (unichar_t *) N_("Cajun French"), NULL, 0, 0, (void *) CHR('F','R','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
555 { (unichar_t *) N_("Frisian"), NULL, 0, 0, (void *) CHR('F','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
556 { (unichar_t *) N_("Friulian"), NULL, 0, 0, (void *) CHR('F','R','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
557 { (unichar_t *) N_("Arpitan"), NULL, 0, 0, (void *) CHR('F','R','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
558 { (unichar_t *) N_("Futa"), NULL, 0, 0, (void *) CHR('F','T','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
559 { (unichar_t *) N_("Fulah"), NULL, 0, 0, (void *) CHR('F','U','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
560 { (unichar_t *) N_("Nigerian Fulfulde"), NULL, 0, 0, (void *) CHR('F','U','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
561 { (unichar_t *) N_("Ga"), NULL, 0, 0, (void *) CHR('G','A','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
562 { (unichar_t *) N_("Scottish Gaelic"), NULL, 0, 0, (void *) CHR('G','A','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
563 { (unichar_t *) N_("Gagauz"), NULL, 0, 0, (void *) CHR('G','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
564 { (unichar_t *) N_("Galician"), NULL, 0, 0, (void *) CHR('G','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
565 { (unichar_t *) N_("Garshuni"), NULL, 0, 0, (void *) CHR('G','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
566 { (unichar_t *) N_("Garhwali"), NULL, 0, 0, (void *) CHR('G','A','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
567 { (unichar_t *) N_("Lang|Ge'ez"), NULL, 0, 0, (void *) CHR('G','E','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
568 { (unichar_t *) N_("Githabul"), NULL, 0, 0, (void *) CHR('G','I','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
569 { (unichar_t *) N_("Gilyak"), NULL, 0, 0, (void *) CHR('G','I','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
570 { (unichar_t *) N_("Kiribati"), NULL, 0, 0, (void *) CHR('G','I','L','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
571 { (unichar_t *) N_("Kpelle (Guinea)"), NULL, 0, 0, (void *) CHR('G','K','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
572 { (unichar_t *) N_("Gilaki"), NULL, 0, 0, (void *) CHR('G','L','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
573 { (unichar_t *) N_("Gumuz"), NULL, 0, 0, (void *) CHR('G','M','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
574 { (unichar_t *) N_("Gumatj"), NULL, 0, 0, (void *) CHR('G','N','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
575 { (unichar_t *) N_("Gogo"), NULL, 0, 0, (void *) CHR('G','O','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
576 { (unichar_t *) N_("Gondi"), NULL, 0, 0, (void *) CHR('G','O','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
577 { (unichar_t *) N_("Greenlandic"), NULL, 0, 0, (void *) CHR('G','R','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
578 { (unichar_t *) N_("Garo"), NULL, 0, 0, (void *) CHR('G','R','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
579 { (unichar_t *) N_("Guarani"), NULL, 0, 0, (void *) CHR('G','U','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
580 { (unichar_t *) N_("Wayuu"), NULL, 0, 0, (void *) CHR('G','U','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
581 { (unichar_t *) N_("Gupapuyngu"), NULL, 0, 0, (void *) CHR('G','U','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
582 { (unichar_t *) N_("Lang|Gujarati"), NULL, 0, 0, (void *) CHR('G','U','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
583 { (unichar_t *) N_("Gusii"), NULL, 0, 0, (void *) CHR('G','U','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
584 { (unichar_t *) N_("Haitian"), NULL, 0, 0, (void *) CHR('H','A','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
585 { (unichar_t *) N_("Haida"), NULL, 0, 0, (void *) CHR('H','A','I','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
586 { (unichar_t *) N_("Halam"), NULL, 0, 0, (void *) CHR('H','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
587 { (unichar_t *) N_("Harauti"), NULL, 0, 0, (void *) CHR('H','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
588 { (unichar_t *) N_("Hausa"), NULL, 0, 0, (void *) CHR('H','A','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
589 { (unichar_t *) N_("Hawaiian"), NULL, 0, 0, (void *) CHR('H','A','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
590 { (unichar_t *) N_("Haya"), NULL, 0, 0, (void *) CHR('H','A','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
591 { (unichar_t *) N_("Hazaragi"), NULL, 0, 0, (void *) CHR('H','A','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
592 { (unichar_t *) N_("Hammer-Banna"), NULL, 0, 0, (void *) CHR('H','B','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
593 { (unichar_t *) N_("Heiltsuk"), NULL, 0, 0, (void *) CHR('H','E','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
594 { (unichar_t *) N_("Herero"), NULL, 0, 0, (void *) CHR('H','E','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
595 { (unichar_t *) N_("Hiligaynon"), NULL, 0, 0, (void *) CHR('H','I','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
596 { (unichar_t *) N_("Hindi"), NULL, 0, 0, (void *) CHR('H','I','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
597 { (unichar_t *) N_("High Mari"), NULL, 0, 0, (void *) CHR('H','M','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
598 { (unichar_t *) N_("A-Hmao"), NULL, 0, 0, (void *) CHR('H','M','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
599 { (unichar_t *) N_("Hmong"), NULL, 0, 0, (void *) CHR('H','M','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
600 { (unichar_t *) N_("Hiri Motu"), NULL, 0, 0, (void *) CHR('H','M','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
601 { (unichar_t *) N_("Hmong Shuat"), NULL, 0, 0, (void *) CHR('H','M','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
602 { (unichar_t *) N_("Hindko"), NULL, 0, 0, (void *) CHR('H','N','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
603 { (unichar_t *) N_("Ho"), NULL, 0, 0, (void *) CHR('H','O',' ',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
604 { (unichar_t *) N_("Harari"), NULL, 0, 0, (void *) CHR('H','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
605 { (unichar_t *) N_("Croatian"), NULL, 0, 0, (void *) CHR('H','R','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
606 { (unichar_t *) N_("Hungarian"), NULL, 0, 0, (void *) CHR('H','U','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
607 { (unichar_t *) N_("Halkomelem"), NULL, 0, 0, (void *) CHR('H','U','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
608 { (unichar_t *) N_("Lang|Armenian"), NULL, 0, 0, (void *) CHR('H','Y','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
609 { (unichar_t *) N_("Armenian East"), NULL, 0, 0, (void *) CHR('H','Y','E','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
610 { (unichar_t *) N_("Iban"), NULL, 0, 0, (void *) CHR('I','B','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
611 { (unichar_t *) N_("Ibibio"), NULL, 0, 0, (void *) CHR('I','B','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
612 { (unichar_t *) N_("Igbo"), NULL, 0, 0, (void *) CHR('I','B','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
613 { (unichar_t *) N_("Ido"), NULL, 0, 0, (void *) CHR('I','D','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
614 { (unichar_t *) N_("Ijo languages"), NULL, 0, 0, (void *) CHR('I','J','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
615 { (unichar_t *) N_("Interlingue"), NULL, 0, 0, (void *) CHR('I','L','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
616 { (unichar_t *) N_("Ilokano"), NULL, 0, 0, (void *) CHR('I','L','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
617 { (unichar_t *) N_("Interlingua"), NULL, 0, 0, (void *) CHR('I','N','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
618 { (unichar_t *) N_("Indonesian"), NULL, 0, 0, (void *) CHR('I','N','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
619 { (unichar_t *) N_("Ingush"), NULL, 0, 0, (void *) CHR('I','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
620 { (unichar_t *) N_("Inuktitut"), NULL, 0, 0, (void *) CHR('I','N','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
621 { (unichar_t *) N_("Nunavik Inuktitut"), NULL, 0, 0, (void *) CHR('I','N','U','K'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
622 { (unichar_t *) N_("Inupiat"), NULL, 0, 0, (void *) CHR('I','P','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
623 { (unichar_t *) N_("IPA usage"), NULL, 0, 0, (void *) CHR('I','P','P','H'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
624 { (unichar_t *) N_("Irish"), NULL, 0, 0, (void *) CHR('I','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
625 { (unichar_t *) N_("Irish Traditional"), NULL, 0, 0, (void *) CHR('I','R','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
626 { (unichar_t *) N_("Irula"), NULL, 0, 0, (void *) CHR('I','R','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
627 { (unichar_t *) N_("Icelandic"), NULL, 0, 0, (void *) CHR('I','S','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
628 { (unichar_t *) N_("Inari Sami"), NULL, 0, 0, (void *) CHR('I','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
629 { (unichar_t *) N_("Italian"), NULL, 0, 0, (void *) CHR('I','T','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
630 { (unichar_t *) N_("Lang|Hebrew"), NULL, 0, 0, (void *) CHR('I','W','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
631 { (unichar_t *) N_("Jamaican Creole"), NULL, 0, 0, (void *) CHR('J','A','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
632 { (unichar_t *) N_("Japanese"), NULL, 0, 0, (void *) CHR('J','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
633 { (unichar_t *) N_("Lang|Javanese"), NULL, 0, 0, (void *) CHR('J','A','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
634 { (unichar_t *) N_("Lojban"), NULL, 0, 0, (void *) CHR('J','B','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
635 { (unichar_t *) N_("Krymchak"), NULL, 0, 0, (void *) CHR('J','C','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
636 { (unichar_t *) N_("Judeo-Tat"), NULL, 0, 0, (void *) CHR('J','D','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
637 { (unichar_t *) N_("Yiddish"), NULL, 0, 0, (void *) CHR('J','I','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
638 { (unichar_t *) N_("Ladino"), NULL, 0, 0, (void *) CHR('J','U','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
639 { (unichar_t *) N_("Jula"), NULL, 0, 0, (void *) CHR('J','U','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
640 { (unichar_t *) N_("Kabardian"), NULL, 0, 0, (void *) CHR('K','A','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
641 { (unichar_t *) N_("Kabyle"), NULL, 0, 0, (void *) CHR('K','A','B','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
642 { (unichar_t *) N_("Kachchi"), NULL, 0, 0, (void *) CHR('K','A','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
643 { (unichar_t *) N_("Kalenjin"), NULL, 0, 0, (void *) CHR('K','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
644 { (unichar_t *) N_("Lang|Kannada"), NULL, 0, 0, (void *) CHR('K','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
645 { (unichar_t *) N_("Karachay"), NULL, 0, 0, (void *) CHR('K','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
646 { (unichar_t *) N_("Lang|Georgian"), NULL, 0, 0, (void *) CHR('K','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
647 { (unichar_t *) N_("Kawi"), NULL, 0, 0, (void *) CHR('K','A','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
648 { (unichar_t *) N_("Kazakh"), NULL, 0, 0, (void *) CHR('K','A','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
649 { (unichar_t *) NU_("Kadiwéu"), NULL, 0, 0, (void *) CHR('K','B','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
650 { (unichar_t *) N_("Makonde"), NULL, 0, 0, (void *) CHR('K','D','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
651 { (unichar_t *) N_("Kabuverdianu"), NULL, 0, 0, (void *) CHR('K','E','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
652 { (unichar_t *) N_("Kebena"), NULL, 0, 0, (void *) CHR('K','E','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
653 { (unichar_t *) N_("Kekchi"), NULL, 0, 0, (void *) CHR('K','E','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
654 { (unichar_t *) N_("Khutsuri Georgian"), NULL, 0, 0, (void *) CHR('K','G','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
655 { (unichar_t *) N_("Kube"), NULL, 0, 0, (void *) CHR('K','G','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
656 { (unichar_t *) N_("Khakass"), NULL, 0, 0, (void *) CHR('K','H','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
657 { (unichar_t *) N_("Khanty-Kazim"), NULL, 0, 0, (void *) CHR('K','H','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
658 { (unichar_t *) N_("Lang|Khmer"), NULL, 0, 0, (void *) CHR('K','H','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
659 { (unichar_t *) N_("Khanty-Shurishkar"), NULL, 0, 0, (void *) CHR('K','H','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
660 { (unichar_t *) N_("Khamti Shan"), NULL, 0, 0, (void *) CHR('K','H','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
661 { (unichar_t *) N_("Khanty-Vakhi"), NULL, 0, 0, (void *) CHR('K','H','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
662 { (unichar_t *) N_("Khowar"), NULL, 0, 0, (void *) CHR('K','H','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
663 { (unichar_t *) N_("Kikuyu"), NULL, 0, 0, (void *) CHR('K','I','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
664 { (unichar_t *) N_("Kirghiz"), NULL, 0, 0, (void *) CHR('K','I','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
665 { (unichar_t *) N_("Kisii"), NULL, 0, 0, (void *) CHR('K','I','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
666 { (unichar_t *) N_("Kirmanjki"), NULL, 0, 0, (void *) CHR('K','I','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
667 { (unichar_t *) N_("Southern Kiwai"), NULL, 0, 0, (void *) CHR('K','J','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
668 { (unichar_t *) N_("Khinalug"), NULL, 0, 0, (void *) CHR('K','J','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
669 { (unichar_t *) N_("Eastern Pwo Karen"), NULL, 0, 0, (void *) CHR('K','J','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
670 { (unichar_t *) N_("Bumthangkha"), NULL, 0, 0, (void *) CHR('K','J','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
671 { (unichar_t *) N_("Kokni"), NULL, 0, 0, (void *) CHR('K','K','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
672 { (unichar_t *) N_("Kalmyk"), NULL, 0, 0, (void *) CHR('K','L','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
673 { (unichar_t *) N_("Kamba"), NULL, 0, 0, (void *) CHR('K','M','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
674 { (unichar_t *) NU_("KĂąte"), NULL, 0, 0, (void *) CHR('K','M','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
675 { (unichar_t *) N_("Kumaoni"), NULL, 0, 0, (void *) CHR('K','M','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
676 { (unichar_t *) N_("Komo"), NULL, 0, 0, (void *) CHR('K','M','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
677 { (unichar_t *) N_("Komso"), NULL, 0, 0, (void *) CHR('K','M','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
678 { (unichar_t *) N_("Khorasani Turkic"), NULL, 0, 0, (void *) CHR('K','M','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
679 { (unichar_t *) N_("Kanuri"), NULL, 0, 0, (void *) CHR('K','N','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
680 { (unichar_t *) N_("Kodagu"), NULL, 0, 0, (void *) CHR('K','O','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
681 { (unichar_t *) N_("Korean Old Hangul"), NULL, 0, 0, (void *) CHR('K','O','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
682 { (unichar_t *) N_("Konkani"), NULL, 0, 0, (void *) CHR('K','O','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
683 { (unichar_t *) N_("Komi"), NULL, 0, 0, (void *) CHR('K','O','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
684 { (unichar_t *) N_("Kikongo"), NULL, 0, 0, (void *) CHR('K','O','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
685 { (unichar_t *) N_("Kongo"), NULL, 0, 0, (void *) CHR('K','O','N','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
686 { (unichar_t *) N_("Komi-Permyak"), NULL, 0, 0, (void *) CHR('K','O','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
687 { (unichar_t *) N_("Korean"), NULL, 0, 0, (void *) CHR('K','O','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
688 { (unichar_t *) N_("Kosraean"), NULL, 0, 0, (void *) CHR('K','O','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
689 { (unichar_t *) N_("Komi-Zyrian"), NULL, 0, 0, (void *) CHR('K','O','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
690 { (unichar_t *) N_("Kpelle"), NULL, 0, 0, (void *) CHR('K','P','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
691 { (unichar_t *) N_("Krio"), NULL, 0, 0, (void *) CHR('K','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
692 { (unichar_t *) N_("Karakalpak"), NULL, 0, 0, (void *) CHR('K','R','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
693 { (unichar_t *) N_("Karelian"), NULL, 0, 0, (void *) CHR('K','R','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
694 { (unichar_t *) N_("Karaim"), NULL, 0, 0, (void *) CHR('K','R','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
695 { (unichar_t *) N_("Karen"), NULL, 0, 0, (void *) CHR('K','R','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
696 { (unichar_t *) N_("Koorete"), NULL, 0, 0, (void *) CHR('K','R','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
697 { (unichar_t *) N_("Kashmiri"), NULL, 0, 0, (void *) CHR('K','S','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
698 { (unichar_t *) N_("Ripuarian"), NULL, 0, 0, (void *) CHR('K','S','H','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
699 { (unichar_t *) N_("Khasi"), NULL, 0, 0, (void *) CHR('K','S','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
700 { (unichar_t *) N_("Kildin Sami"), NULL, 0, 0, (void *) CHR('K','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
701 { (unichar_t *) N_("Khamyang"), NULL, 0, 0, (void *) CHR('K','S','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
702 { (unichar_t *) N_("S'gaw Karen"), NULL, 0, 0, (void *) CHR('K','S','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
703 { (unichar_t *) N_("Kuanyama"), NULL, 0, 0, (void *) CHR('K','U','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
704 { (unichar_t *) N_("Kui"), NULL, 0, 0, (void *) CHR('K','U','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
705 { (unichar_t *) N_("Kulvi"), NULL, 0, 0, (void *) CHR('K','U','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
706 { (unichar_t *) N_("Kumyk"), NULL, 0, 0, (void *) CHR('K','U','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
707 { (unichar_t *) N_("Kurdish"), NULL, 0, 0, (void *) CHR('K','U','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
708 { (unichar_t *) N_("Kurukh"), NULL, 0, 0, (void *) CHR('K','U','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
709 { (unichar_t *) N_("Kuy"), NULL, 0, 0, (void *) CHR('K','U','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
710 { (unichar_t *) N_("Geba Karen"), NULL, 0, 0, (void *) CHR('K','V','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
711 { (unichar_t *) N_("Kwak'wala"), NULL, 0, 0, (void *) CHR('K','W','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
712 { (unichar_t *) N_("Koryak"), NULL, 0, 0, (void *) CHR('K','Y','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
713 { (unichar_t *) N_("Western Kayah"), NULL, 0, 0, (void *) CHR('K','Y','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
714 { (unichar_t *) N_("Ladin"), NULL, 0, 0, (void *) CHR('L','A','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
715 { (unichar_t *) N_("Lahuli"), NULL, 0, 0, (void *) CHR('L','A','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
716 { (unichar_t *) N_("Lak"), NULL, 0, 0, (void *) CHR('L','A','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
717 { (unichar_t *) N_("Lambani"), NULL, 0, 0, (void *) CHR('L','A','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
718 { (unichar_t *) N_("Lang|Lao"), NULL, 0, 0, (void *) CHR('L','A','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
719 { (unichar_t *) N_("Lang|Latin"), NULL, 0, 0, (void *) CHR('L','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
720 { (unichar_t *) N_("Laz"), NULL, 0, 0, (void *) CHR('L','A','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
721 { (unichar_t *) N_("L-Cree"), NULL, 0, 0, (void *) CHR('L','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
722 { (unichar_t *) N_("Ladakhi"), NULL, 0, 0, (void *) CHR('L','D','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
723 { (unichar_t *) N_("Lelemi"), NULL, 0, 0, (void *) CHR('L','E','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
724 { (unichar_t *) N_("Lezgi"), NULL, 0, 0, (void *) CHR('L','E','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
725 { (unichar_t *) N_("Ligurian"), NULL, 0, 0, (void *) CHR('L','I','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
726 { (unichar_t *) N_("Limburgish"), NULL, 0, 0, (void *) CHR('L','I','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
727 { (unichar_t *) N_("Lingala"), NULL, 0, 0, (void *) CHR('L','I','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
728 { (unichar_t *) N_("Lang|Lisu"), NULL, 0, 0, (void *) CHR('L','I','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
729 { (unichar_t *) N_("Liv"), NULL, 0, 0, (void *) CHR('L','I','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
730 { (unichar_t *) N_("Lampung"), NULL, 0, 0, (void *) CHR('L','J','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
731 { (unichar_t *) N_("Laki"), NULL, 0, 0, (void *) CHR('L','K','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
732 { (unichar_t *) N_("Low Mari"), NULL, 0, 0, (void *) CHR('L','M','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
733 { (unichar_t *) N_("Lang|Limbu"), NULL, 0, 0, (void *) CHR('L','M','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
734 { (unichar_t *) N_("Lombard"), NULL, 0, 0, (void *) CHR('L','M','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
735 { (unichar_t *) N_("Lomwe"), NULL, 0, 0, (void *) CHR('L','M','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
736 { (unichar_t *) N_("Lang|Loma"), NULL, 0, 0, (void *) CHR('L','O','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
737 { (unichar_t *) N_("Lipo"), NULL, 0, 0, (void *) CHR('L','P','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
738 { (unichar_t *) N_("Luri"), NULL, 0, 0, (void *) CHR('L','R','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
739 { (unichar_t *) N_("Lower Sorbian"), NULL, 0, 0, (void *) CHR('L','S','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
740 { (unichar_t *) N_("Lule Sami"), NULL, 0, 0, (void *) CHR('L','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
741 { (unichar_t *) N_("Lithuanian"), NULL, 0, 0, (void *) CHR('L','T','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
742 { (unichar_t *) N_("Luxembourgish"), NULL, 0, 0, (void *) CHR('L','T','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
743 { (unichar_t *) N_("Luba-Lulua"), NULL, 0, 0, (void *) CHR('L','U','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
744 { (unichar_t *) N_("Luba-Katanga"), NULL, 0, 0, (void *) CHR('L','U','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
745 { (unichar_t *) N_("Ganda"), NULL, 0, 0, (void *) CHR('L','U','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
746 { (unichar_t *) N_("Luyia"), NULL, 0, 0, (void *) CHR('L','U','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
747 { (unichar_t *) N_("Luo"), NULL, 0, 0, (void *) CHR('L','U','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
748 { (unichar_t *) N_("Lushootseed"), NULL, 0, 0, (void *) CHR('L','U','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
749 { (unichar_t *) N_("Latvian"), NULL, 0, 0, (void *) CHR('L','V','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
750 { (unichar_t *) N_("Madura"), NULL, 0, 0, (void *) CHR('M','A','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
751 { (unichar_t *) N_("Magahi"), NULL, 0, 0, (void *) CHR('M','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
752 { (unichar_t *) N_("Marshallese"), NULL, 0, 0, (void *) CHR('M','A','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
753 { (unichar_t *) N_("Majang"), NULL, 0, 0, (void *) CHR('M','A','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
754 { (unichar_t *) N_("Makhuwa"), NULL, 0, 0, (void *) CHR('M','A','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
755 { (unichar_t *) N_("Malayalam Traditional"), NULL, 0, 0, (void *) CHR('M','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
756 { (unichar_t *) N_("Mam"), NULL, 0, 0, (void *) CHR('M','A','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
757 { (unichar_t *) N_("Mansi"), NULL, 0, 0, (void *) CHR('M','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
758 { (unichar_t *) N_("Mapudungun"), NULL, 0, 0, (void *) CHR('M','A','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
759 { (unichar_t *) N_("Marathi"), NULL, 0, 0, (void *) CHR('M','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
760 { (unichar_t *) N_("Marwari"), NULL, 0, 0, (void *) CHR('M','A','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
761 { (unichar_t *) N_("Mbundu"), NULL, 0, 0, (void *) CHR('M','B','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
762 { (unichar_t *) N_("Mbo"), NULL, 0, 0, (void *) CHR('M','B','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
763 { (unichar_t *) N_("Lang|Manchu"), NULL, 0, 0, (void *) CHR('M','C','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
764 { (unichar_t *) N_("Moose Cree"), NULL, 0, 0, (void *) CHR('M','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
765 { (unichar_t *) N_("Mende"), NULL, 0, 0, (void *) CHR('M','D','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
766 { (unichar_t *) N_("Mandar"), NULL, 0, 0, (void *) CHR('M','D','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
767 { (unichar_t *) N_("Me'en"), NULL, 0, 0, (void *) CHR('M','E','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
768 { (unichar_t *) N_("Meru"), NULL, 0, 0, (void *) CHR('M','E','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
769 { (unichar_t *) N_("Mano"), NULL, 0, 0, (void *) CHR('M','E','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
770 { (unichar_t *) N_("Pattani Malay"), NULL, 0, 0, (void *) CHR('M','F','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
771 { (unichar_t *) N_("Morisyen"), NULL, 0, 0, (void *) CHR('M','F','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
772 { (unichar_t *) N_("Minangkabau"), NULL, 0, 0, (void *) CHR('M','I','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
773 { (unichar_t *) N_("Mizo"), NULL, 0, 0, (void *) CHR('M','I','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
774 { (unichar_t *) N_("Macedonian"), NULL, 0, 0, (void *) CHR('M','K','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
775 { (unichar_t *) N_("Lang|Makasar"), NULL, 0, 0, (void *) CHR('M','K','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
776 { (unichar_t *) N_("Kituba"), NULL, 0, 0, (void *) CHR('M','K','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
777 { (unichar_t *) N_("Male"), NULL, 0, 0, (void *) CHR('M','L','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
778 { (unichar_t *) N_("Malagasy"), NULL, 0, 0, (void *) CHR('M','L','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
779 { (unichar_t *) N_("Malinke"), NULL, 0, 0, (void *) CHR('M','L','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
780 { (unichar_t *) N_("Malayalam Reformed"), NULL, 0, 0, (void *) CHR('M','L','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
781 { (unichar_t *) N_("Malay"), NULL, 0, 0, (void *) CHR('M','L','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
782 { (unichar_t *) N_("Mandinka"), NULL, 0, 0, (void *) CHR('M','N','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
783 { (unichar_t *) N_("Lang|Mongolian"), NULL, 0, 0, (void *) CHR('M','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
784 { (unichar_t *) N_("Manipuri"), NULL, 0, 0, (void *) CHR('M','N','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
785 { (unichar_t *) N_("Maninka"), NULL, 0, 0, (void *) CHR('M','N','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
786 { (unichar_t *) N_("Manx"), NULL, 0, 0, (void *) CHR('M','N','X',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
787 { (unichar_t *) N_("Mohawk"), NULL, 0, 0, (void *) CHR('M','O','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
788 { (unichar_t *) N_("Moksha"), NULL, 0, 0, (void *) CHR('M','O','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
789 { (unichar_t *) N_("Moldavian"), NULL, 0, 0, (void *) CHR('M','O','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
790 { (unichar_t *) N_("Mon"), NULL, 0, 0, (void *) CHR('M','O','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
791 { (unichar_t *) N_("Thailand Mon"), NULL, 0, 0, (void *) CHR('M','O','N','T'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
792 { (unichar_t *) N_("Moroccan"), NULL, 0, 0, (void *) CHR('M','O','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
793 { (unichar_t *) N_("Mossi"), NULL, 0, 0, (void *) CHR('M','O','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
794 { (unichar_t *) N_("Maori"), NULL, 0, 0, (void *) CHR('M','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
795 { (unichar_t *) N_("Maithili"), NULL, 0, 0, (void *) CHR('M','T','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
796 { (unichar_t *) N_("Maltese"), NULL, 0, 0, (void *) CHR('M','T','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
797 { (unichar_t *) N_("Mundari"), NULL, 0, 0, (void *) CHR('M','U','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
798 { (unichar_t *) N_("Muscogee"), NULL, 0, 0, (void *) CHR('M','U','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
799 { (unichar_t *) N_("Mirandese"), NULL, 0, 0, (void *) CHR('M','W','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
800 { (unichar_t *) N_("Hmong Daw"), NULL, 0, 0, (void *) CHR('M','W','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
801 { (unichar_t *) N_("Lang|Mayan"), NULL, 0, 0, (void *) CHR('M','Y','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
802 { (unichar_t *) N_("Mazanderani"), NULL, 0, 0, (void *) CHR('M','Z','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
803 { (unichar_t *) N_("Naga-Assamese"), NULL, 0, 0, (void *) CHR('N','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
804 { (unichar_t *) N_("Nahuatl"), NULL, 0, 0, (void *) CHR('N','A','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
805 { (unichar_t *) N_("Nanai"), NULL, 0, 0, (void *) CHR('N','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
806 { (unichar_t *) N_("Neapolitan"), NULL, 0, 0, (void *) CHR('N','A','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
807 { (unichar_t *) N_("Naskapi"), NULL, 0, 0, (void *) CHR('N','A','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
808 { (unichar_t *) N_("Nauruan"), NULL, 0, 0, (void *) CHR('N','A','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
809 { (unichar_t *) N_("Navajo"), NULL, 0, 0, (void *) CHR('N','A','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
810 { (unichar_t *) N_("N-Cree"), NULL, 0, 0, (void *) CHR('N','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
811 { (unichar_t *) N_("Ndebele"), NULL, 0, 0, (void *) CHR('N','D','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
812 { (unichar_t *) N_("Ndau"), NULL, 0, 0, (void *) CHR('N','D','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
813 { (unichar_t *) N_("Ndonga"), NULL, 0, 0, (void *) CHR('N','D','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
814 { (unichar_t *) N_("Low Saxon"), NULL, 0, 0, (void *) CHR('N','D','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
815 { (unichar_t *) N_("Nepali"), NULL, 0, 0, (void *) CHR('N','E','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
816 { (unichar_t *) N_("Newari"), NULL, 0, 0, (void *) CHR('N','E','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
817 { (unichar_t *) N_("Ngbaka"), NULL, 0, 0, (void *) CHR('N','G','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
818 { (unichar_t *) N_("Nagari"), NULL, 0, 0, (void *) CHR('N','G','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
819 { (unichar_t *) N_("Norway House Cree"), NULL, 0, 0, (void *) CHR('N','H','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
820 { (unichar_t *) N_("Nisi"), NULL, 0, 0, (void *) CHR('N','I','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
821 { (unichar_t *) N_("Niuean"), NULL, 0, 0, (void *) CHR('N','I','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
822 { (unichar_t *) N_("Nyankole"), NULL, 0, 0, (void *) CHR('N','K','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
823 { (unichar_t *) N_("N'Ko"), NULL, 0, 0, (void *) CHR('N','K','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
824 { (unichar_t *) N_("Dutch"), NULL, 0, 0, (void *) CHR('N','L','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
825 { (unichar_t *) N_("Nimadi"), NULL, 0, 0, (void *) CHR('N','O','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
826 { (unichar_t *) N_("Nogai"), NULL, 0, 0, (void *) CHR('N','O','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
827 { (unichar_t *) N_("Numanggang"), NULL, 0, 0, (void *) CHR('N','O','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
828 { (unichar_t *) N_("Norwegian"), NULL, 0, 0, (void *) CHR('N','O','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
829 { (unichar_t *) N_("Novial"), NULL, 0, 0, (void *) CHR('N','O','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
830 { (unichar_t *) N_("Northern Sami"), NULL, 0, 0, (void *) CHR('N','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
831 { (unichar_t *) N_("Northern Sotho"), NULL, 0, 0, (void *) CHR('N','S','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
832 { (unichar_t *) N_("Northern Tai"), NULL, 0, 0, (void *) CHR('N','T','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
833 { (unichar_t *) N_("Esperanto"), NULL, 0, 0, (void *) CHR('N','T','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
834 { (unichar_t *) N_("Nuu-chah-nulth"), NULL, 0, 0, (void *) CHR('N','U','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
835 { (unichar_t *) N_("Nyamwezi"), NULL, 0, 0, (void *) CHR('N','Y','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
836 { (unichar_t *) N_("Norwegian Nynorsk"), NULL, 0, 0, (void *) CHR('N','Y','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
837 { (unichar_t *) N_("Mbembe Tigon"), NULL, 0, 0, (void *) CHR('N','Z','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
838 { (unichar_t *) N_("Occitan"), NULL, 0, 0, (void *) CHR('O','C','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
839 { (unichar_t *) N_("Oji-Cree"), NULL, 0, 0, (void *) CHR('O','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
840 { (unichar_t *) N_("Ojibway"), NULL, 0, 0, (void *) CHR('O','J','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
841 { (unichar_t *) N_("Oneida"), NULL, 0, 0, (void *) CHR('O','N','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
842 { (unichar_t *) N_("Onondaga"), NULL, 0, 0, (void *) CHR('O','N','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
843 { (unichar_t *) N_("Lang|Odia"), NULL, 0, 0, (void *) CHR('O','R','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
844 { (unichar_t *) N_("Oromo"), NULL, 0, 0, (void *) CHR('O','R','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
845 { (unichar_t *) N_("Ossetian"), NULL, 0, 0, (void *) CHR('O','S','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
846 { (unichar_t *) N_("Palestinian Aramaic"), NULL, 0, 0, (void *) CHR('P','A','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
847 { (unichar_t *) N_("Pangasinan"), NULL, 0, 0, (void *) CHR('P','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
848 { (unichar_t *) N_("Pali"), NULL, 0, 0, (void *) CHR('P','A','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
849 { (unichar_t *) N_("Pampangan"), NULL, 0, 0, (void *) CHR('P','A','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
850 { (unichar_t *) N_("Punjabi"), NULL, 0, 0, (void *) CHR('P','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
851 { (unichar_t *) N_("Palpa"), NULL, 0, 0, (void *) CHR('P','A','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
852 { (unichar_t *) N_("Papiamentu"), NULL, 0, 0, (void *) CHR('P','A','P','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
853 { (unichar_t *) N_("Pashto"), NULL, 0, 0, (void *) CHR('P','A','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
854 { (unichar_t *) N_("Palauan"), NULL, 0, 0, (void *) CHR('P','A','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
855 { (unichar_t *) N_("Bouyei"), NULL, 0, 0, (void *) CHR('P','C','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
856 { (unichar_t *) N_("Picard"), NULL, 0, 0, (void *) CHR('P','C','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
857 { (unichar_t *) N_("Pennsylvania German"), NULL, 0, 0, (void *) CHR('P','D','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
858 { (unichar_t *) N_("Polytonic Greek"), NULL, 0, 0, (void *) CHR('P','G','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
859 { (unichar_t *) N_("Phake"), NULL, 0, 0, (void *) CHR('P','H','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
860 { (unichar_t *) N_("Norfolk"), NULL, 0, 0, (void *) CHR('P','I','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
861 { (unichar_t *) N_("Filipino"), NULL, 0, 0, (void *) CHR('P','I','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
862 { (unichar_t *) N_("Palaung"), NULL, 0, 0, (void *) CHR('P','L','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
863 { (unichar_t *) NU_("PilagĂĄ"), NULL, 0, 0, (void *) CHR('P','L','G','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
864 { (unichar_t *) N_("Polish"), NULL, 0, 0, (void *) CHR('P','L','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
865 { (unichar_t *) N_("Piemontese"), NULL, 0, 0, (void *) CHR('P','M','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
866 { (unichar_t *) N_("Western Panjabi"), NULL, 0, 0, (void *) CHR('P','N','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
867 { (unichar_t *) N_("Pocomchi"), NULL, 0, 0, (void *) CHR('P','O','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
868 { (unichar_t *) N_("Pohnpeian"), NULL, 0, 0, (void *) CHR('P','O','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
869 { (unichar_t *) NU_("Provençal / Old Provençal"), NULL, 0, 0, (void *) CHR('P','R','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
870 { (unichar_t *) N_("Portuguese"), NULL, 0, 0, (void *) CHR('P','T','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
871 { (unichar_t *) N_("Western Pwo Karen"), NULL, 0, 0, (void *) CHR('P','W','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
872 { (unichar_t *) N_("Chin"), NULL, 0, 0, (void *) CHR('Q','I','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
873 { (unichar_t *) N_("K'iche'"), NULL, 0, 0, (void *) CHR('Q','U','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
874 { (unichar_t *) N_("Quechua (Bolivia)"), NULL, 0, 0, (void *) CHR('Q','U','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
875 { (unichar_t *) N_("Quechua"), NULL, 0, 0, (void *) CHR('Q','U','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
876 { (unichar_t *) N_("Quechua (Ecuador)"), NULL, 0, 0, (void *) CHR('Q','V','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
877 { (unichar_t *) N_("Quechua (Peru)"), NULL, 0, 0, (void *) CHR('Q','W','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
878 { (unichar_t *) N_("Rajasthani"), NULL, 0, 0, (void *) CHR('R','A','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
879 { (unichar_t *) N_("Rarotongan"), NULL, 0, 0, (void *) CHR('R','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
880 { (unichar_t *) N_("Russian Buriat"), NULL, 0, 0, (void *) CHR('R','B','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
881 { (unichar_t *) N_("R-Cree"), NULL, 0, 0, (void *) CHR('R','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
882 { (unichar_t *) N_("Rejang"), NULL, 0, 0, (void *) CHR('R','E','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
883 { (unichar_t *) N_("Riang"), NULL, 0, 0, (void *) CHR('R','I','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
884 { (unichar_t *) N_("Rohingya"), NULL, 0, 0, (void *) CHR('R','H','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
885 { (unichar_t *) N_("Tarifit"), NULL, 0, 0, (void *) CHR('R','I','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
886 { (unichar_t *) N_("Ritarungo"), NULL, 0, 0, (void *) CHR('R','I','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
887 { (unichar_t *) N_("Arakwal"), NULL, 0, 0, (void *) CHR('R','K','W',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
888 { (unichar_t *) N_("Romansh"), NULL, 0, 0, (void *) CHR('R','M','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
889 { (unichar_t *) N_("Vlax Romani"), NULL, 0, 0, (void *) CHR('R','M','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
890 { (unichar_t *) N_("Romanian"), NULL, 0, 0, (void *) CHR('R','O','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
891 { (unichar_t *) N_("Romany"), NULL, 0, 0, (void *) CHR('R','O','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
892 { (unichar_t *) N_("Rusyn"), NULL, 0, 0, (void *) CHR('R','S','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
893 { (unichar_t *) N_("Rotuman"), NULL, 0, 0, (void *) CHR('R','T','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
894 { (unichar_t *) N_("Kinyarwanda"), NULL, 0, 0, (void *) CHR('R','U','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
895 { (unichar_t *) N_("Rundi"), NULL, 0, 0, (void *) CHR('R','U','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
896 { (unichar_t *) N_("Aromanian"), NULL, 0, 0, (void *) CHR('R','U','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
897 { (unichar_t *) N_("Russian"), NULL, 0, 0, (void *) CHR('R','U','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
898 { (unichar_t *) N_("Sadri"), NULL, 0, 0, (void *) CHR('S','A','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
899 { (unichar_t *) N_("Sanskrit"), NULL, 0, 0, (void *) CHR('S','A','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
900 { (unichar_t *) N_("Sasak"), NULL, 0, 0, (void *) CHR('S','A','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
901 { (unichar_t *) N_("Santali"), NULL, 0, 0, (void *) CHR('S','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
902 { (unichar_t *) N_("Sayisi"), NULL, 0, 0, (void *) CHR('S','A','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
903 { (unichar_t *) N_("Sicilian"), NULL, 0, 0, (void *) CHR('S','C','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
904 { (unichar_t *) N_("Scots"), NULL, 0, 0, (void *) CHR('S','C','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
905 { (unichar_t *) N_("North Slavey"), NULL, 0, 0, (void *) CHR('S','C','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
906 { (unichar_t *) N_("Seneca"), NULL, 0, 0, (void *) CHR('S','E','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
907 { (unichar_t *) N_("Sekota"), NULL, 0, 0, (void *) CHR('S','E','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
908 { (unichar_t *) N_("Selkup"), NULL, 0, 0, (void *) CHR('S','E','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
909 { (unichar_t *) N_("Small Flowery Miao"), NULL, 0, 0, (void *) CHR('S','F','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
910 { (unichar_t *) N_("Old Irish"), NULL, 0, 0, (void *) CHR('S','G','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
911 { (unichar_t *) N_("Sango"), NULL, 0, 0, (void *) CHR('S','G','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
912 { (unichar_t *) N_("Samogitian"), NULL, 0, 0, (void *) CHR('S','G','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
913 { (unichar_t *) N_("Tachelhit"), NULL, 0, 0, (void *) CHR('S','H','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
914 { (unichar_t *) N_("Shan"), NULL, 0, 0, (void *) CHR('S','H','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
915 { (unichar_t *) N_("Sibe"), NULL, 0, 0, (void *) CHR('S','I','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
916 { (unichar_t *) N_("Sidamo"), NULL, 0, 0, (void *) CHR('S','I','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
917 { (unichar_t *) N_("Silte Gurage"), NULL, 0, 0, (void *) CHR('S','I','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
918 { (unichar_t *) N_("Epena"), NULL, 0, 0, (void *) CHR('S','J','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
919 { (unichar_t *) N_("Pite Sami"), NULL, 0, 0, (void *) CHR('S','J','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
920 { (unichar_t *) N_("Ume Sami"), NULL, 0, 0, (void *) CHR('S','J','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
921 { (unichar_t *) N_("Skolt Sami"), NULL, 0, 0, (void *) CHR('S','K','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
922 { (unichar_t *) N_("Slovak"), NULL, 0, 0, (void *) CHR('S','K','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
923 { (unichar_t *) N_("Slavey"), NULL, 0, 0, (void *) CHR('S','L','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
924 { (unichar_t *) N_("Slovenian"), NULL, 0, 0, (void *) CHR('S','L','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
925 { (unichar_t *) N_("Somali"), NULL, 0, 0, (void *) CHR('S','M','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
926 { (unichar_t *) N_("Samoan"), NULL, 0, 0, (void *) CHR('S','M','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
927 { (unichar_t *) N_("Sena"), NULL, 0, 0, (void *) CHR('S','N','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
928 { (unichar_t *) N_("Shona"), NULL, 0, 0, (void *) CHR('S','N','A','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
929 { (unichar_t *) N_("Sindhi"), NULL, 0, 0, (void *) CHR('S','N','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
930 { (unichar_t *) N_("Lang|Sinhala"), NULL, 0, 0, (void *) CHR('S','N','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
931 { (unichar_t *) N_("Soninke"), NULL, 0, 0, (void *) CHR('S','N','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
932 { (unichar_t *) N_("Sodo Gurage"), NULL, 0, 0, (void *) CHR('S','O','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
933 { (unichar_t *) N_("Songe"), NULL, 0, 0, (void *) CHR('S','O','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
934 { (unichar_t *) N_("Southern Sotho"), NULL, 0, 0, (void *) CHR('S','O','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
935 { (unichar_t *) N_("Albanian"), NULL, 0, 0, (void *) CHR('S','Q','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
936 { (unichar_t *) N_("Serbian"), NULL, 0, 0, (void *) CHR('S','R','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
937 { (unichar_t *) N_("Sardinian"), NULL, 0, 0, (void *) CHR('S','R','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
938 { (unichar_t *) N_("Saraiki"), NULL, 0, 0, (void *) CHR('S','R','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
939 { (unichar_t *) N_("Serer"), NULL, 0, 0, (void *) CHR('S','R','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
940 { (unichar_t *) N_("South Slavey"), NULL, 0, 0, (void *) CHR('S','S','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
941 { (unichar_t *) N_("Southern Sami"), NULL, 0, 0, (void *) CHR('S','S','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
942 { (unichar_t *) N_("Straits Salish"), NULL, 0, 0, (void *) CHR('S','T','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
943 { (unichar_t *) N_("Saterland Frisian"), NULL, 0, 0, (void *) CHR('S','T','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
944 { (unichar_t *) N_("Sukuma"), NULL, 0, 0, (void *) CHR('S','U','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
945 { (unichar_t *) N_("Lang|Sundanese"), NULL, 0, 0, (void *) CHR('S','U','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
946 { (unichar_t *) N_("Suri"), NULL, 0, 0, (void *) CHR('S','U','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
947 { (unichar_t *) N_("Svan"), NULL, 0, 0, (void *) CHR('S','V','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
948 { (unichar_t *) N_("Swedish"), NULL, 0, 0, (void *) CHR('S','V','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
949 { (unichar_t *) N_("Swadaya Aramaic"), NULL, 0, 0, (void *) CHR('S','W','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
950 { (unichar_t *) N_("Swahili"), NULL, 0, 0, (void *) CHR('S','W','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
951 { (unichar_t *) N_("Swati"), NULL, 0, 0, (void *) CHR('S','W','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
952 { (unichar_t *) N_("Sutu"), NULL, 0, 0, (void *) CHR('S','X','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
953 { (unichar_t *) N_("Upper Saxon"), NULL, 0, 0, (void *) CHR('S','X','U',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
954 { (unichar_t *) N_("Sylheti"), NULL, 0, 0, (void *) CHR('S','Y','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
955 { (unichar_t *) N_("Lang|Syriac"), NULL, 0, 0, (void *) CHR('S','Y','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
956 { (unichar_t *) N_("Syriac (Estrangela)"), NULL, 0, 0, (void *) CHR('S','Y','R','E'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
957 { (unichar_t *) N_("Syriac (Western script)"), NULL, 0, 0, (void *) CHR('S','Y','R','J'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
958 { (unichar_t *) N_("Syriac (Eastern script)"), NULL, 0, 0, (void *) CHR('S','Y','R','N'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
959 { (unichar_t *) N_("Silesian"), NULL, 0, 0, (void *) CHR('S','Z','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
960 { (unichar_t *) N_("Tabasaran"), NULL, 0, 0, (void *) CHR('T','A','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
961 { (unichar_t *) N_("Tajiki"), NULL, 0, 0, (void *) CHR('T','A','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
962 { (unichar_t *) N_("Lang|Tamil"), NULL, 0, 0, (void *) CHR('T','A','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
963 { (unichar_t *) N_("Tamasheq"), NULL, 0, 0, (void *) CHR('T','A','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
964 { (unichar_t *) N_("Tatar"), NULL, 0, 0, (void *) CHR('T','A','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
965 { (unichar_t *) N_("Tobo"), NULL, 0, 0, (void *) CHR('T','B','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
966 { (unichar_t *) N_("TH-Cree"), NULL, 0, 0, (void *) CHR('T','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
967 { (unichar_t *) NU_("EmberĂĄ-TadĂł"), NULL, 0, 0, (void *) CHR('T','D','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
968 { (unichar_t *) N_("Dehong Dai"), NULL, 0, 0, (void *) CHR('T','D','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
969 { (unichar_t *) N_("Lang|Telugu"), NULL, 0, 0, (void *) CHR('T','E','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
970 { (unichar_t *) N_("Tetum"), NULL, 0, 0, (void *) CHR('T','E','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
971 { (unichar_t *) N_("Lang|Tagalog"), NULL, 0, 0, (void *) CHR('T','G','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
972 { (unichar_t *) N_("Tongan"), NULL, 0, 0, (void *) CHR('T','G','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
973 { (unichar_t *) N_("Tigre"), NULL, 0, 0, (void *) CHR('T','G','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
974 { (unichar_t *) N_("Tigrinya"), NULL, 0, 0, (void *) CHR('T','G','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
975 { (unichar_t *) N_("Lang|Thai"), NULL, 0, 0, (void *) CHR('T','H','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
976 { (unichar_t *) N_("Tahitian"), NULL, 0, 0, (void *) CHR('T','H','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
977 { (unichar_t *) N_("Thompson"), NULL, 0, 0, (void *) CHR('T','H','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
978 { (unichar_t *) N_("Tahaggart Tamahaq"), NULL, 0, 0, (void *) CHR('T','H','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
979 { (unichar_t *) N_("Tayart Tamajeq"), NULL, 0, 0, (void *) CHR('T','H','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
980 { (unichar_t *) N_("Lang|Tibetan"), NULL, 0, 0, (void *) CHR('T','I','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
981 { (unichar_t *) N_("Tiv"), NULL, 0, 0, (void *) CHR('T','I','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
982 { (unichar_t *) N_("Tai Laing"), NULL, 0, 0, (void *) CHR('T','J','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
983 { (unichar_t *) N_("Turkmen"), NULL, 0, 0, (void *) CHR('T','K','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
984 { (unichar_t *) N_("Tlingit"), NULL, 0, 0, (void *) CHR('T','L','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
985 { (unichar_t *) N_("Tamashek"), NULL, 0, 0, (void *) CHR('T','M','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
986 { (unichar_t *) N_("Talysh"), NULL, 0, 0, (void *) CHR('T','L','Y',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
987 { (unichar_t *) N_("Temne"), NULL, 0, 0, (void *) CHR('T','M','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
988 { (unichar_t *) N_("Tswana"), NULL, 0, 0, (void *) CHR('T','N','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
989 { (unichar_t *) N_("Tundra Enets"), NULL, 0, 0, (void *) CHR('T','N','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
990 { (unichar_t *) N_("Tonga"), NULL, 0, 0, (void *) CHR('T','N','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
991 { (unichar_t *) N_("Todo"), NULL, 0, 0, (void *) CHR('T','O','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
992 { (unichar_t *) N_("Toma"), NULL, 0, 0, (void *) CHR('T','O','D','0'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
993 { (unichar_t *) N_("Tok Pisin"), NULL, 0, 0, (void *) CHR('T','P','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
994 { (unichar_t *) N_("Turkish"), NULL, 0, 0, (void *) CHR('T','R','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
995 { (unichar_t *) N_("Tsonga"), NULL, 0, 0, (void *) CHR('T','S','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
996 { (unichar_t *) N_("Tshangla"), NULL, 0, 0, (void *) CHR('T','S','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
997 { (unichar_t *) N_("Tawallammat Tamajaq"), NULL, 0, 0, (void *) CHR('T','T','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
998 { (unichar_t *) N_("Turoyo Aramaic"), NULL, 0, 0, (void *) CHR('T','U','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
999 { (unichar_t *) N_("Tulu"), NULL, 0, 0, (void *) CHR('T','U','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1000 { (unichar_t *) N_("Tumbuka"), NULL, 0, 0, (void *) CHR('T','U','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1001 { (unichar_t *) N_("Tuscarora"), NULL, 0, 0, (void *) CHR('T','U','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1002 { (unichar_t *) N_("Tuvin"), NULL, 0, 0, (void *) CHR('T','U','V',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1003 { (unichar_t *) N_("Tuvalu"), NULL, 0, 0, (void *) CHR('T','V','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1004 { (unichar_t *) N_("Twi"), NULL, 0, 0, (void *) CHR('T','W','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1005 { (unichar_t *) NU_("TĂ y"), NULL, 0, 0, (void *) CHR('T','Y','Z',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1006 { (unichar_t *) N_("Tamazight"), NULL, 0, 0, (void *) CHR('T','Z','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1007 { (unichar_t *) N_("Tzotzil"), NULL, 0, 0, (void *) CHR('T','Z','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1008 { (unichar_t *) N_("Udi"), NULL, 0, 0, (void *) CHR('U','D','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1009 { (unichar_t *) N_("Udmurt"), NULL, 0, 0, (void *) CHR('U','D','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1010 { (unichar_t *) N_("Ukrainian"), NULL, 0, 0, (void *) CHR('U','K','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1011 { (unichar_t *) N_("Umbundu"), NULL, 0, 0, (void *) CHR('U','M','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1012 { (unichar_t *) N_("Uralic Phonetic Alphabet"), NULL, 0, 0, (void *) CHR('U','P','P','H'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1013 { (unichar_t *) N_("Urdu"), NULL, 0, 0, (void *) CHR('U','R','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1014 { (unichar_t *) N_("Upper Sorbian"), NULL, 0, 0, (void *) CHR('U','S','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1015 { (unichar_t *) N_("Uyghur"), NULL, 0, 0, (void *) CHR('U','Y','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1016 { (unichar_t *) N_("Uzbek"), NULL, 0, 0, (void *) CHR('U','Z','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1017 { (unichar_t *) N_("Venetian"), NULL, 0, 0, (void *) CHR('V','E','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1018 { (unichar_t *) N_("Venda"), NULL, 0, 0, (void *) CHR('V','E','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1019 { (unichar_t *) N_("Vietnamese"), NULL, 0, 0, (void *) CHR('V','I','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1020 { (unichar_t *) NU_("VolapĂŒk"), NULL, 0, 0, (void *) CHR('V','O','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1021 { (unichar_t *) NU_("VÔro"), NULL, 0, 0, (void *) CHR('V','R','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1022 { (unichar_t *) N_("Wa"), NULL, 0, 0, (void *) CHR('W','A',' ',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1023 { (unichar_t *) N_("Wagdi"), NULL, 0, 0, (void *) CHR('W','A','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1024 { (unichar_t *) N_("Waray-Waray"), NULL, 0, 0, (void *) CHR('W','A','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1025 { (unichar_t *) N_("Wakhi"), NULL, 0, 0, (void *) CHR('W','B','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1026 { (unichar_t *) N_("Waci Gbe"), NULL, 0, 0, (void *) CHR('W','C','I',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1027 { (unichar_t *) N_("West-Cree"), NULL, 0, 0, (void *) CHR('W','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1028 { (unichar_t *) N_("Wendat"), NULL, 0, 0, (void *) CHR('W','D','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1029 { (unichar_t *) N_("Welsh"), NULL, 0, 0, (void *) CHR('W','E','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1030 { (unichar_t *) N_("Wolof"), NULL, 0, 0, (void *) CHR('W','L','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1031 { (unichar_t *) N_("Walloon"), NULL, 0, 0, (void *) CHR('W','L','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1032 { (unichar_t *) N_("Mewati"), NULL, 0, 0, (void *) CHR('W','T','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1033 { (unichar_t *) N_("Wyandot"), NULL, 0, 0, (void *) CHR('W','Y','N',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1034 { (unichar_t *) NU_("LĂŒ"), NULL, 0, 0, (void *) CHR('X','B','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1035 { (unichar_t *) N_("Xhosa"), NULL, 0, 0, (void *) CHR('X','H','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1036 { (unichar_t *) N_("Minjangbal"), NULL, 0, 0, (void *) CHR('X','J','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1037 { (unichar_t *) N_("Khengkha"), NULL, 0, 0, (void *) CHR('X','K','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1038 { (unichar_t *) N_("Soga"), NULL, 0, 0, (void *) CHR('X','O','G',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1039 { (unichar_t *) N_("Kpelle (Liberia)"), NULL, 0, 0, (void *) CHR('X','P','E',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1040 { (unichar_t *) N_("Bette Kuruma"), NULL, 0, 0, (void *) CHR('X','U','B',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1041 { (unichar_t *) N_("Jennu Kuruma"), NULL, 0, 0, (void *) CHR('X','U','J',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1042 { (unichar_t *) N_("Sakha"), NULL, 0, 0, (void *) CHR('Y','A','K',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1043 { (unichar_t *) N_("Yao"), NULL, 0, 0, (void *) CHR('Y','A','O',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1044 { (unichar_t *) N_("Yapese"), NULL, 0, 0, (void *) CHR('Y','A','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1045 { (unichar_t *) N_("Yoruba"), NULL, 0, 0, (void *) CHR('Y','B','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1046 { (unichar_t *) N_("Y-Cree"), NULL, 0, 0, (void *) CHR('Y','C','R',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1047 { (unichar_t *) N_("Gepo"), NULL, 0, 0, (void *) CHR('Y','G','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1048 { (unichar_t *) N_("Yi Classic"), NULL, 0, 0, (void *) CHR('Y','I','C',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1049 { (unichar_t *) N_("Yi Modern"), NULL, 0, 0, (void *) CHR('Y','I','M',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1050 { (unichar_t *) N_("Aluo"), NULL, 0, 0, (void *) CHR('Y','N','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1051 { (unichar_t *) N_("Havasupai-Walapai-Yavapai"), NULL, 0, 0, (void *) CHR('Y','U','F',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1052 { (unichar_t *) N_("Wuding-Luquan Yi"), NULL, 0, 0, (void *) CHR('Y','W','Q',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1053 { (unichar_t *) N_("Zealandic"), NULL, 0, 0, (void *) CHR('Z','E','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1054 { (unichar_t *) N_("Standard Moroccan Tamazight"), NULL, 0, 0, (void *) CHR('Z','G','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1055 { (unichar_t *) N_("Zhuang"), NULL, 0, 0, (void *) CHR('Z','H','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1056 { (unichar_t *) N_("Chinese, Traditional, Hong Kong SAR"), NULL, 0, 0, (void *) CHR('Z','H','H',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1057 { (unichar_t *) N_("Chinese, Phonetic"), NULL, 0, 0, (void *) CHR('Z','H','P',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1058 { (unichar_t *) N_("Chinese, Simplified"), NULL, 0, 0, (void *) CHR('Z','H','S',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1059 { (unichar_t *) N_("Chinese, Traditional"), NULL, 0, 0, (void *) CHR('Z','H','T',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1060 { (unichar_t *) N_("Chinese, Traditional, Macao SAR"), NULL, 0, 0, (void *) CHR('Z','H','T','M'), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1061 { (unichar_t *) N_("Zande"), NULL, 0, 0, (void *) CHR('Z','N','D',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1062 { (unichar_t *) N_("Zulu"), NULL, 0, 0, (void *) CHR('Z','U','L',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1063 { (unichar_t *) N_("Zazaki"), NULL, 0, 0, (void *) CHR('Z','Z','A',' '), NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
1064 GTEXTINFO_EMPTY
1065 };
1066
1067 static char *LK_GTKLangsDlg(GGadget *, int r, int c);
1068 static char *LK_ScriptsDlg(GGadget *, int r, int c);
1069 static struct col_init scriptci[] = {
1070 /* GT: English uses "script" to mean a general writing system (latin, greek, kanji) */
1071 /* GT: and the cursive handwriting style. Here we mean the general writing system. */
1072 { me_stringchoicetag , NULL, scripts, NULL, N_("writing system|Script") },
1073 { me_funcedit, LK_GTKLangsDlg, NULL, NULL, N_("Language(s)") },
1074 COL_INIT_EMPTY
1075 };
1076 static struct col_init featureci[] = {
1077 { me_stringchoicetrans , NULL, NULL, NULL, N_("Feature") },
1078 { me_funcedit, LK_ScriptsDlg, NULL, NULL, N_("Script(s) & Language(s)") },
1079 COL_INIT_EMPTY
1080 };
1081
1082 int cmp_item_by_name(const void *a, const void *b) {
1083 /* TODO: strcmp() doesn't consider linguistic comparison, e.g. putting
1084 accented and non-accented character together. Consider using
1085 g_utf8_collate() with an appropriate locale. */
1086 int res = strcmp((const char *)((const GTextInfo *)a)->text,
1087 (const char *)((const GTextInfo *)b)->text);
1088 return res;
1089 }
1090
1091 void LookupUIInit(void) {
1092 static int done = false;
1093 int i, j;
1094 static GTextInfo *needswork[] = {
1095 scripts, languages, gpos_lookuptypes, gsub_lookuptypes,
1096 NULL
1097 };
1098
1099 if ( done )
1100 return;
1101 done = true;
1102 for ( j=0; needswork[j]!=NULL; ++j ) {
1103 for ( i=0; needswork[j][i].text!=NULL || needswork[j][i].line; ++i )
1104 if ( needswork[j][i].text!=NULL )
1105 needswork[j][i].text = (unichar_t *) S_((char *) needswork[j][i].text);
1106 }
1107
1108 /* Sort scripts and languages by localized name */
1109 size_t n_scripts = sizeof(scripts) / sizeof(scripts[0]) - 1;
1110 qsort(scripts, n_scripts, sizeof(GTextInfo), cmp_item_by_name);
1111 size_t n_languages = sizeof(languages) / sizeof(languages[0]) - 1;
1112 qsort(languages, n_languages, sizeof(GTextInfo), cmp_item_by_name);
1113
1114 LookupInit();
1115
1116 featureci[0].title = S_(featureci[0].title);
1117 featureci[1].title = S_(featureci[1].title);
1118 scriptci[0].title = S_(scriptci[0].title);
1119 scriptci[1].title = S_(scriptci[1].title);
1120 }
1121
1122 #define CID_LookupType 1000
1123 #define CID_LookupFeatures 1001
1124 #define CID_Lookup_R2L 1002
1125 #define CID_Lookup_IgnBase 1003
1126 #define CID_Lookup_IgnLig 1004
1127 #define CID_Lookup_IgnMark 1005
1128 #define CID_Lookup_ProcessMark 1006
1129 #define CID_LookupName 1007
1130 #define CID_LookupAfm 1008
1131 #define CID_OK 1009
1132 #define CID_Cancel 1010
1133 #define CID_Lookup_ProcessSet 1011
1134
1135 #define CID_FeatureScripts 1020
1136 #define CID_ShowAnchors 1021
1137
1138 struct lookup_dlg {
1139 OTLookup *orig;
1140 SplineFont *sf;
1141 GWindow gw, scriptgw;
1142 int isgpos;
1143 int done, scriptdone, name_has_been_set;
1144 int ok;
1145 char *scriptret;
1146 };
1147
1148 static char *LK_GTKLangsDlg(GGadget *g, int r, int c) {
1149 LanguageRec lang_recs[sizeof(languages) / sizeof(languages[0])];
1150 int rows;
1151 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1152 char *langstr = strings[2*r+c].u.md_str;
1153
1154 for (int i=0; i < sizeof(languages) / sizeof(languages[0]); ++i ) {
1155 lang_recs[i].name = (const char*)languages[i].text;
1156 lang_recs[i].tag = (uint32_t)(intptr_t)languages[i].userdata;
1157 }
1158
1159 return language_list_dialog(GGadgetGetWindow(g), lang_recs, langstr);
1160 }
1161
1162 static void LK_NewScript(GGadget *g,int row) {
1163 int rows;
1164 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1165 /* What's a good default lang list for a new script? */
1166 /* well it depends on what the script is, but we don't know that yet */
1167 /* dflt is safe */
1168
1169 strings[2*row+1].u.md_str = copy("dflt");
1170 }
1171
1172 static void ScriptMatrixInit(struct matrixinit *mi,char *scriptstr) {
1173 struct matrix_data *md;
1174 int k, cnt;
1175 char *start, *scriptend, *langsend;
1176
1177 memset(mi,0,sizeof(*mi));
1178 mi->col_cnt = 2;
1179 mi->col_init = scriptci;
1180
1181 md = NULL;
1182 for ( k=0; k<2; ++k ) {
1183 cnt = 0;
1184 for ( start = scriptstr; *start; ) {
1185 for ( scriptend=start; *scriptend!='\0' && *scriptend!='{'; ++scriptend );
1186 langsend = scriptend;
1187 if ( *scriptend=='{' )
1188 for ( langsend=scriptend+1; *langsend!='\0' && *langsend!='}'; ++langsend );
1189 if ( k ) {
1190 md[2*cnt+0].u.md_str = copyn(start,scriptend-start);
1191 if ( *scriptend=='{' )
1192 md[2*cnt+1].u.md_str = copyn(scriptend+1,langsend-(scriptend+1));
1193 else
1194 md[2*cnt+1].u.md_str = copy("");
1195 }
1196 ++cnt;
1197 if ( *langsend=='}' ) ++langsend;
1198 if ( *langsend==' ' ) ++langsend;
1199 start = langsend;
1200 }
1201 if ( md==NULL )
1202 md = calloc(2*(cnt+10),sizeof(struct matrix_data));
1203 }
1204 mi->matrix_data = md;
1205 mi->initial_row_cnt = cnt;
1206
1207 mi->initrow = LK_NewScript;
1208 mi->finishedit = NULL;
1209 mi->candelete = NULL;
1210 mi->popupmenu = NULL;
1211 mi->handle_key = NULL;
1212 mi->bigedittitle = NULL;
1213 }
1214
1215 static int Script_OK(GGadget *g, GEvent *e) {
1216
1217 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1218 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1219 int rows, i, j, script_cnt, lang_cnt;
1220 struct matrix_data *strings = GMatrixEditGet(GWidgetGetControl(ld->scriptgw,CID_FeatureScripts), &rows);
1221 char *pt, *start, *ret, *rpt;
1222 char foo[4];
1223
1224 if ( rows==0 ) {
1225 ff_post_error(_("No scripts"),_("You must select at least one script if you provide a feature tag."));
1226 return(true);
1227 }
1228 script_cnt = rows;
1229 lang_cnt = 0;
1230 for ( i=0; i<rows; ++i ) {
1231 if ( strlen(strings[2*i+0].u.md_str)>4 ) {
1232 ff_post_error(_("Bad script tag"),_("The script tag on line %d (%s) is too long. It may be at most 4 letters"),
1233 i+1, strings[2*i+0].u.md_str);
1234 return(true);
1235 } else {
1236 for ( pt=strings[2*i+0].u.md_str; *pt!='\0' ; ++pt )
1237 if ( *pt>0x7e ) {
1238 ff_post_error(_("Bad script tag"),_("The script tag on line %d (%s) should be in ASCII.\n"),
1239 i+1, strings[2*i+0].u.md_str);
1240 return( true );
1241 }
1242 }
1243 /* Now check the languages */
1244 if ( *strings[2*i+1].u.md_str=='\0' ) {
1245 ff_post_error(_("No languages"),_("You must select at least one language for each script."));
1246 return(true);
1247 }
1248 for ( start=strings[2*i+1].u.md_str; *start!='\0'; ) {
1249 for ( pt=start; *pt!=',' && *pt!='\0'; ++pt ) {
1250 if ( *pt>0x7e ) {
1251 ff_post_error(_("Bad language tag"),_("A language tag on line %d (%s) should be in ASCII.\n"),
1252 i+1, strings[2*i+1].u.md_str);
1253 return( true );
1254 }
1255 }
1256 if ( pt-start>4 ) {
1257 ff_post_error(_("Bad language tag"),_("A language tag on line %d (%s) is too long. It may be at most 4 letters"),
1258 i+1, strings[2*i+0].u.md_str);
1259 return(true);
1260 }
1261 ++lang_cnt;
1262 start = pt;
1263 if ( *start==',' ) ++start;
1264 }
1265 }
1266
1267 /* Ok, we validated the script lang list. Now parse it */
1268 rpt = ret = malloc(6*script_cnt+5*lang_cnt+10);
1269 for ( i=0; i<rows; ++i ) {
1270 memset(foo,' ',sizeof(foo));
1271 for ( j=0, pt = strings[2*i+0].u.md_str; j<4 && *pt; foo[j++] = *pt++ );
1272 strncpy(rpt,foo,4);
1273 rpt += 4;
1274 *rpt++ = '{';
1275 /* Now do the languages */
1276 for ( start=strings[2*i+1].u.md_str; *start!='\0'; ) {
1277 memset(foo,' ',sizeof(foo));
1278 for ( j=0,pt=start; *pt!=',' && *pt!='\0'; ++pt )
1279 foo[j++] = *pt;
1280 strncpy(rpt,foo,4);
1281 rpt += 4; *rpt++ = ',';
1282 if ( *pt==',' ) ++pt;
1283 start = pt;
1284 }
1285 if ( rpt>ret && rpt[-1]==',' )
1286 rpt[-1] = '}';
1287 *rpt++ = ' ';
1288 }
1289 if ( rpt>ret && rpt[-1]==' ' ) rpt[-1] = '\0';
1290 else *rpt = '\0';
1291 ld->scriptdone = true;
1292 ld->scriptret = ret;
1293 }
1294 return( true );
1295 }
1296
1297 static int Script_Cancel(GGadget *g, GEvent *e) {
1298
1299 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1300 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1301 ld->scriptdone = true;
1302 ld->scriptret = NULL;
1303 }
1304 return( true );
1305 }
1306
1307 static int script_e_h(GWindow gw, GEvent *event) {
1308
1309 if ( event->type==et_close ) {
1310 struct lookup_dlg *ld = GDrawGetUserData(gw);
1311 ld->scriptdone = true;
1312 ld->scriptret = NULL;
1313 } else if ( event->type == et_char ) {
1314 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
1315 help("ui/dialogs/lookups.html", "#lookups-scripts-dlg");
1316 return( true );
1317 }
1318 return( false );
1319 }
1320
1321 return( true );
1322 }
1323
1324 static char *LK_ScriptsDlg(GGadget *g, int r, int c) {
1325 int rows, i, k, j;
1326 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1327 char *scriptstr = strings[2*r+c].u.md_str;
1328 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1329 GRect pos;
1330 GWindow gw;
1331 GWindowAttrs wattrs;
1332 GGadgetCreateData gcd[4], boxes[3];
1333 GGadgetCreateData *varray[6], *harray3[8];
1334 GTextInfo label[4];
1335 struct matrixinit mi;
1336
1337 ld->scriptdone = 0;
1338 ld->scriptret = NULL;
1339
1340 memset(&wattrs,0,sizeof(wattrs));
1341 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
1342 wattrs.event_masks = ~(1<<et_charup);
1343 wattrs.is_dlg = true;
1344 wattrs.restrict_input_to_me = 1;
1345 wattrs.undercursor = 1;
1346 wattrs.cursor = ct_pointer;
1347 wattrs.utf8_window_title = _("Script(s)");
1348 pos.x = pos.y = 0;
1349 pos.width =GDrawPointsToPixels(NULL,GGadgetScale(268));
1350 pos.height = GDrawPointsToPixels(NULL,375);
1351 ld->scriptgw = gw = GDrawCreateTopWindow(NULL,&pos,script_e_h,ld,&wattrs);
1352
1353 ScriptMatrixInit(&mi,scriptstr);
1354
1355 memset(&gcd,0,sizeof(gcd));
1356 memset(&boxes,0,sizeof(boxes));
1357 memset(&label,0,sizeof(label));
1358 k=j=0;
1359 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[1].gd.pos.y+14;
1360 gcd[k].gd.pos.width = 300; gcd[k].gd.pos.height = 90;
1361 gcd[k].gd.flags = gg_enabled | gg_visible;
1362 gcd[k].gd.cid = CID_FeatureScripts;
1363 gcd[k].gd.u.matrix = &mi;
1364 gcd[k].gd.popup_msg = _(
1365 "Each feature is active for a specific set of\n"
1366 "scripts and languages.\n"
1367 "Usually only one script is specified, but\n"
1368 "occasionally more will be.\n"
1369 "A script is a four letter OpenType script tag\n");
1370 gcd[k].creator = GMatrixEditCreate;
1371 varray[j++] = &gcd[k++]; varray[j++] = NULL;
1372
1373 gcd[k].gd.pos.x = 30-3;
1374 gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0;
1375 gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default;
1376 label[k].text = (unichar_t *) _("_OK");
1377 label[k].text_is_1byte = true;
1378 label[k].text_in_resource = true;
1379 gcd[k].gd.label = &label[k];
1380 gcd[k].gd.handle_controlevent = Script_OK;
1381 gcd[k].gd.cid = CID_OK;
1382 gcd[k++].creator = GButtonCreate;
1383
1384 gcd[k].gd.pos.x = -30;
1385 gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0;
1386 gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
1387 label[k].text = (unichar_t *) _("_Cancel");
1388 label[k].text_is_1byte = true;
1389 label[k].text_in_resource = true;
1390 gcd[k].gd.label = &label[k];
1391 gcd[k].gd.handle_controlevent = Script_Cancel;
1392 gcd[k].gd.cid = CID_Cancel;
1393 gcd[k++].creator = GButtonCreate;
1394
1395 harray3[0] = harray3[2] = harray3[3] = harray3[4] = harray3[6] = GCD_Glue;
1396 harray3[7] = NULL;
1397 harray3[1] = &gcd[k-2]; harray3[5] = &gcd[k-1];
1398
1399 boxes[0].gd.flags = gg_enabled|gg_visible;
1400 boxes[0].gd.u.boxelements = harray3;
1401 boxes[0].creator = GHBoxCreate;
1402 varray[j++] = &boxes[0]; varray[j++] = NULL; varray[j] = NULL;
1403
1404 boxes[1].gd.pos.x = boxes[1].gd.pos.y = 2;
1405 boxes[1].gd.flags = gg_enabled|gg_visible;
1406 boxes[1].gd.u.boxelements = varray;
1407 boxes[1].creator = GHVGroupCreate;
1408
1409 GGadgetsCreate(gw,boxes+1);
1410
1411 for ( i=0; i<mi.initial_row_cnt; ++i ) {
1412 free( mi.matrix_data[2*i+0].u.md_str );
1413 free( mi.matrix_data[2*i+1].u.md_str );
1414 }
1415 free( mi.matrix_data );
1416
1417 GMatrixEditSetNewText(gcd[0].ret,S_("OpenTypeFeature|New"));
1418 GHVBoxSetExpandableRow(boxes[1].ret,0);
1419 GHVBoxSetExpandableCol(boxes[0].ret,gb_expandgluesame);
1420
1421 GHVBoxFitWindow(boxes[1].ret);
1422
1423 GDrawSetVisible(gw,true);
1424 while ( !ld->scriptdone )
1425 GDrawProcessOneEvent(NULL);
1426 GDrawDestroyWindow(gw);
1427 return( ld->scriptret );
1428 }
1429
1430 static FeatureScriptLangList *LK_ParseFL(struct matrix_data *strings, int rows ) {
1431 int i,j;
1432 char *pt, *start;
1433 FeatureScriptLangList *fl, *fhead, *flast;
1434 struct scriptlanglist *sl, *slast;
1435 unsigned char foo[4];
1436 uint32_t *langs=NULL;
1437 int lmax=0, lcnt=0;
1438 int feature, setting;
1439
1440 fhead = flast = NULL;
1441 for ( i=0; i<rows; ++i ) {
1442 fl = chunkalloc(sizeof(FeatureScriptLangList));
1443 if ( sscanf(strings[2*i+0].u.md_str,"<%d,%d>", &feature, &setting )== 2 ) {
1444 fl->ismac = true;
1445 fl->featuretag = (feature<<16)|setting;
1446 } else {
1447 memset(foo,' ',sizeof(foo));
1448 for ( j=0, pt = strings[2*i+0].u.md_str; j<4 && *pt; foo[j++] = *pt++ );
1449 fl->featuretag = (foo[0]<<24) | (foo[1]<<16) | (foo[2]<<8) | foo[3];
1450 }
1451 if ( flast==NULL )
1452 fhead = fl;
1453 else
1454 flast->next = fl;
1455 flast = fl;
1456 /* Now do the script langs */
1457 slast = NULL;
1458 for ( start=strings[2*i+1].u.md_str; *start!='\0'; ) {
1459 memset(foo,' ',sizeof(foo));
1460 for ( j=0,pt=start; *pt!='{' && *pt!='\0'; ++pt )
1461 foo[j++] = *pt;
1462 sl = chunkalloc(sizeof( struct scriptlanglist ));
1463 sl->script = (foo[0]<<24) | (foo[1]<<16) | (foo[2]<<8) | foo[3];
1464 if ( slast==NULL )
1465 fl->scripts = sl;
1466 else
1467 slast->next = sl;
1468 slast = sl;
1469 if ( *pt!='{' ) {
1470 sl->lang_cnt = 1;
1471 sl->langs[0] = DEFAULT_LANG;
1472 start = pt;
1473 } else {
1474 lcnt=0;
1475 for ( start=pt+1; *start!='}' && *start!='\0' ; ) {
1476 memset(foo,' ',sizeof(foo));
1477 for ( j=0,pt=start; *pt!='}' && *pt!=',' && *pt!='\0'; foo[j++] = *pt++ );
1478 if ( lcnt>=lmax )
1479 langs = realloc(langs,(lmax+=20)*sizeof(uint32_t));
1480 langs[lcnt++] = (foo[0]<<24) | (foo[1]<<16) | (foo[2]<<8) | foo[3];
1481 start = ( *pt==',' ) ? pt+1 : pt;
1482 }
1483 if ( *start=='}' ) ++start;
1484 for ( j=0; j<lcnt && j<MAX_LANG; ++j )
1485 sl->langs[j] = langs[j];
1486 if ( lcnt>MAX_LANG ) {
1487 sl->morelangs = malloc((lcnt-MAX_LANG)*sizeof(uint32_t));
1488 for ( ; j<lcnt; ++j )
1489 sl->morelangs[j-MAX_LANG] = langs[j];
1490 }
1491 sl->lang_cnt = lcnt;
1492 }
1493 while ( *start==' ' ) ++start;
1494 }
1495 }
1496 free(langs);
1497 return( fhead );
1498 }
1499
1500 static void LK_FinishEdit(GGadget *g,int row, int col, int wasnew) {
1501 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1502
1503 if ( col==0 ) {
1504 int rows;
1505 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1506
1507 if ( !ld->isgpos &&
1508 (strcmp(strings[row].u.md_str,"liga")==0 ||
1509 strcmp(strings[row].u.md_str,"rlig")==0 ))
1510 GGadgetSetChecked( GWidgetGetControl(ld->gw,CID_LookupAfm ), true );
1511 }
1512 if ( row==0 && !ld->name_has_been_set && ld->orig->features==NULL ) {
1513 int rows;
1514 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1515 OTLookup *otl = ld->orig;
1516 int old_type = otl->lookup_type;
1517 FeatureScriptLangList *oldfl = otl->features;
1518
1519 otl->lookup_type = (intptr_t) GGadgetGetListItemSelected(GWidgetGetControl(ld->gw,CID_LookupType))->userdata;
1520 otl->features = LK_ParseFL(strings,rows);
1521 NameOTLookup(otl,ld->sf);
1522 GGadgetSetTitle8(GWidgetGetControl(ld->gw,CID_LookupName),otl->lookup_name);
1523 free(otl->lookup_name); otl->lookup_name = NULL;
1524 FeatureScriptLangListFree(otl->features); otl->features = oldfl;
1525 otl->lookup_type = old_type;
1526 }
1527 }
1528
1529 static void LK_NewFeature(GGadget *g,int row) {
1530 int rows;
1531 struct matrix_data *strings = GMatrixEditGet(g, &rows);
1532 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1533 SplineFont *sf, *_sf = ld->sf;
1534 SplineChar *sc;
1535 /* What's a good default script / lang list for a new feature? */
1536 /* well it depends on what the feature is, and on what's inside the lookup */
1537 /* Neither of those has been set yet. */
1538 /* So... give them everything we can think of. They can remove stuff */
1539 /* which is inappropriate */
1540 uint32_t scripts[20], script, *langs;
1541 int scnt = 0, i, l;
1542 int gid, k;
1543 char *buf;
1544 int bmax, bpos;
1545
1546 k=0;
1547 do {
1548 sf = k<_sf->subfontcnt ? _sf->subfonts[k] : _sf;
1549 for ( gid=0; gid<sf->glyphcnt; ++gid ) if ( (sc = sf->glyphs[gid])!=NULL ) {
1550 script = SCScriptFromUnicode(sc);
1551 for ( i=0; i<scnt; ++i )
1552 if ( script == scripts[i] )
1553 break;
1554 if ( i==scnt ) {
1555 scripts[scnt++] = script;
1556 if ( scnt>=20 ) /* If they've got lots of scripts, enumerating them all won't be much use... */
1557 break;
1558 }
1559 }
1560 ++k;
1561 } while ( k<_sf->subfontcnt && scnt<20 );
1562
1563 if ( scnt==0 )
1564 scripts[scnt++] = DEFAULT_SCRIPT;
1565
1566 buf = malloc(bmax = 100);
1567 bpos = 0;
1568 for ( i=0; i<scnt; ++i ) {
1569 langs = SFLangsInScript(sf,-1,scripts[i]);
1570 for ( l=0; langs[l]!=0; ++l );
1571 if ( bpos + 5+5*l+4 > bmax )
1572 buf = realloc( buf, bmax += 5+5*l+100 );
1573 sprintf( buf+bpos, "%c%c%c%c{", scripts[i]>>24, scripts[i]>>16, scripts[i]>>8, scripts[i] );
1574 bpos+=5;
1575 for ( l=0; langs[l]!=0; ++l ) {
1576 sprintf( buf+bpos, "%c%c%c%c,", langs[l]>>24, langs[l]>>16, langs[l]>>8, langs[l] );
1577 bpos += 5;
1578 }
1579 if ( l>0 )
1580 --bpos;
1581 strcpy(buf+bpos,"} ");
1582 bpos += 2;
1583 free(langs);
1584 }
1585 if ( bpos>0 )
1586 buf[bpos-1] = '\0';
1587
1588 strings[2*row+1].u.md_str = copy(buf);
1589 free(buf);
1590 }
1591
1592 static void LKMatrixInit(struct matrixinit *mi,OTLookup *otl) {
1593 struct matrix_data *md;
1594 int k, cnt,j;
1595 FeatureScriptLangList *fl;
1596 struct scriptlanglist *sl;
1597 char featbuf[32], *buf=NULL;
1598 int blen=0, bpos=0;
1599
1600 memset(mi,0,sizeof(*mi));
1601 mi->col_cnt = 2;
1602 mi->col_init = featureci;
1603
1604 md = NULL;
1605 for ( k=0; k<2; ++k ) {
1606 cnt = 0;
1607 for ( fl=otl->features; fl!=NULL; fl=fl->next ) {
1608 if ( k ) {
1609 if ( fl->ismac )
1610 sprintf( featbuf, "<%d,%d>", fl->featuretag>>16, fl->featuretag&0xffff );
1611 else
1612 sprintf( featbuf, "%c%c%c%c", fl->featuretag>>24, fl->featuretag>>16,
1613 fl->featuretag>>8, fl->featuretag );
1614 md[2*cnt+0].u.md_str = copy(featbuf);
1615 bpos=0;
1616 for ( sl=fl->scripts; sl!=NULL; sl=sl->next ) {
1617 if ( bpos+4/*script*/+1/*open brace*/+5*sl->lang_cnt+1+2 > blen )
1618 buf = realloc(buf,blen+=5+5*sl->lang_cnt+3+200);
1619 sprintf( buf+bpos, "%c%c%c%c{", sl->script>>24, sl->script>>16,
1620 sl->script>>8, sl->script );
1621 bpos+=5;
1622 for ( j=0; j<sl->lang_cnt; ++j ) {
1623 uint32_t tag = j<MAX_LANG ? sl->langs[j] : sl->morelangs[j-MAX_LANG];
1624 sprintf( buf+bpos, "%c%c%c%c,", tag>>24, tag>>16,
1625 tag>>8, tag );
1626 bpos+=5;
1627 }
1628 if ( sl->lang_cnt!=0 )
1629 --bpos;
1630 buf[bpos++] = '}';
1631 buf[bpos++] = ' ';
1632 }
1633 if ( bpos>0 )
1634 --bpos;
1635 if (buf) {
1636 buf[bpos] = '\0';
1637 md[2*cnt+1].u.md_str = copy(buf);
1638 }
1639 else {
1640 md[2*cnt+1].u.md_str = NULL;
1641 }
1642 }
1643 ++cnt;
1644 }
1645 if ( md==NULL )
1646 md = calloc(2*(cnt+10),sizeof(struct matrix_data));
1647 }
1648 mi->matrix_data = md;
1649 mi->initial_row_cnt = cnt;
1650
1651 mi->initrow = LK_NewFeature;
1652 mi->finishedit = LK_FinishEdit;
1653 mi->candelete = NULL;
1654 mi->popupmenu = NULL;
1655 mi->handle_key = NULL;
1656 mi->bigedittitle = NULL;
1657 free(buf);
1658 }
1659
1660 static GTextInfo *SFMarkClassList(SplineFont *sf,int class) {
1661 int i;
1662 GTextInfo *ti;
1663
1664 if ( sf->cidmaster ) sf = sf->cidmaster;
1665 else if ( sf->mm!=NULL ) sf=sf->mm->normal;
1666
1667 i = sf->mark_class_cnt;
1668 ti = calloc(i+4,sizeof( GTextInfo ));
1669 ti[0].text = utf82u_copy( _("All"));
1670 ti[0].selected = class==0;
1671 for ( i=1; i<sf->mark_class_cnt; ++i ) {
1672 ti[i].text = (unichar_t *) copy(sf->mark_class_names[i]);
1673 ti[i].userdata = (void *) (intptr_t) i;
1674 ti[i].text_is_1byte = true;
1675 if ( i==class ) ti[i].selected = true;
1676 }
1677 return( ti );
1678 }
1679
1680 static GTextInfo *SFMarkSetList(SplineFont *sf,int set) {
1681 int i;
1682 GTextInfo *ti;
1683
1684 if ( sf->cidmaster ) sf = sf->cidmaster;
1685 else if ( sf->mm!=NULL ) sf=sf->mm->normal;
1686
1687 i = sf->mark_set_cnt;
1688 ti = calloc(i+4,sizeof( GTextInfo ));
1689 ti[0].text = utf82u_copy( _("All"));
1690 ti[0].userdata = (void *) (intptr_t) -1;
1691 ti[0].selected = set==-1;
1692 for ( i=0; i<sf->mark_set_cnt; ++i ) {
1693 ti[i+1].text = (unichar_t *) copy(sf->mark_set_names[i]);
1694 ti[i+1].userdata = (void *) (intptr_t) i;
1695 ti[i+1].text_is_1byte = true;
1696 if ( i==set ) ti[i+1].selected = true;
1697 }
1698 return( ti );
1699 }
1700
1701 static int MaskFromLookupType(int lookup_type ) {
1702 switch ( lookup_type ) {
1703 case gsub_single: case gsub_multiple: case gsub_alternate:
1704 case gsub_ligature: case gsub_context: case gsub_contextchain:
1705 return( 1<<(lookup_type-1));
1706 case gsub_reversecchain:
1707 return( gsub_reversecchain_mask );
1708 case morx_indic: case morx_context: case morx_insert:
1709 return( morx_indic_mask<<(lookup_type-morx_indic) );
1710 case gpos_single: case gpos_pair: case gpos_cursive:
1711 case gpos_mark2base: case gpos_mark2ligature: case gpos_mark2mark:
1712 case gpos_context: case gpos_contextchain:
1713 return( gpos_single_mask<<(lookup_type-gpos_single) );
1714 case kern_statemachine:
1715 return( kern_statemachine_mask );
1716 default:
1717 return( 0 );
1718 }
1719 }
1720
1721 static GTextInfo *FeatureListFromLookupType(int lookup_type) {
1722 int k, i, cnt, mask;
1723 GTextInfo *ti;
1724
1725 mask = MaskFromLookupType( lookup_type );
1726 for ( k=0; k<2; ++k ) {
1727 cnt = 0;
1728 for ( i=0; friendlies[i].tag!=0; ++i ) if ( friendlies[i].masks&mask ) {
1729 if ( k ) {
1730 char buf[128];
1731 snprintf(buf, sizeof buf, "%s %s", friendlies[i].tagstr, friendlies[i].friendlyname);
1732 ti[cnt].text = (unichar_t *) copy( buf );
1733 ti[cnt].text_is_1byte = true;
1734 ti[cnt].userdata = friendlies[i].tagstr;
1735 }
1736 ++cnt;
1737 }
1738 if ( cnt==0 ) {
1739 if ( k ) {
1740 ti[cnt].text = (unichar_t *) copy( _("You must choose a lookup type") );
1741 ti[cnt].text_is_1byte = true;
1742 ti[cnt].userdata = "????";
1743 }
1744 ++cnt;
1745 }
1746 if ( !k )
1747 ti = calloc(cnt+1,sizeof(GTextInfo));
1748 }
1749 return( ti );
1750 }
1751
1752 static int Lookup_NameChanged(GGadget *g, GEvent *e) {
1753
1754 if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) {
1755 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1756 if ( *_GGadgetGetTitle(g)!='\0' )
1757 ld->name_has_been_set = true;
1758 }
1759 return( true );
1760 }
1761
1762 static int LK_TypeChanged(GGadget *g, GEvent *e) {
1763
1764 if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
1765 int lookup_type = (intptr_t) GGadgetGetListItemSelected(g)->userdata;
1766 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1767 GTextInfo *ti = FeatureListFromLookupType( lookup_type );
1768 GMatrixEditSetColumnChoices( GWidgetGetControl(ld->gw,CID_LookupFeatures), 0, ti );
1769 GTextInfoListFree(ti);
1770 if ( !ld->isgpos ) {
1771 GGadgetSetEnabled( GWidgetGetControl(ld->gw,CID_LookupAfm ), lookup_type==gsub_ligature );
1772 if ( lookup_type!=gsub_ligature )
1773 GGadgetSetChecked( GWidgetGetControl(ld->gw,CID_LookupAfm ), false );
1774 }
1775 }
1776 return( true );
1777 }
1778
1779 static int Lookup_OK(GGadget *g, GEvent *e) {
1780
1781 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1782 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1783 int lookup_type = (intptr_t) GGadgetGetListItemSelected(GWidgetGetControl(ld->gw,CID_LookupType))->userdata;
1784 int rows, i, isgpos;
1785 struct matrix_data *strings = GMatrixEditGet(GWidgetGetControl(ld->gw,CID_LookupFeatures), &rows);
1786 char *pt, *start, *name;
1787 OTLookup *otl = ld->orig, *test;
1788 int flags, afm;
1789 FeatureScriptLangList *fhead;
1790 int feat, set;
1791
1792 if ( lookup_type==ot_undef ) {
1793 ff_post_error(_("No Lookup Type Selected"),_("You must select a Lookup Type."));
1794 return(true);
1795 }
1796 if ( *_GGadgetGetTitle(GWidgetGetControl(ld->gw,CID_LookupName))=='\0' ) {
1797 ff_post_error(_("Unnamed lookup"),_("You must name the lookup."));
1798 return(true);
1799 }
1800 for ( i=0; i<rows; ++i ) {
1801 if ( sscanf(strings[2*i+0].u.md_str,"<%d,%d>", &feat, &set )== 2 )
1802 /* It's a mac feature/setting */;
1803 else if ( strlen(strings[2*i+0].u.md_str)>4 ) {
1804 ff_post_error(_("Bad feature tag"),_("The feature tag on line %d (%s) is too long. It may be at most 4 letters (or it could be a mac feature setting, two numbers in brokets <3,4>)"),
1805 i+1, strings[2*i+0].u.md_str);
1806 return(true);
1807 } else {
1808 for ( pt=strings[2*i+0].u.md_str; *pt!='\0' ; ++pt )
1809 if ( *pt>0x7e ) {
1810 ff_post_error(_("Bad feature tag"),_("The feature tag on line %d (%s) should be in ASCII.\n"),
1811 i+1, strings[2*i+0].u.md_str);
1812 return( true );
1813 }
1814 }
1815 /* Now check the script langs */
1816 for ( start=strings[2*i+1].u.md_str; *start!='\0'; ) {
1817 for ( pt=start; *pt!='{' && *pt!='\0'; ++pt ) {
1818 if ( *pt>0x7e ) {
1819 ff_post_error(_("Bad script tag"),_("A script tag on line %d (%s) should be in ASCII.\n"),
1820 i+1, strings[2*i+1].u.md_str);
1821 return( true );
1822 }
1823 }
1824 if ( pt-start>4 ) {
1825 ff_post_error(_("Bad script tag"),_("A script tag on line %d (%s) is too long. It may be at most 4 letters"),
1826 i+1, strings[2*i+0].u.md_str);
1827 return(true);
1828 }
1829 if ( *pt=='{' ) {
1830 for ( start=pt+1; *start!='}' && *start!='\0' ; ) {
1831 for ( pt=start; *pt!='}' && *pt!=',' && *pt!='\0'; ++pt ) {
1832 if ( *pt>0x7e ) {
1833 ff_post_error(_("Bad language tag"),_("A language tag on line %d (%s) should be in ASCII.\n"),
1834 i+1, strings[2*i+1].u.md_str);
1835 return( true );
1836 }
1837 }
1838 if ( pt-start>4 ) {
1839 ff_post_error(_("Bad language tag"),_("A language tag on line %d (%s) is too long. It may be at most 4 letters"),
1840 i+1, strings[2*i+0].u.md_str);
1841 return(true);
1842 }
1843 start = ( *pt==',' ) ? pt+1 : pt;
1844 }
1845 if ( *start=='}' ) ++start;
1846 } else
1847 start = pt;
1848 while ( *start==' ' ) ++start;
1849 }
1850 }
1851 name = GGadgetGetTitle8(GWidgetGetControl(ld->gw,CID_LookupName));
1852 for ( isgpos=0; isgpos<2; ++isgpos ) {
1853 for ( test = isgpos ? ld->sf->gpos_lookups : ld->sf->gsub_lookups; test!=NULL; test=test->next ) {
1854 if ( test!=otl && strcmp(test->lookup_name,name)==0 ) {
1855 ff_post_error(_("Lookup name already used"),_("This name has already been used for another lookup.\nLookup names must be unique.") );
1856 free(name);
1857 return(true);
1858 }
1859 }
1860 }
1861
1862 flags = 0;
1863 if ( GGadgetIsChecked(GWidgetGetControl(ld->gw,CID_Lookup_R2L)) ) flags |= pst_r2l;
1864 if ( GGadgetIsChecked(GWidgetGetControl(ld->gw,CID_Lookup_IgnBase)) ) flags |= pst_ignorebaseglyphs;
1865 if ( GGadgetIsChecked(GWidgetGetControl(ld->gw,CID_Lookup_IgnLig)) ) flags |= pst_ignoreligatures;
1866 if ( GGadgetIsChecked(GWidgetGetControl(ld->gw,CID_Lookup_IgnMark)) ) flags |= pst_ignorecombiningmarks;
1867 flags |= ((intptr_t) GGadgetGetListItemSelected(GWidgetGetControl(ld->gw,CID_Lookup_ProcessMark))->userdata)<<8;
1868 set = ((intptr_t) GGadgetGetListItemSelected(GWidgetGetControl(ld->gw,CID_Lookup_ProcessSet))->userdata);
1869 if ( set!=-1 )
1870 flags |= pst_usemarkfilteringset | (set<<16);
1871
1872 if ( !ld->isgpos )
1873 afm = GGadgetIsChecked( GWidgetGetControl(ld->gw,CID_LookupAfm ));
1874 else
1875 afm = false;
1876
1877 /* Ok, we validated the feature script lang list. Now parse it */
1878 fhead = LK_ParseFL(strings,rows);
1879 free( otl->lookup_name );
1880 FeatureScriptLangListFree( otl->features );
1881 otl->lookup_name = name;
1882 otl->lookup_type = lookup_type;
1883 otl->lookup_flags = flags;
1884 otl->features = FLOrder(fhead);
1885 otl->store_in_afm = afm;
1886 ld->done = true;
1887 ld->ok = true;
1888 }
1889 return( true );
1890 }
1891
1892 static int Lookup_Cancel(GGadget *g, GEvent *e) {
1893
1894 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
1895 struct lookup_dlg *ld = GDrawGetUserData(GGadgetGetWindow(g));
1896 ld->done = true;
1897 ld->ok = false;
1898 }
1899 return( true );
1900 }
1901
1902 static int lookup_e_h(GWindow gw, GEvent *event) {
1903
1904 if ( event->type==et_close ) {
1905 struct lookup_dlg *ld = GDrawGetUserData(gw);
1906 ld->done = true;
1907 ld->ok = false;
1908 } else if ( event->type == et_char ) {
1909 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
1910 help("ui/dialogs/lookups.html", "#lookups-add-lookup");
1911 return( true );
1912 }
1913 return( false );
1914 }
1915
1916 return( true );
1917 }
1918
1919 int EditLookup(OTLookup *otl,int isgpos,SplineFont *sf) {
1920 /* Ok we must provide a lookup type (but only if otl->type==ot_undef) */
1921 /* a set of lookup flags */
1922 /* a name */
1923 /* A potentially empty set of features, scripts and languages */
1924 /* afm */
1925 /* check to make sure the name isn't a duplicate */
1926 GRect pos;
1927 GWindow gw;
1928 GWindowAttrs wattrs;
1929 GGadgetCreateData gcd[16], boxes[7];
1930 GGadgetCreateData *harray1[4], *varray[14], *flaghvarray[10], *flagarray[12],
1931 *harray2[4], *harray3[8];
1932 GTextInfo label[16];
1933 struct lookup_dlg ld;
1934 struct matrixinit mi;
1935 int class, i, k, vpos;
1936
1937 LookupUIInit();
1938
1939 memset(&ld,0,sizeof(ld));
1940 memset(&wattrs,0,sizeof(wattrs));
1941 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
1942 wattrs.event_masks = ~(1<<et_charup);
1943 wattrs.is_dlg = true;
1944 wattrs.restrict_input_to_me = 1;
1945 wattrs.undercursor = 1;
1946 wattrs.cursor = ct_pointer;
1947 wattrs.utf8_window_title = _("Lookup");
1948 pos.x = pos.y = 0;
1949 pos.width =GDrawPointsToPixels(NULL,GGadgetScale(268));
1950 pos.height = GDrawPointsToPixels(NULL,375);
1951 ld.gw = gw = GDrawCreateTopWindow(NULL,&pos,lookup_e_h,&ld,&wattrs);
1952
1953 ld.orig = otl;
1954 ld.sf = sf;
1955 ld.isgpos = isgpos;
1956
1957 memset(boxes,0,sizeof(boxes));
1958 memset(gcd,0,sizeof(gcd));
1959 memset(label,0,sizeof(label));
1960
1961 label[0].text = (unichar_t *) _("Type:");
1962 label[0].text_is_1byte = true;
1963 label[0].text_in_resource = true;
1964 gcd[0].gd.label = &label[0];
1965 gcd[0].gd.pos.x = 12; gcd[0].gd.pos.y = 6+6;
1966 gcd[0].gd.flags = gg_visible | gg_enabled;
1967 gcd[0].creator = GLabelCreate;
1968
1969 gcd[1].gd.pos.x = 100; gcd[1].gd.pos.y = 6; gcd[1].gd.pos.width = 200;
1970 gcd[1].gd.flags = otl->lookup_type!=ot_undef && otl->subtables!=NULL?
1971 (gg_visible) : (gg_visible | gg_enabled);
1972 gcd[1].gd.cid = CID_LookupType;
1973 gcd[1].gd.u.list = lookuptypes[isgpos];
1974 gcd[1].gd.handle_controlevent = LK_TypeChanged;
1975 gcd[1].gd.popup_msg = _(
1976 "Each lookup may contain many transformations,\n"
1977 "but each transformation must be of the same type.");
1978 gcd[1].creator = GListButtonCreate;
1979
1980 for ( i=0; lookuptypes[isgpos][i].text!=NULL || lookuptypes[isgpos][i].line; ++i ) {
1981 if ( (void *) otl->lookup_type == lookuptypes[isgpos][i].userdata &&
1982 !lookuptypes[isgpos][i].line) {
1983 lookuptypes[isgpos][i].selected = true;
1984 gcd[1].gd.label = &lookuptypes[isgpos][i];
1985 } else
1986 lookuptypes[isgpos][i].selected = false;
1987 }
1988 harray1[0] = &gcd[0]; harray1[1] = &gcd[1]; harray1[2] = GCD_Glue; harray1[3] = NULL;
1989 boxes[0].gd.flags = gg_enabled|gg_visible;
1990 boxes[0].gd.u.boxelements = harray1;
1991 boxes[0].creator = GHBoxCreate;
1992 varray[0] = &boxes[0]; varray[1] = NULL;
1993
1994 LKMatrixInit(&mi,otl);
1995 featureci[0].enum_vals = FeatureListFromLookupType(otl->lookup_type);
1996
1997 gcd[2].gd.pos.x = 10; gcd[2].gd.pos.y = gcd[1].gd.pos.y+14;
1998 gcd[2].gd.pos.width = 300; gcd[2].gd.pos.height = 90;
1999 gcd[2].gd.flags = gg_enabled | gg_visible;
2000 gcd[2].gd.cid = CID_LookupFeatures;
2001 gcd[2].gd.u.matrix = &mi;
2002 gcd[2].gd.popup_msg = _(
2003 "Most lookups will be attached to a feature\n"
2004 "active in a specific script for certain languages.\n"
2005 "In some cases lookups will not be attached to any\n"
2006 "feature, but will be invoked by another lookup,\n"
2007 "a conditional one. In other cases a lookup might\n"
2008 "be attached to several features.\n"
2009 "A feature is either a four letter OpenType feature\n"
2010 "tag, or a two number mac <feature,setting> combination.");
2011 gcd[2].creator = GMatrixEditCreate;
2012 varray[2] = &gcd[2]; varray[3] = NULL;
2013
2014
2015 gcd[3].gd.pos.x = 5; gcd[3].gd.pos.y = 5;
2016 gcd[3].gd.flags = gg_visible | gg_enabled | (otl->lookup_flags&pst_r2l?gg_cb_on:0);
2017 label[3].text = (unichar_t *) _("Right To Left");
2018 label[3].text_is_1byte = true;
2019 gcd[3].gd.label = &label[3];
2020 gcd[3].gd.cid = CID_Lookup_R2L;
2021 gcd[3].creator = GCheckBoxCreate;
2022 flagarray[0] = &gcd[3]; flagarray[1] = NULL;
2023
2024 gcd[4].gd.pos.x = 5; gcd[4].gd.pos.y = gcd[3].gd.pos.y+15;
2025 gcd[4].gd.flags = gg_visible | gg_enabled | (otl->lookup_flags&pst_ignorebaseglyphs?gg_cb_on:0);
2026 label[4].text = (unichar_t *) _("Ignore Base Glyphs");
2027 label[4].text_is_1byte = true;
2028 gcd[4].gd.label = &label[4];
2029 gcd[4].gd.cid = CID_Lookup_IgnBase;
2030 gcd[4].creator = GCheckBoxCreate;
2031 flagarray[2] = &gcd[4]; flagarray[3] = NULL;
2032
2033 gcd[5].gd.pos.x = 5; gcd[5].gd.pos.y = gcd[4].gd.pos.y+15;
2034 gcd[5].gd.flags = gg_visible | gg_enabled | (otl->lookup_flags&pst_ignoreligatures?gg_cb_on:0);
2035 label[5].text = (unichar_t *) _("Ignore Ligatures");
2036 label[5].text_is_1byte = true;
2037 gcd[5].gd.label = &label[5];
2038 gcd[5].gd.cid = CID_Lookup_IgnLig;
2039 gcd[5].creator = GCheckBoxCreate;
2040 flagarray[4] = &gcd[5]; flagarray[5] = NULL;
2041
2042 gcd[6].gd.pos.x = 5; gcd[6].gd.pos.y = gcd[5].gd.pos.y+15;
2043 gcd[6].gd.flags = gg_visible | gg_enabled | (otl->lookup_flags&pst_ignorecombiningmarks?gg_cb_on:0);
2044 label[6].text = (unichar_t *) _("Ignore Combining Marks");
2045 label[6].text_is_1byte = true;
2046 gcd[6].gd.label = &label[6];
2047 gcd[6].gd.cid = CID_Lookup_IgnMark;
2048 gcd[6].creator = GCheckBoxCreate;
2049 flagarray[6] = &gcd[6]; flagarray[7] = NULL;
2050
2051 /* GT: Process is a verb here and Mark is a noun. */
2052 /* GT: Marks of the given mark class are to be processed */
2053 label[7].text = (unichar_t *) _("Mark Class:");
2054 label[7].text_is_1byte = true;
2055 gcd[7].gd.label = &label[7];
2056 gcd[7].gd.pos.x = 5; gcd[7].gd.pos.y = gcd[6].gd.pos.y+16;
2057 gcd[7].gd.flags = sf->mark_class_cnt<=1 ? gg_visible : (gg_enabled|gg_visible);
2058 gcd[7].creator = GLabelCreate;
2059 flaghvarray[0] = &gcd[7];
2060
2061 gcd[8].gd.pos.x = 10; gcd[8].gd.pos.y = gcd[7].gd.pos.y;
2062 gcd[8].gd.pos.width = 140;
2063 gcd[8].gd.flags = gcd[7].gd.flags;
2064 if ( (class = ((otl->lookup_flags&0xff00)>>8) )>= sf->mark_class_cnt )
2065 class = 0;
2066 gcd[8].gd.u.list = SFMarkClassList(sf,class);
2067 gcd[8].gd.label = &gcd[8].gd.u.list[class];
2068 gcd[8].gd.cid = CID_Lookup_ProcessMark;
2069 gcd[8].creator = GListButtonCreate;
2070 flaghvarray[1] = &gcd[8]; flaghvarray[2] = GCD_Glue; flaghvarray[3] = NULL;
2071
2072 /* GT: Mark is a noun here and Set is also a noun. */
2073 label[9].text = (unichar_t *) _("Mark Set:");
2074 label[9].text_is_1byte = true;
2075 gcd[9].gd.label = &label[9];
2076 gcd[9].gd.flags = sf->mark_set_cnt<1 ? gg_visible : (gg_enabled|gg_visible);
2077 gcd[9].creator = GLabelCreate;
2078 flaghvarray[4] = &gcd[9];
2079
2080 gcd[10].gd.pos.width = 140;
2081 gcd[10].gd.flags = gcd[9].gd.flags;
2082 class = (otl->lookup_flags>>16) & 0xffff;
2083 if ( !(otl->lookup_flags&pst_usemarkfilteringset) || class >= sf->mark_set_cnt )
2084 class = -1;
2085 gcd[10].gd.u.list = SFMarkSetList(sf,class);
2086 gcd[10].gd.label = &gcd[10].gd.u.list[class+1];
2087 gcd[10].gd.cid = CID_Lookup_ProcessSet;
2088 gcd[10].creator = GListButtonCreate;
2089 flaghvarray[5] = &gcd[10]; flaghvarray[6] = GCD_Glue; flaghvarray[7] = NULL; flaghvarray[8] = NULL;
2090
2091 boxes[1].gd.flags = gg_enabled|gg_visible;
2092 boxes[1].gd.u.boxelements = flaghvarray;
2093 boxes[1].creator = GHVBoxCreate;
2094
2095 flagarray[8] = &boxes[1]; flagarray[9] = NULL; flagarray[10] = NULL;
2096
2097 boxes[2].gd.pos.x = boxes[2].gd.pos.y = 2;
2098 boxes[2].gd.flags = gg_enabled|gg_visible;
2099 boxes[2].gd.u.boxelements = flagarray;
2100 boxes[2].creator = GHVGroupCreate;
2101 varray[4] = &boxes[2]; varray[5] = NULL;
2102
2103 label[11].text = (unichar_t *) _("Lookup Name:");
2104 label[11].text_is_1byte = true;
2105 gcd[11].gd.label = &label[11];
2106 gcd[11].gd.pos.x = 5; gcd[11].gd.pos.y = gcd[8].gd.pos.y+16;
2107 gcd[11].gd.flags = gg_enabled|gg_visible;
2108 gcd[11].creator = GLabelCreate;
2109 harray2[0] = &gcd[11];
2110
2111 label[12].text = (unichar_t *) otl->lookup_name;
2112 label[12].text_is_1byte = true;
2113 gcd[12].gd.pos.x = 10; gcd[12].gd.pos.y = gcd[11].gd.pos.y;
2114 gcd[12].gd.pos.width = 140;
2115 gcd[12].gd.flags = gcd[11].gd.flags|gg_text_xim;
2116 gcd[12].gd.label = otl->lookup_name==NULL ? NULL : &label[12];
2117 gcd[12].gd.cid = CID_LookupName;
2118 gcd[12].gd.handle_controlevent = Lookup_NameChanged;
2119 gcd[12].creator = GTextFieldCreate;
2120 harray2[1] = &gcd[12]; harray2[2] = NULL;
2121 if ( otl->lookup_name!=NULL && *otl->lookup_name!='\0' )
2122 ld.name_has_been_set = true;
2123
2124 boxes[3].gd.flags = gg_enabled|gg_visible;
2125 boxes[3].gd.u.boxelements = harray2;
2126 boxes[3].creator = GHBoxCreate;
2127 varray[6] = &boxes[3]; varray[7] = NULL;
2128
2129 k = 13; vpos = 8;
2130 if ( !isgpos ) {
2131 gcd[13].gd.pos.x = 5; gcd[13].gd.pos.y = gcd[5].gd.pos.y+15;
2132 gcd[13].gd.flags = otl->lookup_type!=gsub_ligature ? gg_visible :
2133 otl->store_in_afm ? (gg_visible | gg_enabled | gg_cb_on) :
2134 (gg_visible | gg_enabled);
2135 label[13].text = (unichar_t *) _("Store ligature data in AFM files");
2136 label[13].text_is_1byte = true;
2137 gcd[13].gd.label = &label[13];
2138 gcd[13].gd.cid = CID_LookupAfm;
2139 gcd[13].creator = GCheckBoxCreate;
2140 varray[8] = &gcd[13]; varray[9] = NULL;
2141 k = 14; vpos = 10;
2142 }
2143
2144 gcd[k].gd.pos.x = 30-3;
2145 gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0;
2146 gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default;
2147 label[k].text = (unichar_t *) _("_OK");
2148 label[k].text_is_1byte = true;
2149 label[k].text_in_resource = true;
2150 gcd[k].gd.label = &label[k];
2151 gcd[k].gd.handle_controlevent = Lookup_OK;
2152 gcd[k].gd.cid = CID_OK;
2153 gcd[k].creator = GButtonCreate;
2154
2155 gcd[k+1].gd.pos.x = -30;
2156 gcd[k+1].gd.pos.width = -1; gcd[k+1].gd.pos.height = 0;
2157 gcd[k+1].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
2158 label[k+1].text = (unichar_t *) _("_Cancel");
2159 label[k+1].text_is_1byte = true;
2160 label[k+1].text_in_resource = true;
2161 gcd[k+1].gd.label = &label[k+1];
2162 gcd[k+1].gd.handle_controlevent = Lookup_Cancel;
2163 gcd[k+1].gd.cid = CID_Cancel;
2164 gcd[k+1].creator = GButtonCreate;
2165
2166 harray3[0] = harray3[2] = harray3[3] = harray3[4] = harray3[6] = GCD_Glue;
2167 harray3[7] = NULL;
2168 harray3[1] = &gcd[k]; harray3[5] = &gcd[k+1];
2169
2170 boxes[4].gd.flags = gg_enabled|gg_visible;
2171 boxes[4].gd.u.boxelements = harray3;
2172 boxes[4].creator = GHBoxCreate;
2173 varray[vpos++] = &boxes[4]; varray[vpos++] = NULL; varray[vpos] = NULL;
2174
2175 boxes[5].gd.pos.x = boxes[5].gd.pos.y = 2;
2176 boxes[5].gd.flags = gg_enabled|gg_visible;
2177 boxes[5].gd.u.boxelements = varray;
2178 boxes[5].creator = GHVGroupCreate;
2179
2180 GGadgetsCreate(gw,boxes+5);
2181
2182 GTextInfoListFree(gcd[8].gd.u.list);
2183 GTextInfoListFree(gcd[10].gd.u.list);
2184
2185 for ( i=0; i<mi.initial_row_cnt; ++i ) {
2186 free( mi.matrix_data[2*i+0].u.md_str );
2187 free( mi.matrix_data[2*i+1].u.md_str );
2188 }
2189 free( mi.matrix_data );
2190
2191 GMatrixEditSetNewText(gcd[2].ret,S_("OpenTypeFeature|New"));
2192 GHVBoxSetExpandableRow(boxes[5].ret,1);
2193 GHVBoxSetExpandableCol(boxes[4].ret,gb_expandgluesame);
2194 GHVBoxSetExpandableCol(boxes[3].ret,1);
2195 GHVBoxSetExpandableCol(boxes[1].ret,1);
2196 GHVBoxSetExpandableCol(boxes[0].ret,gb_expandglue);
2197
2198 GHVBoxFitWindow(boxes[5].ret);
2199
2200 GDrawSetVisible(gw,true);
2201 while ( !ld.done )
2202 GDrawProcessOneEvent(NULL);
2203 GDrawDestroyWindow(gw);
2204
2205 return( ld.ok );
2206 }
2207
2208 static OTLookup *CreateAndSortNewLookupOfType(SplineFont *sf, int lookup_type) {
2209 OTLookup *newotl;
2210 int isgpos = lookup_type>=gpos_start;
2211
2212 newotl = chunkalloc(sizeof(OTLookup));
2213 newotl->lookup_type = lookup_type;
2214 if ( !EditLookup(newotl,isgpos,sf)) {
2215 chunkfree(newotl,sizeof(OTLookup));
2216 return( NULL );
2217 }
2218 SortInsertLookup(sf, newotl);
2219 return( newotl );
2220 }
2221
2222 /* ************************************************************************** */
2223 /* ***************************** Anchor Subtable **************************** */
2224 /* ************************************************************************** */
2225 typedef struct anchorclassdlg {
2226 SplineFont *sf;
2227 int def_layer;
2228 struct lookup_subtable *sub;
2229 GWindow gw;
2230 int mag, pixelsize;
2231 int orig_pos, orig_value, down;
2232 BDFFont *display;
2233 int done;
2234 int popup_r;
2235 GCursor cursor_current;
2236 /* Used during autokern */
2237 int rows_at_start;
2238 int rows,cols; /* Total rows, columns allocated */
2239 int next_row;
2240 struct matrix_data *psts;
2241 } AnchorClassDlg, PSTKernDlg;
2242 #define CID_Anchors 2001
2243
2244 #define CID_PSTList 2001
2245 #define CID_Alpha 2002
2246 #define CID_Unicode 2003
2247 #define CID_Scripts 2004
2248 #define CID_BaseChar 2005
2249 #define CID_Suffix 2006
2250 #define CID_AllSame 2007
2251 #define CID_Separation 2008
2252 #define CID_MinKern 2009
2253 #define CID_Touched 2010
2254 #define CID_OnlyCloser 2011
2255 #define CID_Autokern 2012
2256
2257 #define CID_KernDisplay 2022
2258 #define CID_PixelSize 2023
2259 #define CID_Magnification 2024
2260
2261 static GTextInfo magnifications[] = {
2262 { (unichar_t *) "100%", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 1, 0, 1, 0, 0, '\0'},
2263 { (unichar_t *) "200%", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
2264 { (unichar_t *) "300%", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
2265 { (unichar_t *) "400%", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'},
2266 GTEXTINFO_EMPTY
2267 };
2268
2269 static AnchorClass *SFAddAnchorClass(SplineFont *sf,struct lookup_subtable *sub,
2270 char *name) {
2271 AnchorClass *ac;
2272
2273 for ( ac=sf->anchor; ac!=NULL; ac=ac->next) {
2274 if ( strcmp(ac->name,name)==0 && ac->subtable==NULL )
2275 break;
2276 }
2277 if ( ac==NULL ) {
2278 ac = chunkalloc(sizeof(AnchorClass));
2279 ac->name = copy(name);
2280 ac->next = sf->anchor;
2281 sf->anchor = ac;
2282 }
2283 ac->type = sub->lookup->lookup_type == gpos_mark2base ? act_mark :
2284 sub->lookup->lookup_type == gpos_mark2ligature ? act_mklg :
2285 sub->lookup->lookup_type == gpos_cursive ? act_curs :
2286 act_mkmk;
2287 ac->subtable = sub;
2288 return( ac );
2289 }
2290
2291 static int AnchorClassD_ShowAnchors(GGadget *g, GEvent *e) {
2292 AnchorClassDlg *acd;
2293
2294 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
2295 struct matrix_data *classes;
2296 int32_t class_cnt;
2297 int row;
2298 AnchorClass *ac;
2299
2300 acd = GDrawGetUserData(GGadgetGetWindow(g));
2301 classes = GMatrixEditGet(GWidgetGetControl(acd->gw,CID_Anchors), &class_cnt);
2302 row = GMatrixEditGetActiveRow(GWidgetGetControl(acd->gw,CID_Anchors));
2303 if ( row==-1 )
2304 return( true );
2305 ac = classes[2*row+1].u.md_addr;
2306 if ( ac==NULL || ac->subtable==NULL) {
2307 ac = SFAddAnchorClass(acd->sf,acd->sub,classes[2*row+0].u.md_str);
2308 } else if ( ac->subtable!=acd->sub ) {
2309 ff_post_error(_("Name in use"),_("The name, %.80s, has already been used to identify an anchor class in a different lookup subtable (%.80s)"),
2310 ac->name, ac->subtable->subtable_name );
2311 return( true );
2312 }
2313 AnchorControlClass(acd->sf,ac,acd->def_layer);
2314 }
2315 return( true );
2316 }
2317
2318 static void AC_EnableOtherButtons(GGadget *g,int r, int c) {
2319 GGadgetSetEnabled(GWidgetGetControl(GGadgetGetWindow(g),CID_ShowAnchors),
2320 r!=-1 );
2321 }
2322
2323 static int AC_OK(GGadget *g, GEvent *e) {
2324 AnchorClassDlg *acd;
2325
2326 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
2327 struct matrix_data *classes;
2328 int32_t class_cnt;
2329 int i,j;
2330 AnchorClass *ac, *acnext, *actest;
2331
2332 acd = GDrawGetUserData(GGadgetGetWindow(g));
2333 classes = GMatrixEditGet(GWidgetGetControl(acd->gw,CID_Anchors), &class_cnt);
2334 acd->sub->anchor_classes = true /*class_cnt!=0*/;
2335 for ( i=0; i<class_cnt; ++i ) {
2336 if ( *classes[2*i+0].u.md_str=='\0' )
2337 continue; /* Ignore blank lines. They pressed return once too often or something */
2338 for ( j=i+1; j<class_cnt; ++j ) {
2339 if ( strcmp(classes[2*i+0].u.md_str,classes[2*j+0].u.md_str)==0 ) {
2340 ff_post_error(_("Name used twice"),_("The name, %.80s, appears twice in this list.\nEach anchor class must have a distinct name."),
2341 classes[2*i+0].u.md_str );
2342 return( true );
2343 }
2344 }
2345 for ( actest = acd->sf->anchor; actest!=NULL; actest=actest->next )
2346 if ( actest->subtable!=NULL && actest->subtable!=acd->sub &&
2347 strcmp(actest->name,classes[2*i+0].u.md_str)==0 )
2348 break;
2349 if ( actest!=NULL ) {
2350 ff_post_error(_("Name in use"),_("The name, %.80s, has already been used to identify an anchor class in a different lookup subtable (%.80s)"),
2351 actest->name, actest->subtable->subtable_name );
2352 return( true );
2353 }
2354 }
2355
2356 for ( ac = acd->sf->anchor; ac!=NULL; ac=ac->next )
2357 ac->processed = false;
2358 for ( i=0; i<class_cnt; ++i ) {
2359 ac = classes[2*i+1].u.md_addr;
2360 if ( ac!=NULL )
2361 ac->processed = true;
2362 }
2363 for ( ac = acd->sf->anchor; ac!=NULL; ac=ac->next ) {
2364 if ( !ac->processed && ac->subtable == acd->sub ) {
2365 char *buts[3];
2366 int askresult = 0;
2367 /* want to support keeping APs when class is removed from subtable */
2368 buts[0] = _("_Remove"); buts[1] = _("_Cancel"); buts[2]=NULL;
2369 askresult = gwwv_ask(_("Remove Anchor Class?"),(const char **) buts,0,1,_("Do you really want to remove the anchor class, %.80s?\nThis will remove all anchor points associated with that class."),
2370 ac->name );
2371 if ( askresult==1 )
2372 return( true );
2373 else
2374 ac->ticked = askresult==2 ? 0 : 1;
2375 }
2376 }
2377
2378 for ( i=0; i<class_cnt; ++i ) {
2379 if ( *classes[2*i+0].u.md_str=='\0' )
2380 continue; /* Ignore blank lines. They pressed return once too much or something */
2381 ac = classes[2*i+1].u.md_addr;
2382 if ( ac==NULL || ac->subtable==NULL ) {
2383 ac = SFAddAnchorClass(acd->sf,acd->sub,classes[2*i+0].u.md_str);
2384 ac->processed = true;
2385 } else {
2386 free(ac->name);
2387 ac->name = copy(classes[2*i+0].u.md_str);
2388 ac->processed = true;
2389 }
2390 }
2391 for ( ac = acd->sf->anchor; ac!=NULL; ac=acnext ) {
2392 acnext = ac->next;
2393 if ( !ac->processed && ac->subtable == acd->sub ) {
2394 if ( ac->ticked )
2395 SFRemoveAnchorClass(acd->sf,ac);
2396 else {
2397 ac->ticked = 0;
2398 ac->subtable = NULL;
2399 }
2400 }
2401 }
2402 acd->done = true;
2403 }
2404 return( true );
2405 }
2406
2407 static void AC_DoCancel(AnchorClassDlg *acd) {
2408 acd->done = true;
2409 }
2410
2411 static int AC_Cancel(GGadget *g, GEvent *e) {
2412 AnchorClassDlg *acd;
2413
2414 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
2415 acd = GDrawGetUserData(GGadgetGetWindow(g));
2416 AC_DoCancel(acd);
2417 }
2418 return( true );
2419 }
2420
2421 static int acd_e_h(GWindow gw, GEvent *event) {
2422 AnchorClassDlg *acd = GDrawGetUserData(gw);
2423
2424 switch ( event->type ) {
2425 case et_close:
2426 AC_DoCancel(acd);
2427 break;
2428 case et_char:
2429 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
2430 help("ui/dialogs/lookups.html", "#lookups-anchor");
2431 return( true );
2432 }
2433 return( false );
2434 break;
2435 case et_destroy:
2436 break;
2437 case et_mouseup: case et_mousemove: case et_mousedown:
2438 break;
2439 case et_expose:
2440 break;
2441 case et_resize:
2442 break;
2443 default: break;
2444 }
2445 return( true );
2446 }
2447
2448 static void ACDMatrixInit(struct matrixinit *mi,SplineFont *sf, struct lookup_subtable *sub) {
2449 int cnt;
2450 AnchorClass *ac;
2451 struct matrix_data *md;
2452 static struct col_init ci[] = {
2453 { me_string , NULL, NULL, NULL, N_("Anchor Class Name") },
2454 { me_addr , NULL, NULL, NULL, "Anchor Class Pointer, hidden" },
2455 COL_INIT_EMPTY
2456 };
2457 static int initted = false;
2458
2459 if ( !initted ) {
2460 initted = true;
2461 ci[0].title = S_(ci[0].title);
2462 }
2463
2464 memset(mi,0,sizeof(*mi));
2465 mi->col_cnt = 2;
2466 mi->col_init = ci;
2467
2468 for ( ac=sf->anchor, cnt=0; ac!=NULL; ac=ac->next )
2469 if ( ac->subtable == sub )
2470 ++cnt;
2471 if ( cnt==0 ) {
2472 md = calloc(1,sizeof(struct matrix_data));
2473 mi->initial_row_cnt = 0;
2474 } else {
2475 md = calloc(2*cnt,sizeof(struct matrix_data));
2476 for ( ac=sf->anchor, cnt=0; ac!=NULL; ac=ac->next )
2477 if ( ac->subtable == sub ) {
2478 md[2*cnt +0].u.md_str = ac->name;
2479 md[2*cnt++ +1].u.md_addr = ac;
2480 }
2481 mi->initial_row_cnt = cnt;
2482 }
2483 mi->matrix_data = md;
2484 }
2485
2486 /* Anchor list, [new], [delete], [edit], [show first mark/entry], [show first base/exit] */
2487 /* [ok], [cancel] */
2488 static void AnchorClassD(SplineFont *sf, struct lookup_subtable *sub, int def_layer) {
2489 GRect pos;
2490 GWindowAttrs wattrs;
2491 AnchorClassDlg acd;
2492 GWindow gw;
2493 char buffer[200];
2494 GGadgetCreateData gcd[6], buttonbox, mainbox[2];
2495 GGadgetCreateData *buttonarray[8], *varray[7];
2496 GTextInfo label[6];
2497 int i;
2498 struct matrixinit mi;
2499
2500 memset(&acd,0,sizeof(acd));
2501 acd.sf = sf;
2502 acd.def_layer = def_layer;
2503 acd.sub = sub;
2504
2505 memset(&wattrs,0,sizeof(wattrs));
2506 memset(&gcd,0,sizeof(gcd));
2507 memset(&buttonbox,0,sizeof(buttonbox));
2508 memset(&mainbox,0,sizeof(mainbox));
2509 memset(&label,0,sizeof(label));
2510
2511 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
2512 wattrs.event_masks = ~(1<<et_charup);
2513 wattrs.restrict_input_to_me = true;
2514 wattrs.undercursor = 1;
2515 wattrs.cursor = ct_pointer;
2516 snprintf(buffer,sizeof(buffer),_("Anchor classes in subtable %.80s"),
2517 sub->subtable_name );
2518 wattrs.utf8_window_title = buffer;
2519 wattrs.is_dlg = true;
2520 pos.x = pos.y = 0;
2521 pos.width = GGadgetScale(GDrawPointsToPixels(NULL,325));
2522 pos.height = GDrawPointsToPixels(NULL,250);
2523 acd.gw = gw = GDrawCreateTopWindow(NULL,&pos,acd_e_h,&acd,&wattrs);
2524
2525 i = 0;
2526
2527 ACDMatrixInit(&mi,sf,sub);
2528 gcd[i].gd.pos.width = 300; gcd[i].gd.pos.height = 200;
2529 gcd[i].gd.flags = gg_enabled | gg_visible;
2530 gcd[i].gd.cid = CID_Anchors;
2531 gcd[i].gd.u.matrix = &mi;
2532 gcd[i].data = &acd;
2533 gcd[i++].creator = GMatrixEditCreate;
2534 varray[0] = &gcd[i-1]; varray[1] = NULL;
2535
2536 gcd[i].gd.pos.x = 10; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+24+3;
2537 gcd[i].gd.pos.width = -1;
2538 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default;
2539 label[i].text = (unichar_t *) _("_OK");
2540 label[i].text_is_1byte = true;
2541 label[i].text_in_resource = true;
2542 gcd[i].gd.label = &label[i];
2543 gcd[i].gd.handle_controlevent = AC_OK;
2544 gcd[i].gd.cid = CID_OK;
2545 gcd[i++].creator = GButtonCreate;
2546
2547 gcd[i].gd.pos.x = -10; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+3;
2548 gcd[i].gd.pos.width = -1;
2549 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
2550 label[i].text = (unichar_t *) _("_Cancel");
2551 label[i].text_is_1byte = true;
2552 label[i].text_in_resource = true;
2553 gcd[i].gd.label = &label[i];
2554 gcd[i].gd.handle_controlevent = AC_Cancel;
2555 gcd[i].gd.cid = CID_Cancel;
2556 gcd[i++].creator = GButtonCreate;
2557
2558 buttonarray[0] = GCD_Glue; buttonarray[1] = &gcd[i-2]; buttonarray[2] = GCD_Glue;
2559 buttonarray[3] = GCD_Glue; buttonarray[4] = &gcd[i-1]; buttonarray[5] = GCD_Glue;
2560 buttonarray[6] = NULL;
2561 buttonbox.gd.flags = gg_enabled|gg_visible;
2562 buttonbox.gd.u.boxelements = buttonarray;
2563 buttonbox.creator = GHBoxCreate;
2564 varray[2] = &buttonbox; varray[3] = NULL; varray[4] = NULL;
2565
2566 mainbox[0].gd.pos.x = mainbox[0].gd.pos.y = 2;
2567 mainbox[0].gd.flags = gg_enabled|gg_visible;
2568 mainbox[0].gd.u.boxelements = varray;
2569 mainbox[0].creator = GHVGroupCreate;
2570
2571 GGadgetsCreate(acd.gw,mainbox);
2572 GHVBoxSetExpandableRow(mainbox[0].ret,0);
2573 GHVBoxSetExpandableCol(buttonbox.ret,gb_expandgluesame);
2574 GMatrixEditShowColumn(gcd[0].ret,1,false);
2575
2576 gcd[i].gd.flags = gg_visible | gg_enabled;
2577 label[i].text = (unichar_t *) S_("Anchor Control...");
2578 label[i].text_is_1byte = true;
2579 label[i].text_in_resource = true;
2580 gcd[i].gd.label = &label[i];
2581 gcd[i].gd.cid = CID_ShowAnchors;
2582 gcd[i].gd.handle_controlevent = AnchorClassD_ShowAnchors;
2583 gcd[i].creator = GButtonCreate;
2584
2585 GMatrixEditAddButtons(gcd[0].ret,gcd+i);
2586 GMatrixEditSetOtherButtonEnable(gcd[0].ret,AC_EnableOtherButtons);
2587 GMatrixEditSetNewText(gcd[0].ret,S_("New Anchor Class"));
2588
2589 GDrawSetVisible(acd.gw,true);
2590 while ( !acd.done )
2591 GDrawProcessOneEvent(NULL);
2592 GDrawDestroyWindow(acd.gw);
2593 }
2594
2595 /* ************************************************************************** */
2596 /* ********************** Single/Double Glyph Subtables ********************* */
2597 /* ************************************************************************** */
2598 static int isalphabetic = true, byscripts = true, stemming=true;
2599 int lookup_hideunused = true;
2600 static int ispair;
2601
2602 struct sortinfo {
2603 char *glyphname; /* We replace the glyph name with a pointer to*/
2604 /* this structure, but must restore it when */
2605 /* finished sorting */
2606 SplineChar *sc; /* The glyph itself */
2607 SplineChar *base; /* The base of Agrave would be A */
2608 uint32_t script;
2609 };
2610
2611 static void SortPrep(PSTKernDlg *pstkd, struct matrix_data *md, struct sortinfo *si) {
2612
2613 si->glyphname = md->u.md_str;
2614 md->u.md_ival = (intptr_t) si;
2615
2616 si->sc = SFGetChar(pstkd->sf,-1,si->glyphname);
2617 if ( si->sc==NULL )
2618 return;
2619 if ( byscripts )
2620 si->script = SCScriptFromUnicode(si->sc);
2621 if ( stemming ) {
2622 const unichar_t *alt=NULL;
2623 int uni = si->sc->unicodeenc;
2624 char *pt;
2625
2626 if (isdecompositionnormative(uni) && (alt = unialt(uni)) != NULL)
2627 si->base = SFGetChar(pstkd->sf,alt[0],NULL);
2628 if ( si->base==NULL &&
2629 ((pt=strchr(si->glyphname,'.'))!=NULL ||
2630 (pt=strchr(si->glyphname,'_'))!=NULL )) {
2631 int ch = *pt;
2632 *pt = '\0';
2633 si->base = SFGetChar(pstkd->sf,-1,si->glyphname);
2634 *pt = ch;
2635 }
2636 if ( si->base==NULL )
2637 si->base = si->sc;
2638 }
2639 }
2640
2641 static void SortUnPrep(struct matrix_data *md) {
2642 struct sortinfo *si = (struct sortinfo *) (md->u.md_ival);
2643
2644 md->u.md_str = si->glyphname;
2645 }
2646
2647 static int _md_cmp(const struct sortinfo *md1, const struct sortinfo *md2) {
2648
2649 if ( md1->sc==NULL || md2->sc==NULL ) {
2650 if ( md1->sc!=NULL )
2651 return( 1 );
2652 else if ( md2->sc!=NULL )
2653 return( -1 );
2654 else
2655 return( strcmp( md1->glyphname,md2->glyphname ));
2656 }
2657
2658 if ( byscripts && md1->script!=md2->script ) {
2659 if ( md1->script==DEFAULT_SCRIPT )
2660 return( 1 );
2661 else if ( md2->script==DEFAULT_SCRIPT )
2662 return( -1 );
2663 if ( md1->script>md2->script )
2664 return( 1 );
2665 else
2666 return( -1 );
2667 }
2668
2669 if ( !isalphabetic ) {
2670 int uni1;
2671 int uni2;
2672
2673 if ( stemming ) {
2674 /* First ignore case */
2675 uni1 = (md1->base->unicodeenc!=-1)? md1->base->unicodeenc : 0xffffff;
2676 uni2 = (md2->base->unicodeenc!=-1)? md2->base->unicodeenc : 0xffffff;
2677 if (islower(uni1)) uni1 = toupper(uni1);
2678 if (islower(uni2)) uni2 = toupper(uni2);
2679
2680 if ( uni1>uni2 )
2681 return( 1 );
2682 else if ( uni1<uni2 )
2683 return( -1 );
2684
2685 uni1 = (md1->base->unicodeenc!=-1)? md1->base->unicodeenc : 0xffffff;
2686 uni2 = (md2->base->unicodeenc!=-1)? md2->base->unicodeenc : 0xffffff;
2687 if ( uni1>uni2 )
2688 return( 1 );
2689 else if ( uni1<uni2 )
2690 return( -1 );
2691 }
2692
2693 uni1 = (md1->sc->unicodeenc!=-1)? md1->sc->unicodeenc : 0xffffff;
2694 uni2 = (md2->sc->unicodeenc!=-1)? md2->sc->unicodeenc : 0xffffff;
2695 if ( uni1>uni2 )
2696 return( 1 );
2697 else if ( uni1<uni2 )
2698 return( -1 );
2699 } else {
2700 if ( stemming ) {
2701 int ret;
2702 ret = strcasecmp(md1->base->name,md2->base->name);
2703 if ( ret!=0 )
2704 return( ret );
2705 ret = strcmp(md1->base->name,md2->base->name);
2706 if ( ret!=0 )
2707 return( ret );
2708 }
2709 }
2710 return( strcmp(md1->glyphname,md2->glyphname));
2711 }
2712
2713 static int md_cmp(const void *_md1, const void *_md2) {
2714 const struct matrix_data *md1 = _md1, *md2 = _md2;
2715 int ret = _md_cmp((struct sortinfo *) md1->u.md_ival,(struct sortinfo *) md2->u.md_ival);
2716
2717 if ( ret==0 && ispair )
2718 ret = _md_cmp((struct sortinfo *) md1[1].u.md_ival,(struct sortinfo *) md2[1].u.md_ival);
2719 return( ret );
2720 }
2721
2722 static void PSTKD_DoSort(PSTKernDlg *pstkd,struct matrix_data *psts,int rows,int cols) {
2723 struct sortinfo *primary, *secondary=NULL;
2724 int i;
2725
2726 if ( pstkd->gw!=NULL && GWidgetGetControl(pstkd->gw,CID_Alpha)!=NULL ) {
2727 isalphabetic = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Alpha));
2728 byscripts = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Scripts));
2729 stemming = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_BaseChar));
2730 }
2731 primary = calloc(rows,sizeof(struct sortinfo));
2732 ispair = pstkd->sub->lookup->lookup_type == gpos_pair;
2733 if ( ispair )
2734 secondary = calloc(rows,sizeof(struct sortinfo));
2735 for ( i=0; i<rows; ++i ) {
2736 SortPrep(pstkd,&psts[i*cols+0],&primary[i]);
2737 if ( ispair )
2738 SortPrep(pstkd,&psts[i*cols+1],&secondary[i]);
2739 }
2740 qsort( psts, rows, cols*sizeof(struct matrix_data), md_cmp);
2741 for ( i=0; i<rows; ++i ) {
2742 SortUnPrep(&psts[i*cols+0]);
2743 if ( ispair )
2744 SortUnPrep(&psts[i*cols+1]);
2745 }
2746 free(primary);
2747 free(secondary);
2748 }
2749
2750 static void PST_FreeImage(const void *_pstkd, GImage *img) {
2751 GImageDestroy(img);
2752 }
2753
2754 static GImage *_PST_GetImage(const void *_pstkd) {
2755 PSTKernDlg *pstkd = (PSTKernDlg *) _pstkd;
2756 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
2757 int rows, cols = GMatrixEditGetColCnt(pstk);
2758 struct matrix_data *old = GMatrixEditGet(pstk,&rows);
2759 SplineChar *sc = SFGetChar(pstkd->sf,-1, old[cols*pstkd->popup_r].u.md_str);
2760
2761 return( PST_GetImage(pstk,pstkd->sf,pstkd->def_layer,pstkd->sub,pstkd->popup_r,sc) );
2762 }
2763
2764 static void PST_PopupPrepare(GGadget *g, int r, int c) {
2765 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
2766 int rows, cols = GMatrixEditGetColCnt(g);
2767 struct matrix_data *old = GMatrixEditGet(g,&rows);
2768 if ( c!=0 && pstkd->sub->lookup->lookup_type == gpos_single )
2769 return;
2770 if ( c<0 || c>=cols || r<0 || r>=rows || old[cols*r].u.md_str==NULL ||
2771 SFGetChar(pstkd->sf,-1, old[cols*r].u.md_str)==NULL )
2772 return;
2773 pstkd->popup_r = r;
2774 GGadgetPreparePopupImage(GGadgetGetWindow(g),NULL,pstkd,_PST_GetImage,PST_FreeImage);
2775 }
2776
2777 static void PSTKD_FinishSuffixedEdit(GGadget *g, int row, int col, int wasnew);
2778 static void PSTKD_FinishBoundsEdit(GGadget *g, int row, int col, int wasnew);
2779 static void PSTKD_FinishKernEdit(GGadget *g, int row, int col, int wasnew);
2780 static void PSTKD_InitSameAsRow(GGadget *g, int row);
2781
2782 static int is_boundsFeat( struct lookup_subtable *sub) {
2783 FeatureScriptLangList *features = sub->lookup->features, *testf;
2784
2785 if ( sub->lookup->lookup_type == gpos_single ) {
2786 for ( testf=features; testf!=NULL; testf=testf->next ) {
2787 if ( testf->featuretag==CHR('l','f','b','d'))
2788 return( 1 );
2789 else if ( testf->featuretag==CHR('r','t','b','d'))
2790 return( -1 );
2791 }
2792 }
2793 return( 0 );
2794 }
2795
2796 static void PSTMatrixInit(struct matrixinit *mi,SplineFont *_sf, struct lookup_subtable *sub, PSTKernDlg *pstkd) {
2797 int cnt;
2798 struct matrix_data *md;
2799 static struct col_init simplesubsci[] = {
2800 { me_string , NULL, NULL, NULL, N_("Base Glyph Name") },
2801 { me_string, NULL, NULL, NULL, N_("Replacement Glyph Name") },
2802 COL_INIT_EMPTY
2803 };
2804 static struct col_init ligatureci[] = {
2805 { me_string , NULL, NULL, NULL, N_("Ligature Glyph Name") },
2806 { me_string, NULL, NULL, NULL, N_("Source Glyph Names") },
2807 COL_INIT_EMPTY
2808 };
2809 static struct col_init altmultsubsci[] = {
2810 { me_string , NULL, NULL, NULL, N_("Base Glyph Name") },
2811 { me_string, NULL, NULL, NULL, N_("Replacement Glyph Names") },
2812 COL_INIT_EMPTY
2813 };
2814 #define SIM_DX 1
2815 #define SIM_DY 3
2816 #define SIM_DX_ADV 5
2817 #define SIM_DY_ADV 7
2818 #define PAIR_DX1 2
2819 #define PAIR_DY1 4
2820 #define PAIR_DX_ADV1 6
2821 #define PAIR_DY_ADV1 8
2822 #define PAIR_DX2 10
2823 #define PAIR_DY2 12
2824 #define PAIR_DX_ADV2 14
2825 #define PAIR_DY_ADV2 16
2826 static struct col_init simpleposci[] = {
2827 { me_string , NULL, NULL, NULL, N_("Base Glyph Name") },
2828 { me_int, NULL, NULL, NULL, NU_("∆x") }, /* delta-x */
2829 /* GT: "Adjust" here means Device Table based pixel adjustments, an OpenType */
2830 /* GT: concept which allows small corrections for small pixel sizes where */
2831 /* GT: rounding errors (in kerning for example) may smush too glyphs together */
2832 /* GT: or space them too far apart. Generally not a problem for big pixelsizes*/
2833 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2834 { me_int, NULL, NULL, NULL, NU_("∆y") }, /* delta-y */
2835 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2836 { me_int, NULL, NULL, NULL, NU_("∆x_adv") }, /* delta-x-adv */
2837 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2838 { me_int, NULL, NULL, NULL, NU_("∆y_adv") }, /* delta-y-adv */
2839 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2840 COL_INIT_EMPTY
2841 };
2842 static struct col_init pairposci[] = {
2843 { me_string , NULL, NULL, NULL, N_("First Glyph Name") },
2844 { me_string , NULL, NULL, NULL, N_("Second Glyph Name") },
2845 { me_int, NULL, NULL, NULL, NU_("∆x #1") }, /* delta-x */
2846 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2847 { me_int, NULL, NULL, NULL, NU_("∆y #1") }, /* delta-y */
2848 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2849 { me_int, NULL, NULL, NULL, NU_("∆x_adv #1") }, /* delta-x-adv */
2850 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2851 { me_int, NULL, NULL, NULL, NU_("∆y_adv #1") }, /* delta-y-adv */
2852 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2853 { me_int, NULL, NULL, NULL, NU_("∆x #2") }, /* delta-x */
2854 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2855 { me_int, NULL, NULL, NULL, NU_("∆y #2") }, /* delta-y */
2856 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2857 { me_int, NULL, NULL, NULL, NU_("∆x_adv #2") }, /* delta-x-adv */
2858 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2859 { me_int, NULL, NULL, NULL, NU_("∆y_adv #2") }, /* delta-y-adv */
2860 { me_funcedit, DevTab_Dlg, NULL, NULL, N_("Adjust") },
2861 COL_INIT_EMPTY
2862 };
2863 static struct { int ltype; int cnt; struct col_init *ci; } fuf[] = {
2864 { gsub_single, sizeof(simplesubsci)/sizeof(struct col_init)-1, simplesubsci },
2865 { gsub_multiple, sizeof(altmultsubsci)/sizeof(struct col_init)-1, altmultsubsci },
2866 { gsub_alternate, sizeof(altmultsubsci)/sizeof(struct col_init)-1, altmultsubsci },
2867 { gsub_ligature, sizeof(ligatureci)/sizeof(struct col_init)-1, ligatureci },
2868 { gpos_single, sizeof(simpleposci)/sizeof(struct col_init)-1, simpleposci },
2869 { gpos_pair, sizeof(pairposci)/sizeof(struct col_init)-1, pairposci },
2870 { 0, 0, NULL }
2871 };
2872 static int initted = false;
2873 int lookup_type = sub->lookup->lookup_type;
2874 int isv, r2l = sub->lookup->lookup_flags&pst_r2l;
2875 int i,j, gid,k;
2876 SplineFont *sf;
2877 SplineChar *sc;
2878 PST *pst;
2879 KernPair *kp;
2880
2881 if ( !initted ) {
2882 initted = true;
2883 for ( i=0; fuf[i].ltype!=0; ++i ) if ( fuf[i].ltype!=gsub_alternate ) {
2884 for ( j=0; j<fuf[i].cnt; ++j )
2885 fuf[i].ci[j].title = S_(fuf[i].ci[j].title);
2886 }
2887 }
2888
2889 memset(mi,0,sizeof(*mi));
2890 for ( i=0; fuf[i].ltype!=0 && fuf[i].ltype!=lookup_type; ++i );
2891 if ( fuf[i].ltype==0 ) {
2892 IError( "Unknown lookup type in PSTMatrixInit");
2893 i -= 2;
2894 }
2895 mi->col_cnt = fuf[i].cnt;
2896 mi->col_init = fuf[i].ci;
2897
2898 for ( j=0; j<2; ++j ) {
2899 cnt = 0;
2900 k = 0;
2901 do {
2902 sf = _sf->subfontcnt==0 ? _sf : _sf->subfonts[k];
2903 for ( gid = 0; gid<sf->glyphcnt; ++gid ) if ( (sc=sf->glyphs[gid])!=NULL ) {
2904 for ( pst = sc->possub; pst!=NULL; pst=pst->next ) {
2905 if ( pst->subtable == sub ) {
2906 if ( j ) {
2907 md[cnt*mi->col_cnt].u.md_str = SCNameUniStr( sc );
2908 switch ( lookup_type ) {
2909 case gsub_single:
2910 md[cnt*mi->col_cnt+1].u.md_str = SFNameList2NameUni(sf,pst->u.subs.variant);
2911 break;
2912 case gsub_multiple:
2913 case gsub_alternate:
2914 md[cnt*mi->col_cnt+1].u.md_str = SFNameList2NameUni(sf,pst->u.mult.components);
2915 break;
2916 case gsub_ligature:
2917 md[cnt*mi->col_cnt+1].u.md_str = SFNameList2NameUni(sf,pst->u.lig.components);
2918 break;
2919 case gpos_single:
2920 md[cnt*mi->col_cnt+SIM_DX].u.md_ival = pst->u.pos.xoff;
2921 md[cnt*mi->col_cnt+SIM_DY].u.md_ival = pst->u.pos.yoff;
2922 md[cnt*mi->col_cnt+SIM_DX_ADV].u.md_ival = pst->u.pos.h_adv_off;
2923 md[cnt*mi->col_cnt+SIM_DY_ADV].u.md_ival = pst->u.pos.v_adv_off;
2924 ValDevTabToStrings(md,cnt*mi->col_cnt+SIM_DX+1,pst->u.pos.adjust);
2925 break;
2926 case gpos_pair:
2927 md[cnt*mi->col_cnt+1].u.md_str = SFNameList2NameUni( sf,pst->u.pair.paired );
2928 md[cnt*mi->col_cnt+PAIR_DX1].u.md_ival = pst->u.pair.vr[0].xoff;
2929 md[cnt*mi->col_cnt+PAIR_DY1].u.md_ival = pst->u.pair.vr[0].yoff;
2930 md[cnt*mi->col_cnt+PAIR_DX_ADV1].u.md_ival = pst->u.pair.vr[0].h_adv_off;
2931 md[cnt*mi->col_cnt+PAIR_DY_ADV1].u.md_ival = pst->u.pair.vr[0].v_adv_off;
2932 md[cnt*mi->col_cnt+PAIR_DX2].u.md_ival = pst->u.pair.vr[1].xoff;
2933 md[cnt*mi->col_cnt+PAIR_DY2].u.md_ival = pst->u.pair.vr[1].yoff;
2934 md[cnt*mi->col_cnt+PAIR_DX_ADV2].u.md_ival = pst->u.pair.vr[1].h_adv_off;
2935 md[cnt*mi->col_cnt+PAIR_DY_ADV2].u.md_ival = pst->u.pair.vr[1].v_adv_off;
2936 ValDevTabToStrings(md,cnt*mi->col_cnt+PAIR_DX1+1,pst->u.pair.vr[0].adjust);
2937 ValDevTabToStrings(md,cnt*mi->col_cnt+PAIR_DX2+1,pst->u.pair.vr[1].adjust);
2938 break;
2939 }
2940 }
2941 ++cnt;
2942 }
2943 }
2944 if ( lookup_type==gpos_pair ) {
2945 for ( isv=0; isv<2; ++isv ) {
2946 for ( kp = isv ? sc->vkerns : sc->kerns ; kp!=NULL; kp=kp->next ) {
2947 if ( kp->subtable == sub ) {
2948 if ( j ) {
2949 md[cnt*mi->col_cnt+0].u.md_str = SCNameUniStr( sc );
2950 md[cnt*mi->col_cnt+1].u.md_str = SCNameUniStr( kp->sc );
2951 if ( isv ) {
2952 md[cnt*mi->col_cnt+PAIR_DY_ADV1].u.md_ival = kp->off;
2953 DevTabToString(&md[cnt*mi->col_cnt+PAIR_DY_ADV1+1].u.md_str,kp->adjust);
2954 } else if ( r2l ) {
2955 md[cnt*mi->col_cnt+PAIR_DX_ADV1].u.md_ival = kp->off;
2956 DevTabToString(&md[cnt*mi->col_cnt+PAIR_DX_ADV1+1].u.md_str,kp->adjust);
2957 md[cnt*mi->col_cnt+PAIR_DX1].u.md_ival = kp->off;
2958 DevTabToString(&md[cnt*mi->col_cnt+PAIR_DX1+1].u.md_str,kp->adjust);
2959 } else {
2960 md[cnt*mi->col_cnt+PAIR_DX_ADV1].u.md_ival = kp->off;
2961 DevTabToString(&md[cnt*mi->col_cnt+PAIR_DX_ADV1+1].u.md_str,kp->adjust);
2962 }
2963 }
2964 ++cnt;
2965 }
2966 }
2967 }
2968 }
2969 }
2970 ++k;
2971 } while ( k<_sf->subfontcnt );
2972 if ( !j ) {
2973 mi->initial_row_cnt = cnt;
2974 if ( cnt==0 ) {
2975 md = calloc(mi->col_cnt,sizeof(struct matrix_data));
2976 break;
2977 } else {
2978 md = calloc(mi->col_cnt*cnt,sizeof(struct matrix_data));
2979 }
2980 }
2981 }
2982 PSTKD_DoSort(pstkd,md,cnt,mi->col_cnt);
2983 mi->matrix_data = md;
2984 if ( lookup_type==gsub_single )
2985 mi->finishedit = PSTKD_FinishSuffixedEdit;
2986 else if ( lookup_type==gpos_single ) {
2987 mi->initrow = PSTKD_InitSameAsRow;
2988 if ( is_boundsFeat(sub))
2989 mi->finishedit = PSTKD_FinishBoundsEdit;
2990 } else if ( lookup_type==gpos_pair && !sub->vertical_kerning )
2991 mi->finishedit = PSTKD_FinishKernEdit;
2992 }
2993
2994 static void PSTKD_FinishSuffixedEdit(GGadget *g, int row, int col, int wasnew) {
2995 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
2996 int rows, cols = GMatrixEditGetColCnt(g);
2997 struct matrix_data *psts = _GMatrixEditGet(g,&rows);
2998 char *suffix = GGadgetGetTitle8(GWidgetGetControl(pstkd->gw,CID_Suffix));
2999 SplineChar *alt, *sc;
3000
3001 if ( col!=0 || !wasnew || psts[row*cols+0].u.md_str==NULL )
3002 return;
3003 if ( *suffix=='\0' || ( suffix[0]=='.' && suffix[1]=='\0' ))
3004 return;
3005 sc = SFGetChar(pstkd->sf,-1,psts[row*cols+0].u.md_str);
3006 if ( sc==NULL )
3007 return;
3008 alt = SuffixCheck(sc,suffix);
3009 if ( alt!=NULL )
3010 psts[row*cols+1].u.md_str = copy(alt->name);
3011 }
3012
3013 static void PSTKD_FinishBoundsEdit(GGadget *g, int row, int col, int wasnew) {
3014 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3015 int rows, cols = GMatrixEditGetColCnt(g);
3016 struct matrix_data *psts = _GMatrixEditGet(g,&rows);
3017 int is_bounds = is_boundsFeat(pstkd->sub);
3018 SplineChar *sc;
3019 real loff, roff;
3020
3021 if ( col!=0 || !wasnew || psts[row*cols+0].u.md_str==NULL )
3022 return;
3023 if ( is_bounds==0 )
3024 return;
3025 sc = SFGetChar(pstkd->sf,-1,psts[row*cols+0].u.md_str);
3026 if ( sc==NULL )
3027 return;
3028
3029 GuessOpticalOffset(sc,pstkd->def_layer,&loff,&roff,0);
3030 if ( is_bounds>0 ) {
3031 psts[row*cols+SIM_DX].u.md_ival = -loff;
3032 psts[row*cols+SIM_DX_ADV].u.md_ival = -loff;
3033 } else
3034 psts[row*cols+SIM_DX_ADV].u.md_ival = -roff;
3035 }
3036
3037 static void PSTKD_AddKP(void *data,SplineChar *left, SplineChar *right, int off) {
3038 PSTKernDlg *pstkd = data;
3039 struct matrix_data *psts = pstkd->psts;
3040 int cols = pstkd->cols;
3041 int i;
3042 SplineChar *first=left, *second=right;
3043
3044 if ( pstkd->sub->lookup->lookup_flags & pst_r2l ) {
3045 first = right;
3046 second = left;
3047 }
3048
3049 for ( i=0; i<pstkd->rows_at_start; ++i ) {
3050 /* If the user has already got this combination in the lookup */
3051 /* then don't add a new guess, and don't override the old */
3052 if ( psts[i*cols+0].u.md_str!=NULL && psts[i*cols+1].u.md_str!=NULL &&
3053 strcmp(psts[i*cols+0].u.md_str,first->name)==0 &&
3054 strcmp(psts[i*cols+1].u.md_str,second->name)==0 )
3055 return;
3056 }
3057
3058 i = pstkd->next_row++;
3059 if ( i >= pstkd->rows )
3060 pstkd->psts = psts = realloc(psts,(pstkd->rows += 100)*cols*sizeof(struct matrix_data));
3061 memset(psts+i*cols,0,cols*sizeof(struct matrix_data));
3062 psts[i*cols+0].u.md_str = copy(first->name);
3063 psts[i*cols+1].u.md_str = copy(second->name);
3064 if ( pstkd->sub->lookup->lookup_flags & pst_r2l )
3065 psts[i*cols+PAIR_DX_ADV1].u.md_ival = psts[i*cols+PAIR_DX1].u.md_ival = off;
3066 /* else if ( pstkd->sub->vertical_kerning ) */ /* We don't do vertical stuff */
3067 else
3068 psts[i*cols+PAIR_DX_ADV1].u.md_ival = off;
3069 if ( strcmp(psts[0+0].u.md_str,"T")!=0 )
3070 second = left;
3071 }
3072
3073 static void PSTKD_FinishKernEdit(GGadget *g, int row, int col, int wasnew) {
3074 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3075 int rows, cols = GMatrixEditGetColCnt(g);
3076 struct matrix_data *psts = _GMatrixEditGet(g,&rows);
3077 SplineChar *sc1, *sc2;
3078 SplineChar *lefts[2], *rights[2];
3079 int err, touch, separation;
3080
3081 if ( col>1 || psts[row*cols+0].u.md_str==NULL ||
3082 psts[row*cols+1].u.md_str==NULL ||
3083 psts[row*cols+PAIR_DX1].u.md_ival!=0 ||
3084 psts[row*cols+PAIR_DX_ADV1].u.md_ival!=0 ||
3085 psts[row*cols+PAIR_DY_ADV1].u.md_ival!=0 ||
3086 psts[row*cols+PAIR_DX_ADV2].u.md_ival!=0 )
3087 return;
3088 sc1 = SFGetChar(pstkd->sf,-1,psts[row*cols+0].u.md_str);
3089 sc2 = SFGetChar(pstkd->sf,-1,psts[row*cols+1].u.md_str);
3090 if ( sc1==NULL || sc2==NULL )
3091 return;
3092 lefts[1] = rights[1] = NULL;
3093 if ( pstkd->sub->lookup->lookup_flags & pst_r2l ) {
3094 lefts[0] = sc2;
3095 rights[0] = sc1;
3096 } else {
3097 lefts[0] = sc1;
3098 rights[0] = sc2;
3099 }
3100
3101 err = false;
3102 touch = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Touched));
3103 separation = GetInt8(pstkd->gw,CID_Separation,_("Separation"),&err);
3104 if ( err )
3105 return;
3106
3107 pstkd->cols = GMatrixEditGetColCnt(g);
3108 pstkd->psts = psts;
3109 pstkd->rows_at_start = 0;
3110 pstkd->next_row = row;
3111 pstkd->rows = rows;
3112
3113 AutoKern2(pstkd->sf,pstkd->def_layer,lefts,rights,pstkd->sub,
3114 separation,0,touch,0,0, /* Don't bother with minkern,onlyCloser they asked for this, they get it, whatever it may be */
3115 PSTKD_AddKP,pstkd);
3116 if ( pstkd->psts != psts )
3117 IError("AutoKern added too many pairs, was only supposed to add one");
3118 else
3119 GGadgetRedraw(g);
3120 }
3121
3122 static void PSTKD_InitSameAsRow(GGadget *g, int row) {
3123 GWidget gw = GGadgetGetWindow(g);
3124 int rows, cols = GMatrixEditGetColCnt(g);
3125 struct matrix_data *psts = GMatrixEditGet(g,&rows);
3126
3127 if ( row==0 )
3128 return;
3129 if ( !GGadgetIsChecked(GWidgetGetControl(gw,CID_AllSame)))
3130 return;
3131 psts[row*cols+SIM_DX].u.md_ival = psts[0+SIM_DX].u.md_ival;
3132 psts[row*cols+SIM_DY].u.md_ival = psts[0+SIM_DY].u.md_ival;
3133 psts[row*cols+SIM_DX_ADV].u.md_ival = psts[0+SIM_DX_ADV].u.md_ival;
3134 psts[row*cols+SIM_DY_ADV].u.md_ival = psts[0+SIM_DY_ADV].u.md_ival;
3135 }
3136
3137 static int PSTKD_Sort(GGadget *g, GEvent *e) {
3138 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
3139 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3140 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3141 int rows, cols = GMatrixEditGetColCnt(pstk);
3142 struct matrix_data *old = GMatrixEditGet(pstk,&rows);
3143 PSTKD_DoSort(pstkd,old,rows,cols);
3144 GGadgetRedraw(pstk);
3145 }
3146 return( true );
3147 }
3148
3149 static void PSTKD_DoHideUnused(PSTKernDlg *pstkd) {
3150 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3151 int rows, cols = GMatrixEditGetColCnt(pstk);
3152 struct matrix_data *old = GMatrixEditGet(pstk,&rows);
3153 uint8_t cols_used[20];
3154 int r, col, startc, tot;
3155
3156 startc = ( pstkd->sub->lookup->lookup_type == gpos_single ) ? 1 : 2;
3157 if ( lookup_hideunused ) {
3158 memset(cols_used,0,sizeof(cols_used));
3159 for ( r=0; r<rows; ++r ) {
3160 for ( col=startc; col<cols; col+=2 ) {
3161 if ( old[cols*r+col].u.md_ival!=0 )
3162 cols_used[col] = true;
3163 if ( old[cols*r+col+1].u.md_str!=NULL && *old[cols*r+col+1].u.md_str!='\0' )
3164 cols_used[col+1] = true;
3165 }
3166 }
3167 /* If no columns used (no info yet, all info is to preempt a kernclass and sets to 0) */
3168 /* then show what we expect to be the default column for this kerning mode*/
3169 for ( col=startc, tot=0; col<cols; ++col )
3170 tot += cols_used[col];
3171 if ( tot==0 ) {
3172 if ( startc==1 ) {
3173 cols_used[SIM_DX] = cols_used[SIM_DY] =
3174 cols_used[SIM_DX_ADV] = cols_used[SIM_DY_ADV] = true;
3175 } else {
3176 if ( pstkd->sub->vertical_kerning )
3177 cols_used[PAIR_DY_ADV1] = true;
3178 else if ( pstkd->sub->lookup->lookup_flags&pst_r2l )
3179 cols_used[PAIR_DX_ADV1] = cols_used[PAIR_DX1] = true;
3180 else
3181 cols_used[PAIR_DX_ADV1] = true;
3182 }
3183 }
3184 for ( col=startc; col<cols; ++col )
3185 GMatrixEditShowColumn(pstk,col,cols_used[col]);
3186 } else {
3187 for ( col=startc; col<cols; ++col )
3188 GMatrixEditShowColumn(pstk,col,true);
3189 }
3190 GWidgetToDesiredSize(pstkd->gw);
3191
3192 GGadgetRedraw(pstk);
3193 }
3194
3195 static int PSTKD_HideUnused(GGadget *g, GEvent *e) {
3196 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
3197 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3198 lookup_hideunused = GGadgetIsChecked(g);
3199 PSTKD_DoHideUnused(pstkd);
3200 GGadgetRedraw(GWidgetGetControl(pstkd->gw,CID_PSTList));
3201 }
3202 return( true );
3203 }
3204
3205 static int PSTKD_MagnificationChanged(GGadget *g, GEvent *e) {
3206 if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
3207 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3208 int mag = GGadgetGetFirstListSelectedItem(g);
3209
3210 if ( mag!=-1 && mag!=pstkd->mag-1 ) {
3211 pstkd->mag = mag+1;
3212 GGadgetRedraw(GWidgetGetControl(pstkd->gw,CID_KernDisplay));
3213 }
3214 }
3215 return( true );
3216 }
3217
3218 static int PSTKD_DisplaySizeChanged(GGadget *g, GEvent *e) {
3219 if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) {
3220 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3221 const unichar_t *ret = _GGadgetGetTitle(GWidgetGetControl(pstkd->gw,CID_PixelSize));
3222 unichar_t *end;
3223 int pixelsize = u_strtol(ret,&end,10);
3224
3225 while ( *end==' ' ) ++end;
3226 if ( pixelsize>4 && pixelsize<400 && *end=='\0' ) {
3227 pstkd->pixelsize = pixelsize;
3228 if ( pstkd->display!=NULL ) {
3229 BDFFontFree(pstkd->display);
3230 pstkd->display = NULL;
3231 }
3232 GGadgetRedraw(GWidgetGetControl(pstkd->gw,CID_KernDisplay));
3233 }
3234 }
3235 return( true );
3236 }
3237
3238 static void PSTKD_METextChanged(GGadget *g, int r, int c, GGadget *text) {
3239 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3240 GGadgetRedraw(GWidgetGetControl(pstkd->gw,CID_KernDisplay));
3241 }
3242
3243 static int FigureValue(struct matrix_data *old,int rcol,int c, int startc,
3244 GGadget *tf,double scale, int pixelsize) {
3245 int val;
3246 char *str, *freeme=NULL;
3247 DeviceTable dt;
3248
3249 if ( c==startc && tf!=NULL )
3250 val = u_strtol(_GGadgetGetTitle(tf),NULL,10);
3251 else
3252 val = old[rcol+startc].u.md_ival;
3253 val = rint(val*scale);
3254 if ( c==startc+1 && tf!=NULL )
3255 str = freeme = GGadgetGetTitle8(tf);
3256 else
3257 str = old[rcol+startc+1].u.md_str;
3258 memset(&dt,0,sizeof(dt));
3259 DeviceTableParse(&dt,str);
3260 if ( pixelsize>=dt.first_pixel_size && pixelsize<=dt.last_pixel_size && dt.corrections!=NULL )
3261 val += dt.corrections[pixelsize-dt.first_pixel_size];
3262 free(dt.corrections);
3263 free(freeme);
3264 return( val );
3265 }
3266
3267 static int ParsePSTKVR(PSTKernDlg *pstkd,GGadget *pstk,int startc,struct vr *vr) {
3268 int rows, cols = GMatrixEditGetColCnt(pstk);
3269 struct matrix_data *old = _GMatrixEditGet(pstk,&rows);
3270 GGadget *tf = _GMatrixEditGetActiveTextField(pstk);
3271 int r = GMatrixEditGetActiveRow(pstk);
3272 int c = GMatrixEditGetActiveCol(pstk);
3273 double scale = pstkd->pixelsize/(double) (pstkd->sf->ascent+pstkd->sf->descent);
3274
3275 vr->xoff = FigureValue(old,r*cols,c,startc,tf,scale,pstkd->pixelsize);
3276 vr->yoff = FigureValue(old,r*cols,c,startc+2,tf,scale,pstkd->pixelsize);
3277 vr->h_adv_off = FigureValue(old,r*cols,c,startc+4,tf,scale,pstkd->pixelsize);
3278 vr->v_adv_off = FigureValue(old,r*cols,c,startc+6,tf,scale,pstkd->pixelsize);
3279 return( true );
3280 }
3281
3282 static void PSTKern_DrawGlyph(GWindow pixmap,int x,int y, BDFChar *bc, int mag) {
3283 /* x,y is the location of the origin of the glyph, they need to */
3284 /* be adjusted by the images xmin, ymax, etc. */
3285 struct _GImage base;
3286 GImage gi;
3287 GClut clut;
3288 int scale, l;
3289 Color fg, bg;
3290
3291 scale = bc->depth == 8 ? 8 : 4;
3292
3293 memset(&gi,'\0',sizeof(gi));
3294 memset(&base,'\0',sizeof(base));
3295 memset(&clut,'\0',sizeof(clut));
3296 gi.u.image = &base;
3297 base.clut = &clut;
3298 base.data = bc->bitmap;
3299 base.bytes_per_line = bc->bytes_per_line;
3300 base.width = bc->xmax-bc->xmin+1;
3301 base.height = bc->ymax-bc->ymin+1;
3302 base.image_type = it_index;
3303 clut.clut_len = 1<<scale;
3304 bg = GDrawGetDefaultBackground(NULL);
3305 fg = GDrawGetDefaultForeground(NULL);
3306 for ( l=0; l<(1<<scale); ++l )
3307 clut.clut[l] =
3308 COLOR_CREATE(
3309 COLOR_RED(bg) + (l*(COLOR_RED(fg)-COLOR_RED(bg)))/((1<<scale)-1),
3310 COLOR_GREEN(bg) + (l*(COLOR_GREEN(fg)-COLOR_GREEN(bg)))/((1<<scale)-1),
3311 COLOR_BLUE(bg) + (l*(COLOR_BLUE(fg)-COLOR_BLUE(bg)))/((1<<scale)-1) );
3312
3313 x += bc->xmin;
3314 y -= bc->ymax;
3315
3316 if ( mag==1 )
3317 GDrawDrawImage(pixmap,&gi,NULL,x,y);
3318 else
3319 GDrawDrawImageMagnified(pixmap, &gi, NULL,
3320 x*mag,y*mag,
3321 base.width*mag,base.height*mag);
3322 }
3323
3324 static void PSTKern_Expose(GWindow pixmap, PSTKernDlg *pstkd) {
3325 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3326 int r;
3327 int rows, cols = GMatrixEditGetColCnt(pstk);
3328 struct matrix_data *old = _GMatrixEditGet(pstk,&rows);
3329 SplineChar *sc1, *sc2;
3330 BDFChar *bc1, *bc2;
3331 struct vr vr1, vr2;
3332 int xorig, yorig;
3333 GRect size;
3334 int mag = pstkd->mag;
3335
3336 if ( (r = GMatrixEditGetActiveRow(pstk))==-1 )
3337 return; /* No kerning pair is active */
3338 if ( old[r*cols+0].u.md_str==NULL || old[r*cols+1].u.md_str==NULL )
3339 return; /* No glyphs specified to kern */
3340 sc1 = SFGetChar(pstkd->sf,-1,old[r*cols+0].u.md_str);
3341 sc2 = SFGetChar(pstkd->sf,-1,old[r*cols+1].u.md_str);
3342 if ( sc1==NULL || sc2==NULL )
3343 return; /* The names specified weren't in the font */
3344
3345 if ( !ParsePSTKVR(pstkd,pstk,PAIR_DX1,&vr1) ||
3346 !ParsePSTKVR(pstkd,pstk,PAIR_DX2,&vr2) )
3347 return; /* Couldn't parse the numeric kerning info */
3348
3349 if ( pstkd->display==NULL )
3350 pstkd->display = SplineFontPieceMeal(pstkd->sf,pstkd->def_layer,pstkd->pixelsize,72,pf_antialias,NULL);
3351 bc1 = BDFPieceMealCheck(pstkd->display,sc1->orig_pos);
3352 bc2 = BDFPieceMealCheck(pstkd->display,sc2->orig_pos);
3353
3354 GDrawGetSize(GDrawableGetWindow(GWidgetGetControl(pstkd->gw,CID_KernDisplay)),&size);
3355 if ( pstkd->sub->vertical_kerning ) {
3356 double scale = pstkd->pixelsize/(double) (pstkd->sf->ascent+pstkd->sf->descent);
3357 int vwidth1 = rint( sc1->vwidth*scale ), vwidth2 = rint( sc2->vwidth*scale );
3358 xorig = size.width/10;
3359 yorig = size.height/20;
3360 xorig /= mag; yorig /= mag;
3361 PSTKern_DrawGlyph(pixmap,xorig+vr1.xoff,yorig+vwidth1-vr1.yoff, bc1, mag);
3362 PSTKern_DrawGlyph(pixmap,xorig+vr2.xoff,yorig+vwidth1+vwidth2+vr1.v_adv_off-vr2.yoff, bc2, mag);
3363 } else if ( pstkd->sub->lookup->lookup_flags&pst_r2l ) {
3364 xorig = 9*size.width/10;
3365 yorig = pstkd->sf->ascent*size.height/(pstkd->sf->ascent+pstkd->sf->descent);
3366 GDrawDrawLine(pixmap,xorig+vr1.h_adv_off-vr1.xoff,0,xorig+vr1.h_adv_off-vr1.xoff,size.height, fi_originlinescol);
3367 GDrawDrawLine(pixmap,0,yorig,size.width,yorig, fi_originlinescol);
3368 xorig /= mag; yorig /= mag;
3369 PSTKern_DrawGlyph(pixmap,xorig-bc1->width,yorig-vr1.yoff, bc1, mag);
3370 PSTKern_DrawGlyph(pixmap,xorig-bc1->width-bc2->width-vr2.h_adv_off-vr2.xoff-vr1.xoff,yorig-vr2.yoff, bc2, mag);
3371 } else {
3372 xorig = size.width/10;
3373 yorig = pstkd->sf->ascent*size.height/(pstkd->sf->ascent+pstkd->sf->descent);
3374 GDrawDrawLine(pixmap,xorig,0,xorig,size.height, fi_originlinescol);
3375 GDrawDrawLine(pixmap,0,yorig,size.width,yorig, fi_originlinescol);
3376 xorig /= mag; yorig /= mag;
3377 PSTKern_DrawGlyph(pixmap,xorig+vr1.xoff,yorig-vr1.yoff, bc1, mag);
3378 PSTKern_DrawGlyph(pixmap,xorig+bc1->width+vr1.h_adv_off+vr2.xoff,yorig-vr2.yoff, bc2, mag);
3379 }
3380 }
3381
3382 static void PSTKern_Mouse(PSTKernDlg *pstkd,GEvent *event) {
3383 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3384 int r;
3385 int rows, cols = GMatrixEditGetColCnt(pstk);
3386 struct matrix_data *old = _GMatrixEditGet(pstk,&rows);
3387 int c = GMatrixEditGetActiveCol(pstk);
3388 GGadget *tf = _GMatrixEditGetActiveTextField(pstk);
3389 double scale = pstkd->pixelsize/(double) (pstkd->sf->ascent+pstkd->sf->descent);
3390 int diff, col, col2;
3391 int r2l = pstkd->sub->lookup->lookup_flags&pst_r2l;
3392 char buffer[20];
3393 GCursor ct = ct_mypointer;
3394 GRect size;
3395
3396 if ( (r = GMatrixEditGetActiveRow(pstk))==-1 )
3397 return; /* No kerning pair is active */
3398
3399 if ( pstkd->sub->vertical_kerning ) {
3400 diff = event->u.mouse.y - pstkd->orig_pos;
3401 col = PAIR_DY_ADV1;
3402 } else if ( r2l ) {
3403 diff = pstkd->orig_pos - event->u.mouse.x ;
3404 col = PAIR_DX_ADV1;
3405 col2 = PAIR_DX1;
3406 } else {
3407 diff = event->u.mouse.x - pstkd->orig_pos;
3408 col = PAIR_DX_ADV1;
3409 }
3410
3411 if ( event->type == et_mousedown ) {
3412 pstkd->down = true;
3413 pstkd->orig_pos = pstkd->sub->vertical_kerning ? event->u.mouse.y : event->u.mouse.x;
3414 pstkd->orig_value = FigureValue(old,r*cols,c,col,tf,1.0,-1);
3415 } else if ( pstkd->down ) {
3416 diff = rint(diff/scale);
3417 if ( col==c && tf!=NULL ) {
3418 sprintf( buffer, "%d", pstkd->orig_value + diff);
3419 GGadgetSetTitle8(tf,buffer);
3420 GGadgetRedraw(tf);
3421 } else {
3422 old[r*cols+col].u.md_ival = pstkd->orig_value + diff;
3423 GGadgetRedraw(pstk);
3424 }
3425 if ( r2l ) {
3426 if ( col2==c && tf!=NULL ) {
3427 sprintf( buffer, "%d", pstkd->orig_value + diff);
3428 GGadgetSetTitle8(tf,buffer);
3429 GGadgetRedraw(tf);
3430 } else {
3431 old[r*cols+col2].u.md_ival = pstkd->orig_value + diff;
3432 GGadgetRedraw(pstk);
3433 }
3434 }
3435 GGadgetRedraw(GWidgetGetControl(pstkd->gw,CID_KernDisplay));
3436 if ( event->type == et_mouseup )
3437 pstkd->down = false;
3438 } else if ( event->type == et_mousemove ) {
3439 SplineChar *sc1 = SFGetChar(pstkd->sf,-1,old[r*cols+0].u.md_str);
3440 if (sc1!=NULL ) {
3441 GDrawGetSize(event->w,&size);
3442 if ( r2l ) {
3443 if ( event->u.mouse.x < 9*size.width/10-sc1->width*scale )
3444 ct = ct_kerning;
3445 } else if ( col==PAIR_DX_ADV1 && event->u.mouse.x-size.width/10 > sc1->width*scale ) {
3446 ct = ct_kerning;
3447 }
3448 }
3449 }
3450 if ( ct!=pstkd->cursor_current ) {
3451 GDrawSetCursor(event->w,ct);
3452 pstkd->cursor_current = ct;
3453 }
3454 }
3455
3456 static int pstkern_e_h(GWindow gw, GEvent *event) {
3457 switch ( event->type ) {
3458 case et_char:
3459 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
3460 help("ui/dialogs/lookups.html", "#lookups-pair");
3461 return( true );
3462 }
3463 return( false );
3464 case et_expose:
3465 PSTKern_Expose(gw,GDrawGetUserData(gw));
3466 return( true );
3467 case et_mousedown: case et_mouseup: case et_mousemove:
3468 PSTKern_Mouse(GDrawGetUserData(gw),event);
3469 return( true );
3470 default: break;
3471 }
3472 return( true );
3473 }
3474
3475 static int SCReasonable(SplineChar *sc) {
3476 if ( sc==NULL )
3477 return( false );
3478 if ( strcmp(sc->name,".notdef")==0 ||
3479 strcmp(sc->name,".null")==0 ||
3480 strcmp(sc->name,"nonmarkingreturn")==0 )
3481 return( false );
3482
3483 return( true );
3484 }
3485
3486 static struct matrix_data *MDCopy(struct matrix_data *old,int rows,int cols) {
3487 struct matrix_data *md = malloc(rows*cols*sizeof(struct matrix_data));
3488 int r;
3489
3490 memcpy(md,old,rows*cols*sizeof(struct matrix_data));
3491 for ( r=0; r<rows; ++r ) {
3492 md[r*cols+0].u.md_str = copy(md[r*cols+0].u.md_str);
3493 if ( cols==2 /* subs, lig, alt, etc. */ || cols>=10 /* kerning */ )
3494 md[r*cols+1].u.md_str = copy(md[r*cols+1].u.md_str);
3495 }
3496 return( md );
3497 }
3498
3499 static int SCNameUnused(char *name,struct matrix_data *old,int rows,int cols) {
3500 int r;
3501
3502 for ( r=0; r<rows; ++r ) {
3503 if ( old[r*cols+0].u.md_str!=NULL && strcmp(old[r*cols+0].u.md_str,name)==0 ) {
3504 if (( cols==2 && (old[r*cols+1].u.md_str == NULL || *old[r*cols+1].u.md_str=='\0')) ||
3505 (cols==5 && old[r*cols+1].u.md_ival==0 &&
3506 old[r*cols+2].u.md_ival==0 &&
3507 old[r*cols+3].u.md_ival==0 &&
3508 old[r*cols+4].u.md_ival==0 ))
3509 return( r ); /* There's an entry, but it's blank, fill it if we can */
3510 else
3511 return( -1 );
3512 }
3513 }
3514 return( r ); /* Off end of list */
3515 }
3516
3517 static int SCIsLigature(SplineChar *sc) {
3518 int len;
3519 const unichar_t *alt=NULL;
3520
3521 if ( strchr(sc->name,'_')!=NULL )
3522 return( true );
3523 len = strlen( sc->name );
3524 if ( strncmp(sc->name,"uni",3)==0 && (len-3)%4==0 && len>7 )
3525 return( true );
3526
3527 if ( isdecompositionnormative(sc->unicodeenc) &&
3528 (alt = unialt(sc->unicodeenc))!=NULL ) {
3529 if ( alt[1]=='\0' )
3530 return( false ); /* Single replacements aren't ligatures */
3531 else if ( iscombining(alt[1]) && ( alt[2]=='\0' || iscombining(alt[2])))
3532 return( false ); /* Nor am I interested in accented letters */
3533 else
3534 return( true );
3535 } else
3536 return( false );
3537 }
3538
3539 enum pop_type { pt_all, pt_suffixed, pt_selected };
3540
3541 static void PSTKD_DoPopulate(PSTKernDlg *pstkd,char *suffix, enum pop_type pt) {
3542 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3543 int rows, row_max, old_rows, cols = GMatrixEditGetColCnt(pstk);
3544 struct matrix_data *old = GMatrixEditGet(pstk,&rows), *psts;
3545 int pos;
3546 int gid,k;
3547 SplineChar *sc, *alt;
3548 int enc;
3549 SplineFont *sf = pstkd->sf;
3550 FontView *fv = (FontView *) sf->fv;
3551 EncMap *map = fv->b.map;
3552 GGadget *gallsame = GWidgetGetControl(pstkd->gw,CID_AllSame);
3553 int allsame = false;
3554 FeatureScriptLangList *features = pstkd->sub->lookup->features;
3555
3556 if ( gallsame!=NULL )
3557 allsame = GGadgetIsChecked(gallsame);
3558
3559 psts = MDCopy(old,rows,cols);
3560 old_rows = row_max = rows;
3561 k = 0;
3562 do {
3563 sf = pstkd->sf->subfontcnt==0 ? pstkd->sf : pstkd->sf->subfonts[k];
3564 for ( gid=0; gid<sf->glyphcnt; ++gid ) {
3565 if ( SCReasonable(sc = sf->glyphs[gid]) &&
3566 (pt==pt_selected || ScriptInFeatureScriptList(SCScriptFromUnicode(sc),
3567 features)) &&
3568 (pt!=pt_selected || (gid<fv->b.sf->glyphcnt &&
3569 (enc = map->backmap[gid])!=-1 &&
3570 fv->b.selected[enc])) &&
3571 (pos = SCNameUnused(sc->name,old,old_rows,cols))!=-1 &&
3572 (pstkd->sub->lookup->lookup_type!=gsub_ligature ||
3573 SCIsLigature(sc)) ) {
3574 alt = NULL;
3575 if ( suffix!=NULL ) {
3576 alt = SuffixCheck(sc,suffix);
3577 if ( pt==pt_suffixed && alt==NULL )
3578 continue;
3579 }
3580 if ( pos==old_rows ) {
3581 pos = rows;
3582 if ( rows>=row_max ) {
3583 if ( row_max< sf->glyphcnt-10 )
3584 row_max = sf->glyphcnt;
3585 else
3586 row_max += 15;
3587 psts = realloc(psts,row_max*cols*sizeof(struct matrix_data));
3588 }
3589 memset(psts+rows*cols,0,cols*sizeof(struct matrix_data));
3590 psts[rows*cols+0].u.md_str = copy(sc->name);
3591 ++rows;
3592 }
3593 if ( alt!=NULL )
3594 psts[pos*cols+1].u.md_str = copy(alt->name);
3595 else if ( allsame && pos!=0 ) {
3596 psts[pos*cols+SIM_DX].u.md_ival = psts[0+SIM_DX].u.md_ival;
3597 psts[pos*cols+SIM_DY].u.md_ival = psts[0+SIM_DY].u.md_ival;
3598 psts[pos*cols+SIM_DX_ADV].u.md_ival = psts[0+SIM_DX_ADV].u.md_ival;
3599 psts[pos*cols+SIM_DY_ADV].u.md_ival = psts[0+SIM_DY_ADV].u.md_ival;
3600 } else if ( pstkd->sub->lookup->lookup_type!=gpos_pair )
3601 SCSubtableDefaultSubsCheck(sc,pstkd->sub,psts,cols,pos,pstkd->def_layer);
3602 }
3603 }
3604 ++k;
3605 } while ( k<pstkd->sf->subfontcnt );
3606 if ( rows<row_max )
3607 psts = realloc(psts,rows*cols*sizeof(struct matrix_data));
3608 PSTKD_DoSort(pstkd,psts,rows,cols);
3609 GMatrixEditSet(pstk,psts,rows,false);
3610 GGadgetRedraw(pstk);
3611 }
3612
3613 static void PSTKD_SetSuffix(PSTKernDlg *pstkd) {
3614 char *suffix;
3615
3616 if ( pstkd->sub->lookup->lookup_type!=gsub_single )
3617 return; /* Not applicable */
3618
3619 suffix = GGadgetGetTitle8(GWidgetGetControl(pstkd->gw,CID_Suffix));
3620 if ( *suffix!='\0' && ( suffix[0]!='.' || suffix[1]!='\0' )) {
3621 free(pstkd->sub->suffix);
3622 pstkd->sub->suffix = ( *suffix=='.' ) ? copy(suffix+1): copy(suffix);
3623 free(suffix);
3624 }
3625 }
3626
3627 static int PSTKD_PopulateWithSuffix(GGadget *g, GEvent *e) {
3628 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3629 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3630 char *suffix = GGadgetGetTitle8(GWidgetGetControl(pstkd->gw,CID_Suffix));
3631 if ( *suffix!='\0' && ( suffix[0]!='.' || suffix[1]!='\0' )) {
3632 PSTKD_DoPopulate(pstkd,suffix, pt_suffixed);
3633 PSTKD_SetSuffix(pstkd);
3634 }
3635 free(suffix);
3636 }
3637 return( true );
3638 }
3639
3640 static int PSTKD_Populate(GGadget *g, GEvent *e) {
3641 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3642 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3643 GGadget *gsuffix = GWidgetGetControl(pstkd->gw,CID_Suffix);
3644 char *suffix = NULL;
3645 if ( gsuffix != NULL ) {
3646 suffix = GGadgetGetTitle8(gsuffix);
3647 if ( *suffix=='\0' || ( suffix[0]=='.' && suffix[1]=='\0' )) {
3648 free(suffix);
3649 suffix = NULL;
3650 }
3651 }
3652 PSTKD_SetSuffix(pstkd);
3653 PSTKD_DoPopulate(pstkd,suffix,pt_all);
3654 free(suffix);
3655 }
3656 return( true );
3657 }
3658
3659 static int PSTKD_PopulateSelected(GGadget *g, GEvent *e) {
3660 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3661 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3662 GGadget *gsuffix = GWidgetGetControl(pstkd->gw,CID_Suffix);
3663 char *suffix = NULL;
3664 if ( gsuffix != NULL ) {
3665 suffix = GGadgetGetTitle8(gsuffix);
3666 if ( *suffix=='\0' || ( suffix[0]=='.' && suffix[1]=='\0' )) {
3667 free(suffix);
3668 suffix = NULL;
3669 }
3670 }
3671 PSTKD_SetSuffix(pstkd);
3672 PSTKD_DoPopulate(pstkd,suffix,pt_selected);
3673 free(suffix);
3674 }
3675 return( true );
3676 }
3677
3678 static int PSTKD_DoAutoKern(PSTKernDlg *pstkd,SplineChar **glyphlist) {
3679 int err, touch, separation, minkern, onlyCloser;
3680
3681 if ( !GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Autokern)) )
3682 return( false );
3683
3684 err = false;
3685 touch = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Touched));
3686 separation = GetInt8(pstkd->gw,CID_Separation,_("Separation"),&err);
3687 minkern = GetInt8(pstkd->gw,CID_MinKern,_("Min Kern"),&err);
3688 onlyCloser = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_OnlyCloser));
3689 if ( err )
3690 return( false );
3691 AutoKern2(pstkd->sf,pstkd->def_layer,glyphlist,glyphlist,pstkd->sub,
3692 separation,minkern,touch,onlyCloser,0,
3693 PSTKD_AddKP,pstkd);
3694 return( true );
3695 }
3696
3697 static int PSTKD_AutoKern(GGadget *g, GEvent *e) {
3698 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3699 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3700 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3701 int rows, cols = GMatrixEditGetColCnt(pstk);
3702 struct matrix_data *old = GMatrixEditGet(pstk,&rows);
3703 SplineFont *sf = pstkd->sf;
3704 int i,gid,cnt;
3705 SplineChar **list, *sc;
3706 FeatureScriptLangList *features = pstkd->sub->lookup->features, *testf;
3707 struct scriptlanglist *scripts;
3708 uint32_t *scripttags;
3709
3710 pstkd->cols = GMatrixEditGetColCnt(pstk);
3711 pstkd->psts = MDCopy(old,rows,cols);
3712 pstkd->rows_at_start = pstkd->rows = pstkd->next_row = rows;
3713
3714 for ( testf=features,cnt=0; testf!=NULL; testf=testf->next ) {
3715 for ( scripts=testf->scripts; scripts!=NULL; scripts=scripts->next )
3716 ++cnt;
3717 }
3718 if ( cnt==0 ) {
3719 ff_post_error(_("No scripts"),_("There are no scripts bound to features bound to this lookup. So nothing happens." ));
3720 return(true);
3721 }
3722 scripttags = malloc((cnt+1)*sizeof(uint32_t));
3723 for ( testf=features,cnt=0; testf!=NULL; testf=testf->next ) {
3724 for ( scripts=testf->scripts; scripts!=NULL; scripts=scripts->next ) {
3725 for ( i=0; i<cnt; ++i )
3726 if ( scripttags[i]==scripts->script )
3727 break;
3728 if ( i==cnt )
3729 scripttags[cnt++] = scripts->script;
3730 }
3731 }
3732 scripttags[cnt] = 0;
3733
3734 list = malloc((sf->glyphcnt+1)*sizeof(SplineChar *));
3735 for ( i=0; scripttags[i]!=0; ++i ) {
3736 uint32_t script = scripttags[i];
3737
3738 for ( cnt=gid=0; gid<sf->glyphcnt; ++gid ) {
3739 if ( (sc = sf->glyphs[gid])!=NULL &&
3740 SCWorthOutputting(sc) &&
3741 SCScriptFromUnicode(sc)==script )
3742 list[cnt++] = sc;
3743 }
3744 list[cnt] = NULL;
3745 PSTKD_DoAutoKern(pstkd,list);
3746 }
3747 free(list);
3748 free(scripttags);
3749 if ( pstkd->next_row<pstkd->rows )
3750 pstkd->psts = realloc(pstkd->psts,pstkd->rows*cols*sizeof(struct matrix_data));
3751 PSTKD_DoSort(pstkd,pstkd->psts,pstkd->next_row,cols);
3752 GMatrixEditSet(pstk,pstkd->psts,pstkd->next_row,false);
3753 GGadgetRedraw(pstk);
3754 }
3755 return( true );
3756 }
3757
3758 static int PSTKD_AutoKernSelected(GGadget *g, GEvent *e) {
3759 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3760 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3761 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3762 int rows, cols = GMatrixEditGetColCnt(pstk);
3763 struct matrix_data *old = GMatrixEditGet(pstk,&rows);
3764 SplineFont *sf = pstkd->sf;
3765 FontViewBase *fv = sf->fv;
3766 int enc,gid,cnt;
3767 SplineChar **list, *sc;
3768
3769 pstkd->cols = GMatrixEditGetColCnt(pstk);
3770 pstkd->psts = MDCopy(old,rows,cols);
3771 pstkd->rows_at_start = pstkd->rows = pstkd->next_row = rows;
3772
3773 for ( enc=0,cnt=0; enc<fv->map->enccount; ++enc ) {
3774 if ( fv->selected[enc] && (gid=fv->map->map[enc])!=-1 &&
3775 SCWorthOutputting(sc = sf->glyphs[gid]))
3776 ++cnt;
3777 }
3778 list = malloc((cnt+1)*sizeof(SplineChar *));
3779 for ( enc=0,cnt=0; enc<fv->map->enccount; ++enc ) {
3780 if ( fv->selected[enc] && (gid=fv->map->map[enc])!=-1 &&
3781 SCWorthOutputting(sc = sf->glyphs[gid]))
3782 list[cnt++] = sc;
3783 }
3784 list[cnt] = NULL;
3785 PSTKD_DoAutoKern(pstkd,list);
3786 free(list);
3787 if ( pstkd->next_row<pstkd->rows )
3788 pstkd->psts = realloc(pstkd->psts,pstkd->rows*cols*sizeof(struct matrix_data));
3789 PSTKD_DoSort(pstkd,pstkd->psts,pstkd->next_row,cols);
3790 GMatrixEditSet(pstk,pstkd->psts,pstkd->next_row,false);
3791 GGadgetRedraw(pstk);
3792 }
3793 return( true );
3794 }
3795
3796 static int PSTKD_RemoveAll(GGadget *g, GEvent *e) {
3797 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3798 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3799 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3800 int cols = GMatrixEditGetColCnt(pstk);
3801 struct matrix_data *psts=NULL;
3802
3803 psts = calloc(cols,sizeof(struct matrix_data));
3804 GMatrixEditSet(pstk,psts,0,false);
3805 }
3806 return( true );
3807 }
3808
3809 static int PSTKD_RemoveEmpty(GGadget *g, GEvent *e) {
3810 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
3811 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
3812 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
3813 int rows, cols = GMatrixEditGetColCnt(pstk);
3814 struct matrix_data *old = GMatrixEditGet(pstk,&rows), *psts=NULL;
3815 int r, empty, rm_cnt, j;
3816
3817 for ( r=rows-1, rm_cnt=0; r>=0; --r ) {
3818 if ( pstkd->sub->lookup->lookup_type==gpos_single )
3819 empty = old[r*cols+SIM_DX].u.md_ival==0 &&
3820 old[r*cols+SIM_DY].u.md_ival==0 &&
3821 old[r*cols+SIM_DX_ADV].u.md_ival==0 &&
3822 old[r*cols+SIM_DY_ADV].u.md_ival==0;
3823 else
3824 empty = old[r*cols+1].u.md_str == NULL || *old[r*cols+1].u.md_str=='\0';
3825 if ( empty ) {
3826 if ( psts==NULL )
3827 psts = MDCopy(old,rows,cols);
3828 free(psts[r*cols+0].u.md_str);
3829 if ( cols!=5 )
3830 free(psts[r*cols+1].u.md_str);
3831 for ( j=r+1; j<rows-rm_cnt; ++j )
3832 memcpy(psts+(j-1)*cols,psts+j*cols,
3833 cols*sizeof(struct matrix_data));
3834 ++rm_cnt;
3835 }
3836 }
3837 if ( rm_cnt!=0 ) {
3838 /* Some reallocs explode if given a size of 0 */
3839 psts = realloc(psts,(rows-rm_cnt+1)*cols*sizeof(struct matrix_data));
3840 GMatrixEditSet(pstk,psts,rows-rm_cnt,false);
3841 }
3842 }
3843 return( true );
3844 }
3845
3846 void SFUntickAllPSTandKern(SplineFont *sf)
3847 {
3848 SplineChar *sc;
3849 PST *pst;
3850 KernPair *kp;
3851 int gid, isv;
3852 for ( gid=0; gid<sf->glyphcnt; ++gid ) {
3853 if ( (sc = sf->glyphs[gid])!=NULL ) {
3854 for ( pst = sc->possub; pst!=NULL; pst=pst->next )
3855 pst->ticked = false;
3856 for ( isv=0; isv<2; ++isv )
3857 for ( kp = isv ? sc->vkerns : sc->kerns; kp!=NULL; kp=kp->next )
3858 kp->kcid = 0;
3859 }
3860 }
3861 }
3862
3863
3864
3865 /**
3866 * Return true of the splinechar has any horizontal or vert kerns.
3867 */
3868 static int SCHasAnyKerns(SplineChar *sc) {
3869 KernPair *kp;
3870 int v;
3871 int ret = 0;
3872 for ( v=0; v<2; ++v ) {
3873 kp = v ? sc->vkerns : sc->kerns;
3874 if ( kp!=NULL ) {
3875 ret = 1;
3876 }
3877 }
3878 return ret;
3879 }
3880
3881
3882 int kernsLength( KernPair *kp ) {
3883 if( !kp )
3884 return 0;
3885 int i = 0;
3886 for ( ; kp; kp=kp->next ) {
3887 ++i;
3888 }
3889 return i;
3890 }
3891
3892 static int kerncomp(const void *_r1, const void *_r2) {
3893 const KernPair *kp1 = *(KernPair * const *)_r1;
3894 const KernPair *kp2 = *(KernPair * const *)_r2;
3895 if( kp1->sc->orig_pos == kp2->sc->orig_pos )
3896 return 0;
3897 if( kp1->sc->orig_pos < kp2->sc->orig_pos )
3898 return -1;
3899 return 1;
3900 }
3901
3902 /**
3903 * This will sort both the kerns and vkerns for the splinefont so that
3904 * the list is in the order of "orig_pos" for each kernpair.
3905 *
3906 * Sometimes FontForge had two KernPair lists which were identical but
3907 * where not sorted the same way, using this function will force a
3908 * specific ordering on the KernPair list to make performing a lexical
3909 * "diff" between two serialized KernPair lists work as expected.
3910 */
3911 static void SCKernsSort( SplineChar *sc ) {
3912 KernPair *kp;
3913 int v;
3914 KernPair *cur;
3915 KernPair *newlist = 0;
3916 for ( v=0; v<2; ++v ) {
3917 kp = v ? sc->vkerns : sc->kerns;
3918 if ( kp!=NULL ) {
3919 int idx = 0;
3920 int length = kernsLength(kp);
3921 if( length == 0 ) {
3922 // nothing is always sorted already!
3923 continue;
3924 }
3925
3926 KernPair** ordered = malloc( sizeof(KernPair*) * length+1 );
3927 // copy to temp array
3928 idx = 0;
3929 for ( cur = kp; cur; cur=cur->next ) {
3930 ordered[idx] = cur;
3931 idx++;
3932 }
3933 // sort array using easy swap()
3934 qsort(ordered,length,sizeof(KernPair*),kerncomp);
3935
3936 // and back to a linked list again
3937 newlist = ordered[0];
3938 ordered[length-1]->next = 0;
3939 for( idx = 0; idx < length-1; idx++ ) {
3940 ordered[idx]->next = ordered[idx+1];
3941 }
3942 free( ordered );
3943
3944 // now change the right kerns member of sc
3945 if( v ) sc->vkerns = newlist;
3946 else sc->kerns = newlist;
3947 }
3948 }
3949 }
3950
3951 extern char* SFDCreateUndoForLookup( SplineFont *sf, int lookup_type );
3952
3953 /**
3954 * Create a fragment of SFD file which represents the state of the
3955 * lookup_type for the given splinefont.
3956 *
3957 * Note that the kernpair lists may be modified by this function in
3958 * that those lists might be sorted on return.
3959 *
3960 * The caller needs to free() the returned string value.
3961 */
3962 char* SFDCreateUndoForLookup( SplineFont *sf, int lookup_type )
3963 {
3964 int gid = 0;
3965 SplineChar *sc = 0;
3966 PST *pst = 0;
3967 FILE* sfd = GFileTmpfile();
3968 SFD_DumpLookup( sfd, sf );
3969 for ( gid=0; gid<sf->glyphcnt; ++gid )
3970 {
3971 if ( (sc = sf->glyphs[gid])!=NULL )
3972 {
3973 int haveStartMarker = 0;
3974 if(lookup_type==gpos_pair)
3975 {
3976 haveStartMarker = 1;
3977 SFDDumpCharStartingMarker( sfd, sc );
3978
3979 if( SCHasAnyKerns(sc) )
3980 {
3981 SCKernsSort( sc );
3982 SFD_DumpKerns( sfd, sc, 0 );
3983 }
3984 }
3985 else
3986 {
3987 for ( pst = sc->possub; pst; pst=pst->next )
3988 {
3989 if( !haveStartMarker )
3990 {
3991 haveStartMarker = 1;
3992 SFDDumpCharStartingMarker( sfd, sc );
3993 }
3994 SFD_DumpPST( sfd, sc );
3995 }
3996 }
3997 if( haveStartMarker )
3998 {
3999 fprintf(sfd,"EndChar\n" );
4000 }
4001 }
4002 }
4003
4004 char* str = FileToAllocatedString( sfd );
4005 fclose(sfd);
4006 return(str);
4007 }
4008
4009 static SplineChar* SCFindByGlyphName( SplineFont *sf, char* n ) {
4010 int i=0;
4011 for ( i=0; i<sf->glyphcnt; ++i ) {
4012 if ( sf->glyphs[i]!=NULL ) {
4013 SplineChar *sc = sf->glyphs[i];
4014 if( !strcmp( sc->name, n )) {
4015 return sc;
4016 }
4017 }
4018 }
4019 return 0;
4020 }
4021
4022
4023 static void SFDTrimUndoOldToNew_Output( FILE* retf, char* glyph, char* line ) {
4024 fwrite( "StartChar:", strlen("StartChar:"), 1, retf );
4025 fwrite( glyph, strlen(glyph), 1, retf );
4026 fwrite( "\n", 1, 1, retf );
4027 fwrite( line, strlen(line), 1, retf );
4028 fwrite( "\n", 1, 1, retf );
4029 fwrite( "EndChar\n", strlen("EndChar\n"), 1, retf );
4030 }
4031
4032 /**
4033 * Given two SFD fragments, oldstr and newstr, compare them and remove
4034 * the SFD for glyphs which have not changed state significantly
4035 * between old and new.
4036 *
4037 * This can be very handy for fonts like DroidSans which have kerning
4038 * table which is about 2mb in SFD format. If you only change the
4039 * kerning for a 10 glyphs then the resulting SFD from this function
4040 * might be only in the 10-50kb size instead of megabytes.
4041 *
4042 * The caller needs to free the return value.
4043 */
4044 static char* SFDTrimUndoOldToNew( SplineFont *sf, char* oldstr, char* newstr ) {
4045
4046 if( !oldstr || !newstr ) {
4047 return 0;
4048 }
4049
4050 /* open temporary files */
4051 FILE *of, *nf, *retf;
4052 if ( !(retf=GFileTmpfile()) )
4053 goto error0SFDTrimUndoOldToNew;
4054 if ( !(of=GFileTmpfile()) )
4055 goto error1SFDTrimUndoOldToNew;
4056 if ( !(nf=GFileTmpfile()) )
4057 goto error2SFDTrimUndoOldToNew;
4058
4059 int glyphsWithUndoInfoCount = 0;
4060 fwrite( oldstr, strlen(oldstr), 1, of );
4061 fwrite( newstr, strlen(newstr), 1, nf );
4062 fseek( of, 0, SEEK_SET );
4063 fseek( nf, 0, SEEK_SET );
4064
4065 char* oglyph = 0;
4066 char* nglyph = 0;
4067 char* oline = 0;
4068 char* nline = 0;
4069
4070 // copy the header from the old SFD fragment
4071 while((oline = getquotedeol(of)) && !feof(of)) {
4072 if( !strnmatch( oline, "StartChar:", strlen( "StartChar:" ))) {
4073 int len = strlen("StartChar:");
4074 while( oline[len] && oline[len] == ' ' )
4075 len++;
4076 oglyph = copy( oline+len );
4077 break;
4078 }
4079 fwrite( oline, strlen(oline), 1, retf );
4080 fwrite( "\n", 1, 1, retf );
4081 free(oline);
4082 }
4083
4084 while (oglyph) {
4085 oline = getquotedeol(of);
4086 SplineChar* oldsc = SCFindByGlyphName( sf, oglyph );
4087 int newGlyphsSeen = 0;
4088
4089 while ((nglyph = SFDMoveToNextStartChar(nf))) {
4090 newGlyphsSeen++;
4091 SplineChar* newsc = SCFindByGlyphName( sf, nglyph );
4092 if( !newsc || !oldsc ) {
4093 goto error3SFDTrimUndoOldToNew;
4094 }
4095 /**
4096 * If the user has deleted a whole glyph from the SFD
4097 * fragment then the nglyph in the new list will be
4098 * *after* oglyph in the ordering. If that's the case then
4099 * we have to output oglyph and read another glyph from
4100 * the old list.
4101 */
4102 while( newsc->orig_pos > oldsc->orig_pos ) {
4103 glyphsWithUndoInfoCount++;
4104 SFDTrimUndoOldToNew_Output( retf, oglyph, oline );
4105 free(oline);
4106 oglyph = SFDMoveToNextStartChar(of);
4107 oline = getquotedeol(of);
4108 oldsc = SCFindByGlyphName( sf, oglyph );
4109 }
4110
4111 nline = getquotedeol(nf);
4112 if( !oline || !nline ) {
4113 fprintf(stderr,"failed to read new or old files during SFD diff. Returning entire new data as diff!\n");
4114 goto error3SFDTrimUndoOldToNew;
4115 }
4116 if( strcmp( oglyph, nglyph )) {
4117 // fprintf(stderr,"mismatch between old and new SFD fragments. Skipping new glyph that is not in old...\n");
4118 glyphsWithUndoInfoCount++;
4119 SFDTrimUndoOldToNew_Output( retf, nglyph, "Kerns2: " );
4120 free(nline);
4121 continue;
4122 }
4123
4124 if( !strcmp( oline, nline )) {
4125 // printf("old and new have the same data, skipping glyph:%s\n", oglyph );
4126 break;
4127 }
4128
4129 glyphsWithUndoInfoCount++;
4130 SFDTrimUndoOldToNew_Output( retf, oglyph, oline );
4131 free(nline);
4132 break;
4133 }
4134
4135 /**
4136 * There is one or more old glyphs which do not have a new glyph
4137 * in the SFD fragments, preserve those old SFD fragments.
4138 */
4139 if( !newGlyphsSeen ) {
4140 glyphsWithUndoInfoCount++;
4141 SFDTrimUndoOldToNew_Output( retf, oglyph, oline );
4142 }
4143
4144 free(oline);
4145 oglyph = SFDMoveToNextStartChar(of);
4146 }
4147 fclose(of);
4148
4149 /* Trailing new glyph data that has nothing in the old file.
4150 *
4151 * we don't care what the data is if its new,
4152 * we only want to be able to revert to the old state (nothing)
4153 */
4154 while ((nglyph = SFDMoveToNextStartChar(nf))) {
4155 SCFindByGlyphName( sf, nglyph );
4156 nline = getquotedeol(nf);
4157 glyphsWithUndoInfoCount++;
4158 SFDTrimUndoOldToNew_Output( retf, nglyph, "Kerns2: " );
4159 }
4160 fclose(nf);
4161
4162 if( !glyphsWithUndoInfoCount )
4163 goto error1SFDTrimUndoOldToNew;
4164
4165 char* ret = FileToAllocatedString( retf );
4166 fclose(retf);
4167 return ret;
4168
4169 error3SFDTrimUndoOldToNew: fclose(of);
4170 error2SFDTrimUndoOldToNew: fclose(nf);
4171 error1SFDTrimUndoOldToNew: fclose(retf);
4172 error0SFDTrimUndoOldToNew:
4173 return 0;
4174 }
4175
4176
4177
4178 static int PSTKD_Ok(GGadget *g, GEvent *e) {
4179
4180 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
4181 PSTKernDlg *pstkd = GDrawGetUserData(GGadgetGetWindow(g));
4182 GGadget *pstk = GWidgetGetControl(pstkd->gw,CID_PSTList);
4183 int rows, cols = GMatrixEditGetColCnt(pstk);
4184 struct matrix_data *psts = GMatrixEditGet(pstk,&rows);
4185 int r, r1, k, gid, isv, ch;
4186 char *pt, *start;
4187 int lookup_type = pstkd->sub->lookup->lookup_type;
4188 SplineFont *sf = NULL;
4189 SplineChar *sc, *found;
4190 char *buts[3];
4191 KernPair *kp, *kpprev, *kpnext;
4192 PST *pst, *pstprev, *pstnext;
4193 int err, touch=0, separation=0, minkern=0, onlyCloser=0, autokern=0;
4194 int _t = lookup_type == gpos_single ? pst_position
4195 : lookup_type == gpos_pair ? pst_pair
4196 : lookup_type == gsub_single ? pst_substitution
4197 : lookup_type == gsub_alternate ? pst_alternate
4198 : lookup_type == gsub_multiple ? pst_multiple
4199 : pst_ligature;
4200
4201 /* First check for errors */
4202 if ( lookup_type==gpos_pair ) {
4203 /* bad metadata */
4204 err = false;
4205 touch = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Touched));
4206 separation = GetInt8(pstkd->gw,CID_Separation,_("Separation"),&err);
4207 minkern = GetInt8(pstkd->gw,CID_MinKern,_("Min Kern"),&err);
4208 onlyCloser = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_OnlyCloser));
4209 autokern = GGadgetIsChecked(GWidgetGetControl(pstkd->gw,CID_Autokern));
4210 if ( err )
4211 return( true );
4212 }
4213
4214 /* Glyph names that aren't in the font */
4215 for ( r=0; r<rows; ++r ) {
4216 if ( SFGetChar(pstkd->sf,-1,psts[r*cols+0].u.md_str)==NULL ) {
4217 ff_post_error( _("Missing glyph"),_("There is no glyph named %s in the font"),
4218 psts[cols*r+0].u.md_str );
4219 return( true );
4220 }
4221 }
4222 /* Empty entries */
4223 if ( cols==2 || cols==10 ) {
4224 for ( r=0; r<rows; ++r ) {
4225 start = psts[cols*r+1].u.md_str;
4226 if ( start==NULL ) start="";
4227 while ( *start== ' ' ) ++start;
4228 /* Replacements which aren't in the font */
4229 while ( *start ) {
4230 for ( pt=start; *pt!='\0' && *pt!=' ' && *pt!='('; ++pt );
4231 ch = *pt; *pt='\0';
4232 found = SFGetChar(pstkd->sf,-1,start);
4233 if ( found==NULL ) {
4234 buts[0] = _("_Yes");
4235 buts[1] = _("_Cancel");
4236 buts[2] = NULL;
4237 if ( gwwv_ask(_("Missing glyph"),(const char **) buts,0,1,_("For glyph %.60s you refer to a glyph named %.80s, which is not in the font yet. Was this intentional?"),
4238 psts[cols*r+0].u.md_str, start)==1 ) {
4239 *pt = ch;
4240 return( true );
4241 }
4242 }
4243 *pt = ch;
4244 if ( ch=='(' ) {
4245 while ( *pt!=')' && *pt!='\0' ) ++pt;
4246 if ( *pt==')' ) ++pt;
4247 }
4248 while ( *pt== ' ' ) ++pt;
4249 start = pt;
4250 }
4251 }
4252 }
4253 /* Duplicate entries */
4254 for ( r=0; r<rows; ++r ) {
4255 for ( r1=r+1; r1<rows; ++r1 ) {
4256 if ( strcmp(psts[r*cols+0].u.md_str,psts[r1*cols+0].u.md_str)==0 ) {
4257 if ( lookup_type==gpos_pair || lookup_type==gsub_ligature ) {
4258 if ( strcmp(psts[r*cols+1].u.md_str,psts[r1*cols+1].u.md_str)==0 ) {
4259 ff_post_error( _("Duplicate data"),_("There are two entries for the same glyph set (%.80s and %.80s)"),
4260 psts[cols*r+0].u.md_str, psts[cols*r+1].u.md_str );
4261 return( true );
4262 }
4263 } else {
4264 ff_post_error( _("Duplicate data"),_("There are two entries for the same glyph (%.80s)"),
4265 psts[cols*r+0].u.md_str );
4266 return( true );
4267 }
4268 }
4269 }
4270 }
4271
4272 /* Check for badly specified device tables */
4273 if ( _t==pst_position || _t==pst_pair ) {
4274 int startc = _t==pst_position ? SIM_DX+1 : PAIR_DX1+1;
4275 int low, high, c;
4276 for ( r=0; r<rows; ++r ) {
4277 for ( c=startc; c<cols; c+=2 ) {
4278 if ( !DeviceTableOK(psts[r*cols+c].u.md_str,&low,&high) ) {
4279 ff_post_error( _("Bad Device Table Adjustment"),_("A device table adjustment specified for %.80s is invalid"),
4280 psts[cols*r+0].u.md_str );
4281 return( true );
4282 }
4283 }
4284 }
4285 }
4286
4287 /* Ok, if we get here then there should be no errors and we can parse */
4288
4289 /* First grab a snapshot of the state of the system as it is
4290 * now so that we can "undo" the lookup table edits as a
4291 * single operation if desired */
4292 char* oldsfd = 0;
4293 if( !pstkd->sf->subfontcnt ) {
4294 sf = pstkd->sf;
4295 oldsfd = SFDCreateUndoForLookup( sf, lookup_type );
4296
4297 if( DEBUG && oldsfd )
4298 GFileWriteAll( "/tmp/old-lookup-table.sfd", oldsfd );
4299 }
4300
4301 /* Then mark all the current things as unused */
4302 k=0;
4303 do {
4304 sf = pstkd->sf->subfontcnt==0 ? pstkd->sf : pstkd->sf->subfonts[k];
4305 SFUntickAllPSTandKern( sf );
4306 ++k;
4307 } while ( k<pstkd->sf->subfontcnt );
4308
4309 /* Write the changes to each SplineChar. For example, updating
4310 * the ligaments will update the splinechar's
4311 * pst->u.subs.variant and pst->u.lig.lig
4312 */
4313 if ( lookup_type!=gpos_pair ) {
4314 for ( r=0; r<rows; ++r ) {
4315
4316 sc = SFGetChar(pstkd->sf,-1,psts[cols*r+0].u.md_str);
4317 for ( pst=sc->possub; pst!=NULL; pst=pst->next ) {
4318 if ( pst->subtable == pstkd->sub && !pst->ticked )
4319 break;
4320 }
4321 if ( pst==NULL ) {
4322 pst = chunkalloc(sizeof(PST));
4323 pst->type = _t;
4324 pst->subtable = pstkd->sub;
4325 pst->next = sc->possub;
4326 sc->possub = pst;
4327 } else if ( lookup_type!=gpos_single )
4328 free( pst->u.subs.variant );
4329 pst->ticked = true;
4330 if ( lookup_type==gpos_single ) {
4331 VRDevTabParse(&pst->u.pos,&psts[cols*r+SIM_DX+1]);
4332 pst->u.pos.xoff = psts[cols*r+SIM_DX].u.md_ival;
4333 pst->u.pos.yoff = psts[cols*r+SIM_DY].u.md_ival;
4334 pst->u.pos.h_adv_off = psts[cols*r+SIM_DX_ADV].u.md_ival;
4335 pst->u.pos.v_adv_off = psts[cols*r+SIM_DY_ADV].u.md_ival;
4336 } else {
4337 pst->u.subs.variant = GlyphNameListDeUnicode( psts[cols*r+1].u.md_str );
4338 if ( lookup_type==gsub_ligature )
4339 pst->u.lig.lig = sc;
4340 }
4341 }
4342 } else if ( lookup_type==gpos_pair ) {
4343 for ( r=0; r<rows; ++r ) {
4344 sc = SFGetChar(pstkd->sf,-1,psts[cols*r+0].u.md_str);
4345 KpMDParse(sc,pstkd->sub,psts,rows,cols,r);
4346 }
4347 }
4348
4349 /* Now free anything with this subtable which did not get ticked
4350 * during the above update */
4351 k=0;
4352 do {
4353 sf = pstkd->sf->subfontcnt==0 ? pstkd->sf : pstkd->sf->subfonts[k];
4354 for ( gid=0; gid<sf->glyphcnt; ++gid ) if ( (sc = sf->glyphs[gid])!=NULL ) {
4355 for ( pstprev=NULL, pst = sc->possub; pst!=NULL; pst=pstnext ) {
4356 pstnext = pst->next;
4357 if ( pst->ticked || pst->subtable!=pstkd->sub )
4358 pstprev = pst;
4359 else {
4360 if ( pstprev==NULL )
4361 sc->possub = pstnext;
4362 else
4363 pstprev->next = pstnext;
4364 pst->next = NULL;
4365 PSTFree(pst);
4366 }
4367 }
4368 for ( isv=0; isv<2; ++isv ) {
4369 for ( kpprev=NULL, kp = isv ? sc->vkerns : sc->kerns; kp!=NULL; kp=kpnext ) {
4370 kpnext = kp->next;
4371 if ( kp->kcid!=0 || kp->subtable!=pstkd->sub )
4372 kpprev = kp;
4373 else {
4374 if ( kpprev!=NULL )
4375 kpprev->next = kpnext;
4376 else if ( isv )
4377 sc->vkerns = kpnext;
4378 else
4379 sc->kerns = kpnext;
4380 kp->next = NULL;
4381 KernPairsFree(kp);
4382 }
4383 }
4384 }
4385 }
4386 ++k;
4387 } while ( k<pstkd->sf->subfontcnt );
4388
4389 /* The field we use to tick kern pairs must be reset to false */
4390 k=0;
4391 do {
4392 for ( gid=0; gid<sf->glyphcnt; ++gid ) if ( (sc = sf->glyphs[gid])!=NULL ) {
4393 for ( isv=0; isv<2; ++isv ) {
4394 for ( kp = isv ? sc->vkerns : sc->kerns; kp!=NULL; kp=kp->next ) {
4395 kp->kcid = false;
4396 }
4397 }
4398 }
4399 ++k;
4400 } while ( k<pstkd->sf->subfontcnt );
4401 PSTKD_SetSuffix(pstkd);
4402 if ( lookup_type==gpos_pair ) {
4403 pstkd->sub->separation = separation;
4404 pstkd->sub->minkern = minkern;
4405 pstkd->sub->kerning_by_touch = touch;
4406 pstkd->sub->onlyCloser = onlyCloser;
4407 pstkd->sub->dontautokern = !autokern;
4408 }
4409
4410 /* compare the updated data to the snapshot we took before and
4411 * trim the undo operation of superfluous data
4412 */
4413 if( oldsfd ) {
4414
4415 int shouldCreateUndoEntry = 1;
4416 sf = pstkd->sf;
4417 char* str = SFDCreateUndoForLookup( sf, lookup_type );
4418
4419 if( !pstkd->sf->subfontcnt ) {
4420 char* diffstr = SFDTrimUndoOldToNew( sf, oldsfd, str );
4421 if( !diffstr ) {
4422 // If nothing has changed after all,
4423 // don't create an empty undo
4424 shouldCreateUndoEntry = 0;
4425 } else {
4426 free(str);
4427 str = diffstr;
4428 }
4429 }
4430
4431 if( shouldCreateUndoEntry ) {
4432
4433 dlist_trim_to_limit( (struct dlistnode **)&sf->undoes, fontlevel_undo_limit,
4434 (dlist_visitor_func_type)SFUndoFreeAssociated );
4435
4436 enum sfundotype t = sfut_lookups;
4437 if( lookup_type == gpos_pair ) {
4438 t = sfut_lookups_kerns;
4439 }
4440 SFUndoes* undo = SFUndoCreateSFD( t, _("Lookup Table Edit"), str );
4441 dlist_pushfront( (struct dlistnode **)&sf->undoes, (struct dlistnode *)undo );
4442 }
4443 // printf("we now have %d splinefont level undoes\n", dlist_size((struct dlistnode **)&sf->undoes));
4444 }
4445
4446 pstkd->done = true;
4447 }
4448 return( true );
4449 }
4450
4451 static void PSTKD_DoCancel(PSTKernDlg *pstkd) {
4452 pstkd->done = true;
4453 }
4454
4455 static int PSTKD_Cancel(GGadget *g, GEvent *e) {
4456 PSTKernDlg *pstkd;
4457
4458 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
4459 pstkd = GDrawGetUserData(GGadgetGetWindow(g));
4460 PSTKD_DoCancel(pstkd);
4461 }
4462 return( true );
4463 }
4464
4465 char *GlyphNameListDeUnicode( char *str ) {
4466 char *pt;
4467 char *ret, *rpt;
4468
4469 rpt = ret = malloc(strlen(str)+1);
4470 while ( *str==' ' ) ++str;
4471 for ( pt=str; *pt!='\0'; ) {
4472 if ( *pt==' ' ) {
4473 while ( *pt==' ' ) ++pt;
4474 --pt;
4475 }
4476 if ( *pt=='(' ) {
4477 while ( *pt!=')' && *pt!='\0' ) ++pt;
4478 if ( *pt==')' ) ++pt;
4479 } else
4480 *rpt++ = *pt++;
4481 }
4482 *rpt = '\0';
4483 return( ret );
4484 }
4485
4486 char *SFNameList2NameUni(SplineFont *sf, char *str) {
4487 char *start, *pt, *ret, *rpt;
4488 int cnt, ch;
4489 SplineChar *sc;
4490
4491 if ( str==NULL )
4492 return( NULL );
4493 if ( !add_char_to_name_list )
4494 return( copy(str));
4495
4496 cnt = 0;
4497 for ( pt=str; *pt!='\0'; ++pt )
4498 if ( *pt==' ' )
4499 ++cnt;
4500 rpt = ret = malloc(strlen(str) + (cnt+1)*7 + 1);
4501 for ( start=str; *start!='\0'; ) {
4502 while ( *start==' ' ) ++start;
4503 if ( *start=='\0' )
4504 break;
4505 for ( pt=start; *pt!='\0' && *pt!=' ' && *pt!='('; ++pt );
4506 ch = *pt; *pt='\0';
4507 sc = SFGetChar(sf,-1,start);
4508 strcpy(rpt,start);
4509 rpt += strlen(rpt);
4510 *pt = ch;
4511 /* don't show control characters, or space or parens, or */
4512 /* latin letters (their names are themselves, no need to duplicate) */
4513 /* or things in the private use area */
4514 if ( sc!=NULL && sc->unicodeenc>32 && sc->unicodeenc!=')' &&
4515 !( sc->unicodeenc<0x7f && isalpha(sc->unicodeenc)) &&
4516 !issurrogate(sc->unicodeenc) &&
4517 !isprivateuse(sc->unicodeenc)) {
4518 *rpt++ = '(';
4519 rpt = utf8_idpb(rpt,sc->unicodeenc,0);
4520 *rpt++ = ')';
4521 }
4522 *rpt++ = ' ';
4523 if ( ch=='(' )
4524 while ( *pt!=')' && *pt!='\0' ) ++pt;
4525 while ( *pt==' ' ) ++pt;
4526 start = pt;
4527 }
4528 if ( rpt>ret )
4529 rpt[-1] = '\0';
4530 else
4531 ret[0] = '\0';
4532 return( ret );
4533 }
4534
4535 char *SCNameUniStr(SplineChar *sc) {
4536 char *temp, *pt;
4537 int len;
4538
4539 if ( sc==NULL )
4540 return( NULL );
4541 if ( !add_char_to_name_list )
4542 return( copy(sc->name));
4543
4544 len = strlen(sc->name);
4545 temp = malloc(len + 8);
4546 strcpy(temp,sc->name);
4547 if ( sc->unicodeenc>32 && sc->unicodeenc!=')' && add_char_to_name_list &&
4548 !( sc->unicodeenc<0x7f && isalpha(sc->unicodeenc)) &&
4549 !issurrogate(sc->unicodeenc) &&
4550 !isprivateuse(sc->unicodeenc)) {
4551 pt = temp+len;
4552 *pt++ = '(';
4553 pt = utf8_idpb(pt,sc->unicodeenc,0);
4554 *pt++ = ')';
4555 *pt = '\0';
4556 }
4557 return( temp );
4558 }
4559
4560 unichar_t *uSCNameUniStr(SplineChar *sc) {
4561 unichar_t *temp;
4562 int len;
4563
4564 if ( sc==NULL )
4565 return( NULL );
4566 temp = malloc((strlen(sc->name) + 5) * sizeof(unichar_t));
4567 utf82u_strcpy(temp,sc->name);
4568 if ( sc->unicodeenc>32 && sc->unicodeenc!=')' && add_char_to_name_list &&
4569 !( sc->unicodeenc<0x7f && isalpha(sc->unicodeenc)) &&
4570 !issurrogate(sc->unicodeenc) &&
4571 !isprivateuse(sc->unicodeenc)) {
4572 len = u_strlen(temp);
4573 temp[len] = '(';
4574 temp[len+1] = sc->unicodeenc;
4575 temp[len+2] = ')';
4576 temp[len+3] = '\0';
4577 }
4578 return( temp );
4579 }
4580
4581 unichar_t **SFGlyphNameCompletion(SplineFont *sf,GGadget *t,int from_tab,
4582 int new_name_after_space) {
4583 unichar_t *pt, *spt, *basept, *wild; unichar_t **ret;
4584 int gid, cnt, doit, match_len;
4585 SplineChar *sc;
4586 int do_wildcards;
4587
4588 pt = spt = basept = (unichar_t *) _GGadgetGetTitle(t);
4589 if ( pt==NULL || *pt=='\0' )
4590 return( NULL );
4591 if ( new_name_after_space ) {
4592 if (( spt = u_strrchr(spt,' '))== NULL )
4593 spt = basept;
4594 else {
4595 pt = ++spt;
4596 if ( *pt=='\0' )
4597 return( NULL );
4598 }
4599 }
4600 while ( *pt && *pt!='*' && *pt!='?' && *pt!='[' && *pt!='{' )
4601 ++pt;
4602 do_wildcards = *pt!='\0';
4603
4604 if (( !do_wildcards && pt-spt==1 && !isalpha(*spt)) ||
4605 (!from_tab && do_wildcards && pt-spt==2 && spt[1]==' ')) {
4606 sc = SFGetChar(sf,*spt,NULL);
4607 /* One unicode character which isn't a glyph name (so not "A") and */
4608 /* isn't a wildcard (so not "*") gets expanded to its glyph name. */
4609 /* (so "," becomes "comma(,)" */
4610 /* Or, a single wildcard followed by a space gets expanded to glyph name */
4611 if ( sc!=NULL ) {
4612 ret = malloc((2)*sizeof(unichar_t *));
4613 ret[0] = uSCNameUniStr(sc);
4614 ret[1] = NULL;
4615 return( ret );
4616 }
4617 }
4618 if ( do_wildcards && !from_tab )
4619 return( NULL );
4620
4621 wild = NULL;
4622 if ( do_wildcards ) {
4623 pt = spt;
4624 wild = malloc((u_strlen(spt)+2)*sizeof(unichar_t));
4625 u_strcpy(wild,pt);
4626 uc_strcat(wild,"*");
4627 }
4628
4629 match_len = u_strlen(spt);
4630 ret = NULL;
4631 for ( doit=0; doit<2; ++doit ) {
4632 cnt=0;
4633 for ( gid=0; gid<sf->glyphcnt; ++gid ) if ( (sc=sf->glyphs[gid])!=NULL ) {
4634 int matched;
4635 if ( do_wildcards ) {
4636 unichar_t *temp = utf82u_copy(sc->name);
4637 matched = GGadgetWildMatch((unichar_t *) wild,temp,false);
4638 free(temp);
4639 } else
4640 matched = uc_strncmp(spt,sc->name,match_len)==0;
4641 if ( matched ) {
4642 if ( doit ) {
4643 if ( spt==basept ) {
4644 ret[cnt] = uSCNameUniStr(sc);
4645 } else {
4646 unichar_t *temp = malloc((spt-basept+strlen(sc->name)+4)*sizeof(unichar_t));
4647 int len;
4648 u_strncpy(temp,basept,spt-basept);
4649 utf82u_strcpy(temp+(spt-basept),sc->name);
4650 len = u_strlen(temp);
4651 if ( sc->unicodeenc>32 && add_char_to_name_list &&
4652 !( sc->unicodeenc<0x7f && isalpha(sc->unicodeenc)) &&
4653 !issurrogate(sc->unicodeenc) &&
4654 !isprivateuse(sc->unicodeenc)) {
4655 temp[len] = '(';
4656 temp[len+1] = sc->unicodeenc;
4657 temp[len+2] = ')';
4658 temp[len+3] = '\0';
4659 }
4660 ret[cnt] = temp;
4661 }
4662 }
4663 ++cnt;
4664 }
4665 }
4666 if ( doit )
4667 ret[cnt] = NULL;
4668 else if ( cnt==0 )
4669 break;
4670 else
4671 ret = malloc((cnt+1)*sizeof(unichar_t *));
4672 }
4673 free(wild);
4674 return( ret );
4675 }
4676
4677 static unichar_t **PSTKD_GlyphNameCompletion(GGadget *t,int from_tab) {
4678 PSTKernDlg *pstkd = GDrawGetUserData(GDrawGetParentWindow(GGadgetGetWindow(t)));
4679 SplineFont *sf = pstkd->sf;
4680
4681 return( SFGlyphNameCompletion(sf,t,from_tab,false));
4682 }
4683
4684 static unichar_t **PSTKD_GlyphListCompletion(GGadget *t,int from_tab) {
4685 PSTKernDlg *pstkd = GDrawGetUserData(GDrawGetParentWindow(GGadgetGetWindow(t)));
4686 SplineFont *sf = pstkd->sf;
4687
4688 return( SFGlyphNameCompletion(sf,t,from_tab,true));
4689 }
4690
4691 static int pstkd_e_h(GWindow gw, GEvent *event) {
4692 PSTKernDlg *pstkd = GDrawGetUserData(gw);
4693
4694 switch ( event->type ) {
4695 case et_close:
4696 PSTKD_DoCancel(pstkd);
4697 break;
4698 case et_char:
4699 if ( event->u.chr.keysym == GK_F1 || event->u.chr.keysym == GK_Help ) {
4700 int lookup_type = pstkd->sub->lookup->lookup_type;
4701 if ( lookup_type==gpos_single )
4702 help("ui/dialogs/lookups.html", "#lookups-single-pos");
4703 else if ( lookup_type==gpos_pair )
4704 help("ui/dialogs/lookups.html", "#lookups-pair");
4705 else
4706 help("ui/dialogs/lookups.html", "#lookups-basic-subs");
4707 return( true );
4708 }
4709 return( false );
4710 break;
4711 case et_destroy:
4712 break;
4713 case et_mouseup: case et_mousemove: case et_mousedown:
4714 break;
4715 case et_expose:
4716 break;
4717 case et_resize:
4718 break;
4719 default: break;
4720 }
4721 return( true );
4722 }
4723
4724 static void PSTKernD(SplineFont *sf, struct lookup_subtable *sub, int def_layer) {
4725 PSTKernDlg pstkd;
4726 GRect pos;
4727 GWindowAttrs wattrs;
4728 char title[300];
4729 struct matrixinit mi;
4730 GGadgetCreateData gcd[23], buttongcd[6], box[6], hbox;
4731 GGadgetCreateData *h1array[8], *h2array[7], *h3array[7], *varray[20], *h4array[8], *h5array[4];
4732 GTextInfo label[23], buttonlabel[6];
4733 int i,k,mi_pos, mi_k;
4734 enum otlookup_type lookup_type = sub->lookup->lookup_type;
4735 char sepbuf[40], mkbuf[40];
4736
4737 if ( sub->separation==0 && !sub->kerning_by_touch ) {
4738 sub->separation = sf->width_separation;
4739 if ( sf->width_separation==0 )
4740 sub->separation = 15*(sf->ascent+sf->descent)/100;
4741 sub->minkern = sub->separation/10;
4742 }
4743
4744 memset(&pstkd,0,sizeof(pstkd));
4745 pstkd.sf = sf;
4746 pstkd.def_layer = def_layer;
4747 pstkd.sub = sub;
4748
4749 memset(&wattrs,0,sizeof(wattrs));
4750 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
4751 wattrs.event_masks = ~(1<<et_charup);
4752 wattrs.restrict_input_to_me = true;
4753 wattrs.undercursor = 1;
4754 wattrs.cursor = ct_pointer;
4755 snprintf(title,sizeof(title), _("Lookup Subtable, %s"), sub->subtable_name );
4756 wattrs.utf8_window_title = title;
4757 wattrs.is_dlg = true;
4758 pos.x = pos.y = 0;
4759 pos.width = GGadgetScale(GDrawPointsToPixels(NULL,300));
4760 pos.height = GDrawPointsToPixels(NULL,400);
4761 pstkd.gw = GDrawCreateTopWindow(NULL,&pos,pstkd_e_h,&pstkd,&wattrs);
4762
4763 memset(&gcd,0,sizeof(gcd));
4764 memset(&buttongcd,0,sizeof(buttongcd));
4765 memset(&box,0,sizeof(box));
4766 memset(&label,0,sizeof(label));
4767 memset(&buttonlabel,0,sizeof(buttonlabel));
4768
4769 i = k = 0;
4770 label[i].text = (unichar_t *) _("_Alphabetic");
4771 label[i].text_is_1byte = true;
4772 label[i].text_in_resource = true;
4773 gcd[i].gd.label = &label[i];
4774 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4775 gcd[i].gd.flags = isalphabetic ? (gg_enabled|gg_visible|gg_cb_on) : (gg_enabled|gg_visible);
4776 gcd[i].gd.popup_msg = _("Sort this display based on the alphabetic name of the glyph");
4777 gcd[i].gd.handle_controlevent = PSTKD_Sort;
4778 gcd[i].gd.cid = CID_Alpha;
4779 gcd[i].creator = GRadioCreate;
4780 h1array[0] = &gcd[i++];
4781
4782 label[i].text = (unichar_t *) _("_Unicode");
4783 label[i].text_is_1byte = true;
4784 label[i].text_in_resource = true;
4785 gcd[i].gd.label = &label[i];
4786 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4787 gcd[i].gd.flags = !isalphabetic ? (gg_enabled|gg_visible|gg_cb_on) : (gg_enabled|gg_visible);
4788 gcd[i].gd.popup_msg = _("Sort this display based on the unicode code of the glyph");
4789 gcd[i].gd.handle_controlevent = PSTKD_Sort;
4790 gcd[i].gd.cid = CID_Unicode;
4791 gcd[i].creator = GRadioCreate;
4792 h1array[1] = &gcd[i++]; h1array[2] = GCD_HPad10;
4793
4794 label[i].text = (unichar_t *) _("_By Base Char");
4795 label[i].text_is_1byte = true;
4796 label[i].text_in_resource = true;
4797 gcd[i].gd.label = &label[i];
4798 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4799 gcd[i].gd.flags = stemming ? (gg_enabled|gg_visible|gg_cb_on) : (gg_enabled|gg_visible);
4800 gcd[i].gd.popup_msg = _("Sort first using the base glyph (if any).\nThus Agrave would sort with A");
4801 gcd[i].gd.handle_controlevent = PSTKD_Sort;
4802 gcd[i].gd.cid = CID_BaseChar;
4803 gcd[i].creator = GCheckBoxCreate;
4804 h1array[3] = &gcd[i++]; h1array[4] = GCD_HPad10;
4805
4806 label[i].text = (unichar_t *) _("By _Scripts");
4807 label[i].text_is_1byte = true;
4808 label[i].text_in_resource = true;
4809 gcd[i].gd.label = &label[i];
4810 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4811 gcd[i].gd.flags = byscripts ? (gg_enabled|gg_visible|gg_cb_on) : (gg_enabled|gg_visible);
4812 gcd[i].gd.popup_msg = _("Sort first using the glyph's script.\nThus A and Z would sort together\nwhile Alpha would sort with Omega and not A");
4813 if ( sub->lookup->features==NULL ||
4814 (sub->lookup->features->next==NULL &&
4815 (sub->lookup->features->scripts==NULL ||
4816 sub->lookup->features->scripts->next==NULL)))
4817 gcd[i].gd.flags = gg_visible|gg_cb_on; /* If there is only one script, we can't really sort by it */
4818 gcd[i].gd.handle_controlevent = PSTKD_Sort;
4819 gcd[i].gd.cid = CID_Scripts;
4820 gcd[i].creator = GCheckBoxCreate;
4821 h1array[5] = &gcd[i++]; h1array[6] = GCD_Glue; h1array[7] = NULL;
4822
4823 box[0].gd.flags = gg_enabled|gg_visible;
4824 box[0].gd.u.boxelements = h1array;
4825 box[0].creator = GHBoxCreate;
4826 varray[k++] = &box[0]; varray[k++] = NULL;
4827
4828 if ( sub->lookup->lookup_type == gpos_pair || sub->lookup->lookup_type == gpos_single ) {
4829 label[i].text = (unichar_t *) _("_Hide Unused Columns");
4830 label[i].text_is_1byte = true;
4831 label[i].text_in_resource = true;
4832 gcd[i].gd.label = &label[i];
4833 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4834 gcd[i].gd.flags = lookup_hideunused ? (gg_enabled|gg_visible|gg_cb_on) : (gg_enabled|gg_visible);
4835 gcd[i].gd.popup_msg = _("Don't display columns of 0s.\nThe OpenType lookup allows for up to 8 kinds\nof data, but almost all lookups will use just one or two.\nOmitting the others makes the behavior clearer.");
4836 gcd[i].gd.handle_controlevent = PSTKD_HideUnused;
4837 gcd[i].creator = GCheckBoxCreate;
4838 varray[k++] = &gcd[i++]; varray[k++] = NULL;
4839 }
4840
4841 PSTMatrixInit(&mi,sf,sub,&pstkd);
4842 mi_pos = i;
4843 gcd[i].gd.pos.height = 200;
4844 gcd[i].gd.flags = gg_enabled | gg_visible;
4845 gcd[i].gd.cid = CID_PSTList;
4846 gcd[i].gd.u.matrix = &mi;
4847 gcd[i].data = &pstkd;
4848 gcd[i].creator = GMatrixEditCreate;
4849 mi_k = k;
4850 varray[k++] = &gcd[i++]; varray[k++] = NULL;
4851
4852 buttonlabel[0].text = (unichar_t *) _("_Populate");
4853 if ( lookup_type==gpos_pair )
4854 buttonlabel[0].text = (unichar_t *) _("Auto_Kern");
4855 buttonlabel[0].text_is_1byte = true;
4856 buttonlabel[0].text_in_resource = true;
4857 buttongcd[0].gd.label = &buttonlabel[0];
4858 buttongcd[0].gd.pos.x = 5; buttongcd[0].gd.pos.y = 5+4;
4859 buttongcd[0].gd.flags =
4860 sub->lookup->features==NULL || sub->vertical_kerning ?
4861 gg_visible:
4862 gg_enabled|gg_visible;
4863 if ( lookup_type==gpos_pair ) {
4864 buttongcd[0].gd.popup_msg = _("For each script to which this lookup applies, look at all pairs of\n"
4865 "glyphs in that script and try to guess a reasonable kerning value\n"
4866 "for that pair.");
4867 buttongcd[0].gd.handle_controlevent = PSTKD_AutoKern;
4868 } else {
4869 buttongcd[0].gd.popup_msg = _("Add entries for all glyphs in the scripts to which this lookup applies.\nWhen FontForge can find a default value it will add that too.");
4870 buttongcd[0].gd.handle_controlevent = PSTKD_Populate;
4871 }
4872 buttongcd[0].creator = GButtonCreate;
4873
4874 buttonlabel[1].text = (unichar_t *) _("_Add Selected");
4875 if ( lookup_type==gpos_pair )
4876 buttonlabel[1].text = (unichar_t *) _("_AutoKern Selected");
4877 buttonlabel[1].text_is_1byte = true;
4878 buttonlabel[1].text_in_resource = true;
4879 buttongcd[1].gd.label = &buttonlabel[1];
4880 buttongcd[1].gd.pos.x = 5; buttongcd[1].gd.pos.y = 5+4;
4881 buttongcd[1].gd.flags = gg_enabled|gg_visible;
4882 if ( lookup_type==gpos_pair ) {
4883 if ( sub->vertical_kerning )
4884 buttongcd[1].gd.flags = gg_visible;
4885 buttongcd[1].gd.popup_msg = _("Add kerning info between all pairs of selected glyphs" );
4886 buttongcd[1].gd.handle_controlevent = PSTKD_AutoKernSelected;
4887 } else {
4888 buttongcd[1].gd.popup_msg = _("Add entries for all selected glyphs.");
4889 buttongcd[1].gd.handle_controlevent = PSTKD_PopulateSelected;
4890 }
4891 buttongcd[1].creator = GButtonCreate;
4892
4893 buttonlabel[2].text = (unichar_t *) _("_Remove Empty");
4894 buttonlabel[2].text_is_1byte = true;
4895 buttonlabel[2].text_in_resource = true;
4896 buttongcd[2].gd.label = &buttonlabel[2];
4897 buttongcd[2].gd.pos.x = 5; buttongcd[2].gd.pos.y = 5+4;
4898 buttongcd[2].gd.flags = gg_enabled|gg_visible;
4899 buttongcd[2].gd.popup_msg =
4900 (sub->lookup->lookup_type == gpos_single ? _("Remove all \"empty\" entries -- those where all fields are 0") :
4901 sub->lookup->lookup_type == gpos_pair ? _("Remove all \"empty\" entries -- entries with no second glyph") :
4902 sub->lookup->lookup_type == gsub_ligature ? _("Remove all \"empty\" entries -- those with no source glyphs") :
4903 _("Remove all \"empty\" entries -- those with no replacement glyphs"));
4904 buttongcd[2].gd.handle_controlevent = PSTKD_RemoveEmpty;
4905 buttongcd[2].creator = GButtonCreate;
4906
4907 buttonlabel[3].text = (unichar_t *) _("Remove All");
4908 buttonlabel[3].text_is_1byte = true;
4909 buttonlabel[3].text_in_resource = true;
4910 buttongcd[3].gd.label = &buttonlabel[3];
4911 buttongcd[3].gd.pos.x = 5; buttongcd[3].gd.pos.y = 5+4;
4912 buttongcd[3].gd.flags = gg_enabled|gg_visible;
4913 buttongcd[3].gd.popup_msg = _("Remove all entries.");
4914 buttongcd[3].gd.handle_controlevent = PSTKD_RemoveAll;
4915 buttongcd[3].creator = GButtonCreate;
4916
4917 if ( sub->lookup->lookup_type == gsub_single ) {
4918 label[i].text = (unichar_t *) _("_Default Using Suffix:");
4919 label[i].text_is_1byte = true;
4920 label[i].text_in_resource = true;
4921 gcd[i].gd.label = &label[i];
4922 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4923 gcd[i].gd.flags = gg_enabled|gg_visible;
4924 gcd[i].gd.popup_msg = _(
4925 "Add entries to the lookup based on the following suffix.\n"
4926 "So if the suffix is set to \"superior\" and the font\n"
4927 "contains glyphs named \"A\" and \"A.superior\" (and the\n"
4928 "lookup applies to the latin script), then FontForge will\n"
4929 "add an entry mapping \"A\" -> \"A.superior\"." );
4930 gcd[i].gd.handle_controlevent = PSTKD_PopulateWithSuffix;
4931 gcd[i].creator = GButtonCreate;
4932 h2array[0] = &gcd[i++];
4933
4934 label[i].text = (unichar_t *) sub->suffix;
4935 label[i].text_is_1byte = true;
4936 label[i].text_in_resource = true;
4937 gcd[i].gd.label = sub->suffix==NULL ? NULL : &label[i];
4938 gcd[i].gd.flags = gg_enabled|gg_visible;
4939 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
4940 gcd[i].gd.cid = CID_Suffix;
4941 gcd[i].creator = GTextFieldCreate;
4942 h2array[1] = &gcd[i++]; h2array[2] = GCD_Glue; h2array[3] = NULL;
4943
4944 box[1].gd.flags = gg_enabled|gg_visible;
4945 box[1].gd.u.boxelements = h2array;
4946 box[1].creator = GHBoxCreate;
4947 varray[k++] = &box[1]; varray[k++] = NULL;
4948 } else if ( sub->lookup->lookup_type == gpos_single ) {
4949 label[i].text = (unichar_t *) _("_Default New Entries to First");
4950 label[i].text_is_1byte = true;
4951 label[i].text_in_resource = true;
4952 gcd[i].gd.label = &label[i];
4953 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4954 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
4955 if ( is_boundsFeat(sub)!=0 )
4956 gcd[i].gd.flags = gg_enabled|gg_visible;
4957 gcd[i].gd.popup_msg = _("When adding new entries, give them the same\ndelta values as those on the first line.");
4958 gcd[i].gd.cid = CID_AllSame;
4959 gcd[i].creator = GCheckBoxCreate;
4960 varray[k++] = &gcd[i++]; varray[k++] = NULL;
4961
4962 } else if ( sub->lookup->lookup_type == gpos_pair ) {
4963 label[i].text = (unichar_t *) _("_Default Separation:");
4964 label[i].text_is_1byte = true;
4965 label[i].text_in_resource = true;
4966 gcd[i].gd.label = &label[i];
4967 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4968 gcd[i].gd.flags = gg_enabled|gg_visible;
4969 gcd[i].gd.popup_msg = _(
4970 "Add entries to the lookup trying to make the optical\n"
4971 "separation between all pairs of glyphs equal to this\n"
4972 "value." );
4973 gcd[i].creator = GLabelCreate;
4974 h4array[0] = &gcd[i++];
4975
4976 sprintf( sepbuf, "%d", sub->separation );
4977 label[i].text = (unichar_t *) sepbuf;
4978 label[i].text_is_1byte = true;
4979 label[i].text_in_resource = true;
4980 gcd[i].gd.label = &label[i];
4981 gcd[i].gd.pos.width = 50;
4982 gcd[i].gd.flags = gg_enabled|gg_visible;
4983 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
4984 gcd[i].gd.cid = CID_Separation;
4985 gcd[i].creator = GTextFieldCreate;
4986 h4array[1] = &gcd[i++];
4987
4988 label[i].text = (unichar_t *) _("_Min Kern:");
4989 label[i].text_is_1byte = true;
4990 label[i].text_in_resource = true;
4991 gcd[i].gd.label = &label[i];
4992 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
4993 gcd[i].gd.flags = gg_enabled|gg_visible;
4994 gcd[i].gd.popup_msg = _(
4995 "Any computed kerning change whose absolute value is less\n"
4996 "that this will be ignored.\n" );
4997 gcd[i].creator = GLabelCreate;
4998 h4array[2] = &gcd[i++];
4999
5000 sprintf( mkbuf, "%d", sub->minkern );
5001 label[i].text = (unichar_t *) mkbuf;
5002 label[i].text_is_1byte = true;
5003 label[i].text_in_resource = true;
5004 gcd[i].gd.label = &label[i];
5005 gcd[i].gd.pos.width = 50;
5006 gcd[i].gd.flags = gg_enabled|gg_visible;
5007 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
5008 gcd[i].gd.cid = CID_MinKern;
5009 gcd[i].creator = GTextFieldCreate;
5010 h4array[3] = &gcd[i++];
5011
5012 label[i].text = (unichar_t *) _("_Touching");
5013 label[i].text_is_1byte = true;
5014 label[i].text_in_resource = true;
5015 gcd[i].gd.label = &label[i];
5016 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
5017 gcd[i].gd.flags = gg_enabled|gg_visible;
5018 if ( sub->kerning_by_touch )
5019 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5020 gcd[i].gd.popup_msg = _(
5021 "Normally kerning is based on achieving a constant (optical)\n"
5022 "separation between glyphs, but occasionally it is desirable\n"
5023 "to have a kerning table where the kerning is based on the\n"
5024 "closest approach between two glyphs (So if the desired separ-\n"
5025 "ation is 0 then the glyphs will actually be touching.");
5026 gcd[i].gd.cid = CID_Touched;
5027 gcd[i].creator = GCheckBoxCreate;
5028 h4array[4] = &gcd[i++];
5029
5030 h4array[5] = GCD_Glue; h4array[6] = NULL;
5031
5032 box[1].gd.flags = gg_enabled|gg_visible;
5033 box[1].gd.u.boxelements = h4array;
5034 box[1].creator = GHBoxCreate;
5035 varray[k++] = &box[1]; varray[k++] = NULL;
5036
5037 label[i].text = (unichar_t *) _("Only kern glyphs closer");
5038 label[i].text_is_1byte = true;
5039 label[i].text_in_resource = true;
5040 gcd[i].gd.label = &label[i];
5041 gcd[i].gd.flags = gg_enabled|gg_visible;
5042 if ( sub->onlyCloser )
5043 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5044 gcd[i].gd.popup_msg = _(
5045 "When doing autokerning, only move glyphs closer together,\n"
5046 "so the kerning offset will be negative.");
5047 gcd[i].gd.cid = CID_OnlyCloser;
5048 gcd[i].creator = GCheckBoxCreate;
5049 h5array[0] = &gcd[i++];
5050
5051 label[i].text = (unichar_t *) _("Autokern new entries");
5052 label[i].text_is_1byte = true;
5053 label[i].text_in_resource = true;
5054 gcd[i].gd.label = &label[i];
5055 gcd[i].gd.flags = gg_enabled|gg_visible;
5056 if ( !sub->dontautokern )
5057 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5058 gcd[i].gd.popup_msg = _(
5059 "When adding new entries provide default kerning values.");
5060 gcd[i].gd.cid = CID_Autokern;
5061 gcd[i].creator = GCheckBoxCreate;
5062 h5array[1] = &gcd[i++]; h5array[2] = NULL;
5063
5064 memset(&hbox,0,sizeof(hbox));
5065 hbox.gd.flags = gg_enabled|gg_visible;
5066 hbox.gd.u.boxelements = h5array;
5067 hbox.creator = GHBoxCreate;
5068 varray[k++] = &hbox; varray[k++] = NULL;
5069
5070 label[i].text = (unichar_t *) _("Size:");
5071 label[i].text_is_1byte = true;
5072 gcd[i].gd.label = &label[i];
5073 gcd[i].gd.pos.x = 30; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+30;
5074 gcd[i].gd.flags = gg_visible|gg_enabled ;
5075 gcd[i++].creator = GLabelCreate;
5076 h2array[0] = &gcd[i-1];
5077
5078 pstkd.pixelsize = 150;
5079 label[i].text = (unichar_t *) "150";
5080 label[i].text_is_1byte = true;
5081 gcd[i].gd.label = &label[i];
5082 gcd[i].gd.pos.x = 92; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y-4;
5083 gcd[i].gd.pos.width = 80;
5084 gcd[i].gd.flags = gg_visible|gg_enabled ;
5085 gcd[i].gd.cid = CID_PixelSize;
5086 gcd[i].gd.handle_controlevent = PSTKD_DisplaySizeChanged;
5087 gcd[i++].creator = GTextFieldCreate;
5088 h2array[1] = &gcd[i-1]; h2array[2] = GCD_HPad10;
5089
5090 /* GT: Short for "Magnification" */
5091 label[i].text = (unichar_t *) _("Mag:");
5092 label[i].text_is_1byte = true;
5093 gcd[i].gd.label = &label[i];
5094 gcd[i].gd.pos.x = 185; gcd[i].gd.pos.y = gcd[i-2].gd.pos.y;
5095 gcd[i].gd.flags = gg_visible|gg_enabled ;
5096 gcd[i++].creator = GLabelCreate;
5097 h2array[3] = &gcd[i-1];
5098
5099 pstkd.mag = 1;
5100 gcd[i].gd.flags = gg_visible|gg_enabled ;
5101 gcd[i].gd.cid = CID_Magnification;
5102 gcd[i].gd.u.list = magnifications;
5103 gcd[i].gd.handle_controlevent = PSTKD_MagnificationChanged;
5104 gcd[i++].creator = GListButtonCreate;
5105 h2array[4] = &gcd[i-1]; h2array[5] = GCD_Glue; h2array[6] = NULL;
5106
5107 box[2].gd.flags = gg_enabled|gg_visible;
5108 box[2].gd.u.boxelements = h2array;
5109 box[2].creator = GHBoxCreate;
5110 varray[k++] = &box[2]; varray[k++] = NULL;
5111
5112 gcd[i].gd.pos.width = 200;
5113 gcd[i].gd.pos.height = 200;
5114 gcd[i].gd.flags = gg_visible | gg_enabled;
5115 gcd[i].gd.u.drawable_e_h = pstkern_e_h;
5116 gcd[i].gd.cid = CID_KernDisplay;
5117 gcd[i].creator = GDrawableCreate;
5118 varray[k++] = &gcd[i++]; varray[k++] = NULL;
5119 }
5120
5121 gcd[i].gd.pos.x = 10; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+24+3;
5122 gcd[i].gd.pos.width = -1;
5123 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default;
5124 label[i].text = (unichar_t *) _("_OK");
5125 label[i].text_is_1byte = true;
5126 label[i].text_in_resource = true;
5127 gcd[i].gd.label = &label[i];
5128 gcd[i].gd.handle_controlevent = PSTKD_Ok;
5129 gcd[i++].creator = GButtonCreate;
5130
5131 gcd[i].gd.pos.x = -10; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+3;
5132 gcd[i].gd.pos.width = -1;
5133 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
5134 label[i].text = (unichar_t *) _("_Cancel");
5135 label[i].text_is_1byte = true;
5136 label[i].text_in_resource = true;
5137 gcd[i].gd.label = &label[i];
5138 gcd[i].gd.handle_controlevent = PSTKD_Cancel;
5139 gcd[i].gd.cid = CID_Cancel;
5140 gcd[i++].creator = GButtonCreate;
5141
5142 h3array[0] = GCD_Glue; h3array[1] = &gcd[i-2]; h3array[2] = GCD_Glue;
5143 h3array[3] = GCD_Glue; h3array[4] = &gcd[i-1]; h3array[5] = GCD_Glue;
5144 h3array[6] = NULL;
5145
5146 box[3].gd.flags = gg_enabled|gg_visible;
5147 box[3].gd.u.boxelements = h3array;
5148 box[3].creator = GHBoxCreate;
5149 varray[k++] = &box[3]; varray[k++] = NULL; varray[k++] = NULL;
5150
5151 box[4].gd.pos.x = box[4].gd.pos.y = 2;
5152 box[4].gd.flags = gg_enabled|gg_visible;
5153 box[4].gd.u.boxelements = varray;
5154 box[4].creator = GHVGroupCreate;
5155
5156 GGadgetsCreate(pstkd.gw,box+4);
5157 GHVBoxSetExpandableRow(box[4].ret,mi_k/2);
5158 GHVBoxSetExpandableCol(box[3].ret,gb_expandgluesame);
5159 if ( sub->lookup->lookup_type == gsub_single )
5160 GHVBoxSetExpandableCol(box[1].ret,gb_expandglue);
5161 else if ( sub->lookup->lookup_type==gpos_pair ) {
5162 GHVBoxSetExpandableCol(box[1].ret,gb_expandglue);
5163 GHVBoxSetExpandableCol(box[2].ret,gb_expandglue);
5164 }
5165 GHVBoxSetExpandableCol(box[0].ret,gb_expandglue);
5166 GMatrixEditAddButtons(gcd[mi_pos].ret,buttongcd);
5167 GMatrixEditSetColumnCompletion(gcd[mi_pos].ret,0,PSTKD_GlyphNameCompletion);
5168 if ( sub->lookup->lookup_type == gsub_single || sub->lookup->lookup_type==gpos_pair )
5169 GMatrixEditSetColumnCompletion(gcd[mi_pos].ret,1,PSTKD_GlyphNameCompletion);
5170 else if ( sub->lookup->lookup_type == gsub_multiple ||
5171 sub->lookup->lookup_type==gsub_alternate ||
5172 sub->lookup->lookup_type==gsub_ligature )
5173 GMatrixEditSetColumnCompletion(gcd[mi_pos].ret,1,PSTKD_GlyphListCompletion);
5174
5175 if ( sub->lookup->lookup_type == gpos_pair )
5176 GMatrixEditSetTextChangeReporter(gcd[mi_pos].ret,PSTKD_METextChanged);
5177 else
5178 GMatrixEditSetMouseMoveReporter(gcd[mi_pos].ret,PST_PopupPrepare);
5179 if ( sub->lookup->lookup_type == gpos_pair || sub->lookup->lookup_type == gpos_single )
5180 PSTKD_DoHideUnused(&pstkd);
5181 else
5182 GHVBoxFitWindow(box[4].ret);
5183
5184 GDrawSetVisible(pstkd.gw,true);
5185
5186 while ( !pstkd.done )
5187 GDrawProcessOneEvent(NULL);
5188 GDrawDestroyWindow(pstkd.gw);
5189 if ( pstkd.display!=NULL ) {
5190 BDFFontFree(pstkd.display);
5191 pstkd.display = NULL;
5192 }
5193 }
5194 /* ************************************************************************** */
5195 /* *************************** Subtable Selection *************************** */
5196 /* ************************************************************************** */
5197
5198 static int SubtableNameInUse(char *subname, SplineFont *sf, struct lookup_subtable *exclude) {
5199 int isgpos, i, j;
5200 OTLookup *otl;
5201 struct lookup_subtable *sub;
5202
5203 if ( sf->fontinfo!=NULL ) {
5204 for ( isgpos=0; isgpos<2; ++isgpos ) {
5205 struct lkdata *lk = &sf->fontinfo->tables[isgpos];
5206 for ( i=0; i<lk->cnt; ++i ) {
5207 if ( lk->all[i].deleted )
5208 continue;
5209 for ( j=0; j<lk->all[i].subtable_cnt; ++j ) {
5210 if ( lk->all[i].subtables[j].deleted || lk->all[i].subtables[j].subtable==exclude )
5211 continue;
5212 if ( strcmp(lk->all[i].subtables[j].subtable->subtable_name,subname)==0 )
5213 return( true );
5214 }
5215 }
5216 }
5217 } else {
5218 for ( isgpos=0; isgpos<2; ++isgpos ) {
5219 for ( otl = isgpos ? sf->gpos_lookups : sf->gsub_lookups; otl!=NULL; otl=otl->next ) {
5220 for ( sub=otl->subtables; sub!=NULL; sub=sub->next ) {
5221 if ( sub==exclude )
5222 continue;
5223 if ( strcmp(sub->subtable_name,subname)==0 )
5224 return( true );
5225 }
5226 }
5227 }
5228 }
5229 return( false );
5230 }
5231
5232 int EditSubtable(struct lookup_subtable *sub,int isgpos,SplineFont *sf,
5233 struct subtable_data *sd, int def_layer) {
5234 char *def = sub->subtable_name;
5235 int new = def==NULL;
5236 char *freeme = NULL;
5237 int name_search;
5238
5239 if ( new ) {
5240 def = freeme = malloc(strlen(sub->lookup->lookup_name)+10);
5241 name_search = 1;
5242 do {
5243 sprintf( def, "%s-%d", sub->lookup->lookup_name, name_search++ );
5244 } while ( SubtableNameInUse(def,sf,sub));
5245 }
5246 for (;;) {
5247 def = gwwv_ask_string(_("Please name this subtable"),def,_("Please name this subtable"));
5248 free(freeme);
5249 if ( def==NULL )
5250 return( false );
5251 freeme = def;
5252 if ( SubtableNameInUse(def,sf,sub) )
5253 ff_post_notice(_("Duplicate name"),_("There is already a subtable with that name, please pick another."));
5254 else
5255 break;
5256 }
5257 free(sub->subtable_name);
5258 sub->subtable_name = def;
5259 if ( new && sub->lookup->lookup_type == gsub_single )
5260 sub->suffix = SuffixFromTags(sub->lookup->features);
5261 if ( new && (sd==NULL || !(sd->flags&sdf_dontedit)) )
5262 _LookupSubtableContents(sf, sub, sd, def_layer);
5263 return( true );
5264 }
5265
5266 static struct lookup_subtable *NewSubtable(OTLookup *otl,int isgpos,SplineFont *sf, struct subtable_data *sd,int def_layer) {
5267 struct lookup_subtable *sub, *last;
5268 int i,j;
5269
5270 sub = chunkalloc(sizeof(struct lookup_subtable));
5271 sub->lookup = otl;
5272 sub->separation = 15*(sf->ascent+sf->descent)/100;
5273 sub->minkern = sub->separation/10;
5274 if ( !EditSubtable(sub,isgpos,sf,sd,def_layer)) {
5275 chunkfree(sub,sizeof(struct lookup_subtable));
5276 return( NULL );
5277 }
5278 if ( otl->subtables==NULL )
5279 otl->subtables = sub;
5280 else {
5281 for ( last=otl->subtables; last->next!=NULL; last=last->next );
5282 last->next = sub;
5283 }
5284 if ( sf->fontinfo!=NULL ) {
5285 struct lkdata *lk = &sf->fontinfo->tables[isgpos];
5286 for ( i=0; i<lk->cnt && lk->all[i].lookup!=otl; ++i );
5287 if ( i==lk->cnt ) {
5288 IError( "Lookup missing from FontInfo lookup list");
5289 } else {
5290 if ( lk->all[i].subtable_cnt>=lk->all[i].subtable_max )
5291 lk->all[i].subtables = realloc(lk->all[i].subtables,(lk->all[i].subtable_max+=10)*sizeof(struct lksubinfo));
5292 j = lk->all[i].subtable_cnt++;
5293 memset(&lk->all[i].subtables[j],0,sizeof(struct lksubinfo));
5294 lk->all[i].subtables[j].subtable = sub;
5295 GFI_LookupScrollbars(sf->fontinfo,isgpos, true);
5296 GFI_LookupEnableButtons(sf->fontinfo,isgpos);
5297 }
5298 }
5299 return( sub );
5300 }
5301
5302 GTextInfo **SFSubtablesOfType(SplineFont *sf, int lookup_type, int kernclass,
5303 int add_none) {
5304 int isgpos = (lookup_type>=gpos_start);
5305 int k, cnt, lcnt, pos;
5306 OTLookup *otl;
5307 struct lookup_subtable *sub;
5308 GTextInfo **ti;
5309
5310 if ( sf->cidmaster != NULL ) sf=sf->cidmaster;
5311 else if ( sf->mm != NULL ) sf = sf->mm->normal;
5312
5313 for ( k=0; k<2; ++k ) {
5314 cnt = lcnt = pos = 0;
5315 if ( k && add_none ) {
5316 ti[pos] = calloc(1,sizeof(GTextInfo));
5317 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5318 ti[pos]->userdata = (void *) -1;
5319 ti[pos++]->text = utf82u_copy(_("No Subtable"));
5320 ti[pos] = calloc(1,sizeof(GTextInfo));
5321 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5322 ti[pos++]->line = true;
5323 }
5324 for ( otl = isgpos ? sf->gpos_lookups : sf->gsub_lookups; otl!=NULL; otl=otl->next ) {
5325 if ( otl->lookup_type==lookup_type && otl->subtables!=NULL ) {
5326 if ( k ) {
5327 ti[pos] = calloc(1,sizeof(GTextInfo));
5328 ti[pos]->text = malloc((utf82u_strlen(otl->lookup_name)+2)*sizeof(unichar_t));
5329 ti[pos]->text[0] = ' ';
5330 utf82u_strcpy(ti[pos]->text+1,otl->lookup_name);
5331 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5332 ti[pos++]->disabled = true;
5333 }
5334 ++lcnt;
5335 for ( sub=otl->subtables; sub!=NULL; sub=sub->next ) {
5336 if ( lookup_type!=gpos_pair || kernclass==-1 ||
5337 (kernclass && sub->kc!=NULL) ||
5338 (!kernclass && sub->per_glyph_pst_or_kern)) {
5339 if ( k ) {
5340 ti[pos] = calloc(1,sizeof(GTextInfo));
5341 ti[pos]->text = utf82u_copy(sub->subtable_name);
5342 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5343 ti[pos++]->userdata = sub;
5344 }
5345 ++cnt;
5346 }
5347 }
5348 }
5349 }
5350 if ( !k ) {
5351 ti = calloc(cnt+lcnt+3+2*add_none,sizeof(GTextInfo*));
5352 } else {
5353 ti[pos] = calloc(1,sizeof(GTextInfo));
5354 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5355 ti[pos++]->line = true;
5356 ti[pos] = calloc(1,sizeof(GTextInfo));
5357 ti[pos]->fg = ti[pos]->bg = COLOR_DEFAULT;
5358 ti[pos++]->text = utf82u_copy(_("New Lookup Subtable..."));
5359 ti[pos] = calloc(1,sizeof(GTextInfo));
5360 return( ti );
5361 }
5362 }
5363 /* We'll never get here */
5364 return( NULL );
5365 }
5366
5367 GTextInfo *SFSubtableListOfType(SplineFont *sf, int lookup_type, int kernclass,int add_none) {
5368 GTextInfo **temp, *ti;
5369 int cnt;
5370
5371 temp = SFSubtablesOfType(sf,lookup_type,kernclass,add_none);
5372 if ( temp==NULL )
5373 return( NULL );
5374 for ( cnt=0; temp[cnt]->text!=NULL || temp[cnt]->line; ++cnt );
5375 ti = calloc(cnt+1,sizeof(GTextInfo));
5376 for ( cnt=0; temp[cnt]->text!=NULL || temp[cnt]->line; ++cnt ) {
5377 ti[cnt] = *temp[cnt];
5378 free(temp[cnt]);
5379 }
5380 free(temp);
5381 return( ti );
5382 }
5383
5384 struct lookup_subtable *SFNewLookupSubtableOfType(SplineFont *sf, int lookup_type, struct subtable_data *sd, int def_layer ) {
5385 int isgpos = (lookup_type>=gpos_start);
5386 OTLookup *otl, *found=NULL;
5387 int cnt, ans;
5388 struct lookup_subtable *sub;
5389 char **choices;
5390
5391 if ( sf->cidmaster ) sf=sf->cidmaster;
5392
5393 cnt = 0;
5394 for ( otl=isgpos ? sf->gpos_lookups : sf->gsub_lookups; otl!=NULL; otl=otl->next )
5395 if ( otl->lookup_type==lookup_type )
5396 ++cnt;
5397 if ( cnt==0 ) {
5398 /* There are no lookups of this type, so there is nothing for them to */
5399 /* pick from. So we must create a new lookup for them, and then add */
5400 /* a subtable to it */
5401 found = CreateAndSortNewLookupOfType(sf,lookup_type);
5402 if ( found==NULL )
5403 return( NULL );
5404 sub = NewSubtable(found,isgpos,sf,sd,def_layer);
5405 /* even if they canceled the subtable creation they are now stuck */
5406 /* with the lookup */
5407 return( sub );
5408 }
5409
5410 /* I thought briefly that if cnt were 1 I might want to automagically */
5411 /* create a subtable in that lookup... but no. Still give them the */
5412 /* option of creating a new lookup */
5413
5414 choices = malloc((cnt+2)*sizeof(char *));
5415 for ( cnt=0, otl=isgpos ? sf->gpos_lookups : sf->gsub_lookups; otl!=NULL; otl=otl->next )
5416 if ( otl->lookup_type==lookup_type )
5417 choices[cnt++] = otl->lookup_name;
5418 choices[cnt++] = _("Create a new lookup");
5419 choices[cnt] = NULL;
5420 ans = gwwv_choose(_("Add a subtable to which lookup?"),(const char **) choices,cnt,cnt-1,
5421 _("Add a subtable to which lookup?"));
5422 if ( ans==-1 )
5423 found = NULL;
5424 else if ( ans==cnt-1 )
5425 found = CreateAndSortNewLookupOfType(sf,lookup_type);
5426 else {
5427 found = NULL;
5428 for ( cnt=0, otl=isgpos ? sf->gpos_lookups : sf->gsub_lookups; otl!=NULL; otl=otl->next ) {
5429 if ( otl->lookup_type==lookup_type ) {
5430 if ( cnt==ans ) {
5431 found = otl;
5432 break;
5433 } else
5434 ++cnt;
5435 }
5436 }
5437 }
5438 free(choices);
5439 if ( found==NULL )
5440 return( NULL );
5441
5442 return( NewSubtable(found,isgpos,sf,sd,def_layer));
5443 }
5444
5445 static void kf_activateMe(struct fvcontainer *fvc,FontViewBase *fvb) {
5446 struct kf_dlg *kf = (struct kf_dlg *) fvc;
5447 FontView *fv = (FontView *) fvb;
5448
5449 if ( !fv->notactive )
5450 return;
5451
5452 kf->first_fv->notactive = true;
5453 kf->second_fv->notactive = true;
5454 fv->notactive = false;
5455 kf->active = fv;
5456 GDrawSetUserData(kf->dw,fv);
5457 GDrawRequestExpose(kf->dw,NULL,false);
5458 }
5459
5460 static void kf_charEvent(struct fvcontainer *fvc,void *event) {
5461 struct kf_dlg *kf = (struct kf_dlg *) fvc;
5462 FVChar(kf->active,event);
5463 }
5464
5465 static void kf_doClose(struct fvcontainer *fvc) {
5466 struct kf_dlg *kf = (struct kf_dlg *) fvc;
5467 kf->done = true;
5468 }
5469
5470 static void kf_doResize(struct fvcontainer *fvc,FontViewBase *fvb,
5471 int width, int height) {
5472 struct kf_dlg *kf = (struct kf_dlg *) fvc;
5473 FontView *fv = (FontView *) fvb;
5474 FontView *otherfv = fv==kf->first_fv ? kf->second_fv : kf->first_fv;
5475 static int nested=0;
5476 GRect size;
5477
5478 if ( fv->filled==NULL || otherfv->filled == NULL )
5479 return; /* Not initialized yet */
5480 if ( nested )
5481 return;
5482 nested = 1;
5483 FVSetUIToMatch(otherfv,fv);
5484 nested = 0;
5485
5486 memset(&size,0,sizeof(size));
5487 size.height = fv->mbh + kf->infoh + kf->fh+4 + 2*(height-fv->mbh) + kf->fh + 2;
5488 size.width = width;
5489 GGadgetSetDesiredSize(kf->guts,NULL, &size);
5490 GHVBoxFitWindow(kf->topbox);
5491 }
5492
5493 static struct fvcontainer_funcs kernformat_funcs = {
5494 fvc_kernformat,
5495 true, /* Modal dialog. No charviews, etc. */
5496 kf_activateMe,
5497 kf_charEvent,
5498 kf_doClose,
5499 kf_doResize
5500 };
5501
5502 static void kf_FVSetSize(struct kf_dlg *kf,FontView *fv,int width, int height,
5503 int y, int sbsize) {
5504 int cc, rc, topchar;
5505 GRect subsize;
5506
5507 topchar = fv->rowoff*fv->colcnt;
5508 cc = (width-1) / fv->cbw;
5509 if ( cc<1 ) cc=1;
5510 rc = (height-1)/ fv->cbh;
5511 if ( rc<1 ) rc = 1;
5512 subsize.x = 0; subsize.y = 0;
5513 subsize.width = cc*fv->cbw + 1;
5514 subsize.height = rc*fv->cbh + 1;
5515 GDrawResize(fv->v,subsize.width,subsize.height);
5516 GDrawMove(fv->v,0,y);
5517 GGadgetMove(fv->vsb,subsize.width,y);
5518 GGadgetResize(fv->vsb,sbsize,subsize.height);
5519
5520 fv->colcnt = cc; fv->rowcnt = rc;
5521 fv->width = subsize.width; fv->height = subsize.height;
5522 fv->rowltot = (fv->b.map->enccount+fv->colcnt-1)/fv->colcnt;
5523 GScrollBarSetBounds(fv->vsb,0,fv->rowltot,fv->rowcnt);
5524 fv->rowoff = topchar/fv->colcnt;
5525 if ( fv->rowoff>=fv->rowltot-fv->rowcnt )
5526 fv->rowoff = fv->rowltot-fv->rowcnt;
5527 if ( fv->rowoff<0 ) fv->rowoff =0;
5528 GScrollBarSetPos(fv->vsb,fv->rowoff);
5529
5530 GDrawRequestExpose(fv->v,NULL,true);
5531 }
5532
5533 static void kf_sizeSet(struct kf_dlg *kf,GWindow dw) {
5534 GRect size, gsize;
5535 int width, height, y;
5536
5537 GDrawGetSize(dw,&size);
5538 GGadgetGetSize(kf->first_fv->vsb,&gsize);
5539 width = size.width - gsize.width;
5540 height = size.height - kf->mbh - kf->first_fv->infoh - 2*(kf->fh+4);
5541 height /= 2;
5542
5543 y = kf->mbh + kf->first_fv->infoh + (kf->fh + 4);
5544 kf_FVSetSize(kf,kf->first_fv,width,height,y,gsize.width);
5545
5546 kf->label2_y = y + height+2;
5547 y = kf->label2_y + kf->fh + 2;
5548 kf_FVSetSize(kf,kf->second_fv,width,height,y,gsize.width);
5549 }
5550
5551 static int kf_sub_e_h(GWindow pixmap, GEvent *event) {
5552 FontView *active_fv;
5553 struct kf_dlg *kf;
5554
5555 if ( event->type==et_destroy )
5556 return( true );
5557
5558 active_fv = (FontView *) GDrawGetUserData(pixmap);
5559 kf = (struct kf_dlg *) (active_fv->b.container);
5560
5561 if (( event->type==et_mouseup || event->type==et_mousedown ) &&
5562 (event->u.mouse.button>=4 && event->u.mouse.button<=7) ) {
5563 return( GGadgetDispatchEvent(active_fv->vsb,event));
5564 }
5565
5566 Color fg = GDrawGetDefaultForeground(NULL);
5567 switch ( event->type ) {
5568 case et_expose:
5569 FVDrawInfo(active_fv,pixmap,event);
5570 GDrawSetFont(pixmap, kf->first_fv->notactive? kf->plain : kf->bold );
5571 GDrawDrawText8(pixmap,10,kf->mbh+kf->first_fv->infoh+kf->as,
5572 _("Select glyphs for the first part of the kern pair"),-1,fg);
5573 GDrawSetFont(pixmap, kf->second_fv->notactive? kf->plain : kf->bold );
5574 GDrawDrawText8(pixmap,10,kf->label2_y+kf->as,
5575 _("Select glyphs for the second part of the kern pair"),-1,fg);
5576 break;
5577 case et_char:
5578 kf_charEvent(&kf->base,event);
5579 break;
5580 case et_mousedown:
5581 if ( event->u.mouse.y<kf->mbh )
5582 return(false);
5583 kf_activateMe(&kf->base,(struct fontviewbase *)
5584 (( event->u.mouse.y > kf->label2_y ) ?
5585 kf->second_fv : kf->first_fv) );
5586 return(false);
5587 break;
5588 case et_mouseup: case et_mousemove:
5589 return(false);
5590 case et_resize:
5591 kf_sizeSet(kf,pixmap);
5592 break;
5593 default: break;
5594 }
5595 return( true );
5596 }
5597
5598 #undef CID_Separation
5599 #undef CID_MinKern
5600 #undef CID_Touched
5601 #undef CID_OnlyCloser
5602 #undef CID_Autokern
5603 #define CID_KPairs 1000
5604 #define CID_KClasses 1001
5605 #define CID_KCBuild 1002
5606 #define CID_Separation 1003
5607 #define CID_MinKern 1004
5608 #define CID_Touched 1005
5609 #define CID_ClassDistance 1006
5610 #define CID_Guts 1008
5611 #define CID_OnlyCloser 1009
5612 #define CID_Autokern 1010
5613
5614 struct kf_results {
5615 int asked;
5616 int autokern;
5617 int autobuild;
5618 real good_enough;
5619 SplineChar **firstglyphs;
5620 SplineChar **secondglyphs;
5621 };
5622
5623 static int KF_FormatChange(GGadget *g, GEvent *e) {
5624 struct kf_dlg *kf;
5625 char mkbuf[10];
5626
5627 if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
5628 kf = GDrawGetUserData(GGadgetGetWindow(g));
5629 if ( GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_KPairs)) ) {
5630 GGadgetSetEnabled(GWidgetGetControl(kf->gw,CID_KCBuild),0);
5631 sprintf(mkbuf,"%d",15*(kf->sf->ascent+kf->sf->descent)/1000 );
5632 GGadgetSetTitle8(GWidgetGetControl(kf->gw,CID_MinKern),mkbuf);
5633 } else {
5634 GGadgetSetEnabled(GWidgetGetControl(kf->gw,CID_KCBuild),1);
5635 GGadgetSetTitle8(GWidgetGetControl(kf->gw,CID_MinKern),"0");
5636 }
5637 }
5638 return( true );
5639 }
5640
5641 static SplineChar **SelectedGlyphs(FontView *_fv) {
5642 FontViewBase *fv = (FontViewBase *) _fv;
5643 SplineFont *sf;
5644 EncMap *map;
5645 int selcnt;
5646 int enc,gid;
5647 SplineChar **glyphlist, *sc;
5648
5649 map = fv->map;
5650 sf = fv->sf;
5651 selcnt=0;
5652 for ( enc=0; enc<map->enccount; ++enc ) {
5653 if ( fv->selected[enc] && (gid=map->map[enc])!=-1 &&
5654 SCWorthOutputting(sf->glyphs[gid]))
5655 ++selcnt;
5656 }
5657 if ( selcnt<1 ) {
5658 ff_post_error(_("No selection"), _("Please select some glyphs in the font views at the bottom of the dialog for FontForge to put into classes."));
5659 return(NULL);
5660 }
5661
5662 glyphlist = malloc((selcnt+1)*sizeof(SplineChar *));
5663 selcnt=0;
5664 for ( enc=0; enc<map->enccount; ++enc ) {
5665 if ( fv->selected[enc] && (gid=map->map[enc])!=-1 &&
5666 SCWorthOutputting(sc = sf->glyphs[gid]))
5667 glyphlist[selcnt++] = sc;
5668 }
5669 glyphlist[selcnt] = NULL;
5670 return( glyphlist );
5671 }
5672
5673 static int KF_OK(GGadget *g, GEvent *e) {
5674
5675 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
5676 struct kf_dlg *kf = GDrawGetUserData(GGadgetGetWindow(g));
5677 int touch, separation, minkern, err, onlyCloser, autokern;
5678 real good_enough=0;
5679 int isclass, autobuild=0;
5680 struct kf_results *results = kf->results;
5681
5682 err = false;
5683 touch = GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_Touched));
5684 separation = GetInt8(kf->gw,CID_Separation,_("Separation"),&err);
5685 minkern = GetInt8(kf->gw,CID_MinKern,_("Min Kern"),&err);
5686 onlyCloser = GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_OnlyCloser));
5687 autokern = GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_Autokern));
5688 if ( err )
5689 return( true );
5690
5691 isclass = GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_KClasses));
5692 if ( isclass ) {
5693 autobuild = GGadgetIsChecked(GWidgetGetControl(kf->gw,CID_KCBuild));
5694 good_enough = GetReal8(kf->gw,CID_ClassDistance,_("Intra Class Distance"),&err);
5695 if ( err )
5696 return( true );
5697 }
5698 if ( autobuild || autokern ) {
5699 results->firstglyphs = SelectedGlyphs(kf->first_fv);
5700 if ( results->firstglyphs == NULL )
5701 return( true );
5702 results->secondglyphs = SelectedGlyphs(kf->second_fv);
5703 if ( results->secondglyphs == NULL ) {
5704 free(results->firstglyphs); results->firstglyphs=NULL;
5705 return( true );
5706 }
5707 }
5708 kf->sub->separation = separation;
5709 kf->sub->minkern = minkern;
5710 kf->sub->kerning_by_touch = touch;
5711 kf->sub->onlyCloser = onlyCloser;
5712 kf->sub->dontautokern = !autokern;
5713 results->good_enough = good_enough;
5714 if ( !isclass )
5715 results->asked = 0;
5716 else
5717 results->asked = 1;
5718 results->autobuild = autobuild;
5719 results->autokern = autokern;
5720 kf->done = true;
5721 }
5722 return( true );
5723 }
5724
5725 static int KF_Cancel(GGadget *g, GEvent *e) {
5726 struct kf_dlg *kf;
5727
5728 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
5729 kf = GDrawGetUserData(GGadgetGetWindow(g));
5730 kf->done = true;
5731 }
5732 return( true );
5733 }
5734
5735 static int kf_e_h(GWindow gw, GEvent *event) {
5736 struct kf_dlg *kf = GDrawGetUserData(gw);
5737
5738 switch ( event->type ) {
5739 case et_close:
5740 kf->done = true;
5741 break;
5742 case et_char:
5743 return( false );
5744 break;
5745 default: break;
5746 }
5747 return( true );
5748 }
5749
5750 static int kern_format_dlg( SplineFont *sf, int def_layer,
5751 struct lookup_subtable *sub, struct kf_results *results ) {
5752 GRect pos;
5753 GWindowAttrs wattrs;
5754 GGadgetCreateData gcd[16], boxes[7], hbox;
5755 GGadgetCreateData *varray[21], *h2array[6], *h3array[6], *h4array[8], *buttonarray[8], *h5array[4];
5756 GTextInfo label[15];
5757 char sepbuf[40], mkbuf[40], distancebuf[40];
5758 struct kf_dlg kf;
5759 int i,j, guts_row;
5760 /* Returns are 0=>Pairs, 1=>Classes, 2=>Cancel */
5761 int as, ds, ld;
5762
5763 if ( sub->separation==0 && !sub->kerning_by_touch ) {
5764 sub->separation = sf->width_separation;
5765 if ( sf->width_separation==0 )
5766 sub->separation = 15*(sf->ascent+sf->descent)/100;
5767 sub->minkern = sub->separation/10;
5768 }
5769
5770 memset(&wattrs,0,sizeof(wattrs));
5771 memset(&gcd,0,sizeof(gcd));
5772 memset(&boxes,0,sizeof(boxes));
5773 memset(&label,0,sizeof(label));
5774 memset(&kf,0,sizeof(kf));
5775
5776 kf.base.funcs = &kernformat_funcs;
5777 kf.sub = sub;
5778 kf.results = results;
5779 kf.sf = sf;
5780 kf.def_layer = def_layer;
5781 results->asked = 2; /* Cancel */
5782
5783 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
5784 wattrs.event_masks = ~(1<<et_charup);
5785 wattrs.restrict_input_to_me = true;
5786 wattrs.undercursor = 1;
5787 wattrs.cursor = ct_pointer;
5788 wattrs.utf8_window_title = _("Kerning format") ;
5789 wattrs.is_dlg = true;
5790 pos.x = pos.y = 0;
5791 pos.width = 100;
5792 pos.height = 100;
5793 kf.gw = GDrawCreateTopWindow(NULL,&pos,kf_e_h,&kf,&wattrs);
5794
5795 kf.plain = kernformat_font.fi;
5796 kf.bold = kernformat_boldfont.fi;
5797 GDrawWindowFontMetrics(kf.gw,kf.plain,&as,&ds,&ld);
5798 kf.fh = as+ds; kf.as = as;
5799
5800 i = j = 0;
5801
5802 label[i].text = (unichar_t *) _("Use individual kerning pairs");
5803 label[i].text_is_1byte = true;
5804 label[i].text_in_resource = true;
5805 gcd[i].gd.label = &label[i];
5806 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5807 gcd[i].gd.popup_msg = _(
5808 "In this format you specify every kerning pair in which\n"
5809 "you are interested in." );
5810 gcd[i].gd.cid = CID_KPairs;
5811 gcd[i].gd.handle_controlevent = KF_FormatChange;
5812 gcd[i].creator = GRadioCreate;
5813 varray[j++] = &gcd[i++]; varray[j++] = NULL;
5814
5815 label[i].text = (unichar_t *) _("Use a matrix of kerning classes");
5816 label[i].text_is_1byte = true;
5817 label[i].text_in_resource = true;
5818 gcd[i].gd.label = &label[i];
5819 gcd[i].gd.flags = gg_enabled|gg_visible|gg_rad_continueold;
5820 gcd[i].gd.popup_msg = _(
5821 "In this format you define a series of glyph classes and\n"
5822 "specify a matrix showing how each class interacts with all\n"
5823 "the others.");
5824 gcd[i].gd.cid = CID_KClasses;
5825 gcd[i].gd.handle_controlevent = KF_FormatChange;
5826 gcd[i].creator = GRadioCreate;
5827 varray[j++] = &gcd[i++]; varray[j++] = NULL;
5828
5829 label[i].text = (unichar_t *) _("FontForge will guess kerning classes for selected glyphs");
5830 label[i].text_is_1byte = true;
5831 label[i].text_in_resource = true;
5832 gcd[i].gd.label = &label[i];
5833 gcd[i].gd.flags = gg_visible|gg_cb_on;
5834 gcd[i].gd.popup_msg = _(
5835 "FontForge will look at the glyphs selected in the font view\n"
5836 "and will try to find groups of glyphs which are most alike\n"
5837 "and generate kerning classes based on that information." );
5838 gcd[i].gd.cid = CID_KCBuild;
5839 gcd[i].creator = GCheckBoxCreate;
5840 h2array[0] = GCD_HPad10; h2array[1] = &gcd[i++]; h2array[2] = GCD_Glue; h2array[3] = NULL;
5841 boxes[3].gd.flags = gg_enabled|gg_visible;
5842 boxes[3].gd.u.boxelements = h2array;
5843 boxes[3].creator = GHBoxCreate;
5844 varray[j++] = &boxes[3]; varray[j++] = NULL;
5845
5846 label[i].text = (unichar_t *) _("Intra Class Distance:");
5847 label[i].text_is_1byte = true;
5848 label[i].text_in_resource = true;
5849 gcd[i].gd.label = &label[i];
5850 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
5851 gcd[i].gd.flags = gg_enabled|gg_visible;
5852 gcd[i].gd.popup_msg = _(
5853 "This is roughly (very roughly) the number off em-units\n"
5854 "of error that two glyphs may have to belong in the same\n"
5855 "class. This error is taken by comparing the two glyphs\n"
5856 "to all other glyphs and summing the differences.\n"
5857 "A small number here (like 2) means lots of small classes,\n"
5858 "while a larger number (like 20) will mean fewer classes,\n"
5859 "each with more glyphs." );
5860 gcd[i].creator = GLabelCreate;
5861 h3array[0] = GCD_HPad10; h3array[1] = &gcd[i++];
5862
5863 sprintf( distancebuf, "%g", (sf->ascent+sf->descent)/100. );
5864 label[i].text = (unichar_t *) distancebuf;
5865 label[i].text_is_1byte = true;
5866 label[i].text_in_resource = true;
5867 gcd[i].gd.label = &label[i];
5868 gcd[i].gd.pos.width = 50;
5869 gcd[i].gd.flags = gg_enabled|gg_visible;
5870 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
5871 gcd[i].gd.cid = CID_ClassDistance;
5872 gcd[i].creator = GTextFieldCreate;
5873 h3array[2] = &gcd[i++]; h3array[3] = GCD_Glue; h3array[4] = NULL;
5874
5875 boxes[5].gd.flags = gg_enabled|gg_visible;
5876 boxes[5].gd.u.boxelements = h3array;
5877 boxes[5].creator = GHBoxCreate;
5878 varray[j++] = &boxes[5]; varray[j++] = NULL;
5879 varray[j++] = GCD_Glue; varray[j++] = NULL;
5880
5881 label[i].text = (unichar_t *) _("_Default Separation:");
5882 label[i].text_is_1byte = true;
5883 label[i].text_in_resource = true;
5884 gcd[i].gd.label = &label[i];
5885 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
5886 gcd[i].gd.flags = gg_enabled|gg_visible;
5887 gcd[i].gd.popup_msg = _(
5888 "Add entries to the lookup trying to make the optical\n"
5889 "separation between all pairs of glyphs equal to this\n"
5890 "value." );
5891 gcd[i].creator = GLabelCreate;
5892 h4array[0] = &gcd[i++];
5893
5894 sprintf( sepbuf, "%d", sub->separation );
5895 label[i].text = (unichar_t *) sepbuf;
5896 label[i].text_is_1byte = true;
5897 label[i].text_in_resource = true;
5898 gcd[i].gd.label = &label[i];
5899 gcd[i].gd.pos.width = 50;
5900 gcd[i].gd.flags = gg_enabled|gg_visible;
5901 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
5902 gcd[i].gd.cid = CID_Separation;
5903 gcd[i].creator = GTextFieldCreate;
5904 h4array[1] = &gcd[i++]; h4array[2] = GCD_Glue;
5905
5906 label[i].text = (unichar_t *) _("_Min Kern:");
5907 label[i].text_is_1byte = true;
5908 label[i].text_in_resource = true;
5909 gcd[i].gd.label = &label[i];
5910 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
5911 gcd[i].gd.flags = gg_enabled|gg_visible;
5912 gcd[i].gd.popup_msg = _(
5913 "Any computed kerning change whose absolute value is less\n"
5914 "that this will be ignored.\n" );
5915 gcd[i].creator = GLabelCreate;
5916 h4array[3] = &gcd[i++];
5917
5918 sprintf( mkbuf, "%d", sub->minkern );
5919 label[i].text = (unichar_t *) mkbuf;
5920 label[i].text_is_1byte = true;
5921 label[i].text_in_resource = true;
5922 gcd[i].gd.label = &label[i];
5923 gcd[i].gd.pos.width = 50;
5924 gcd[i].gd.flags = gg_enabled|gg_visible;
5925 gcd[i].gd.popup_msg = gcd[i-1].gd.popup_msg;
5926 gcd[i].gd.cid = CID_MinKern;
5927 gcd[i].creator = GTextFieldCreate;
5928 h4array[4] = &gcd[i++];
5929
5930 label[i].text = (unichar_t *) _("_Touching");
5931 label[i].text_is_1byte = true;
5932 label[i].text_in_resource = true;
5933 gcd[i].gd.label = &label[i];
5934 gcd[i].gd.pos.x = 5; gcd[i].gd.pos.y = 5+4;
5935 gcd[i].gd.flags = gg_enabled|gg_visible;
5936 if ( sub->kerning_by_touch )
5937 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5938 gcd[i].gd.popup_msg = _(
5939 "Normally kerning is based on achieving a constant (optical)\n"
5940 "separation between glyphs, but occasionally it is desirable\n"
5941 "to have a kerning table where the kerning is based on the\n"
5942 "closest approach between two glyphs (So if the desired separ-\n"
5943 "ation is 0 then the glyphs will actually be touching.");
5944 gcd[i].gd.cid = CID_Touched;
5945 gcd[i].creator = GCheckBoxCreate;
5946 h4array[5] = &gcd[i++];
5947
5948 h4array[6] = GCD_Glue; h4array[7] = NULL;
5949
5950 boxes[4].gd.flags = gg_enabled|gg_visible;
5951 boxes[4].gd.u.boxelements = h4array;
5952 boxes[4].creator = GHBoxCreate;
5953 varray[j++] = &boxes[4]; varray[j++] = NULL;
5954
5955 label[i].text = (unichar_t *) _("Only kern glyphs closer");
5956 label[i].text_is_1byte = true;
5957 label[i].text_in_resource = true;
5958 gcd[i].gd.label = &label[i];
5959 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5960 if ( sub->onlyCloser )
5961 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5962 gcd[i].gd.popup_msg = _(
5963 "When doing autokerning, only move glyphs closer together,\n"
5964 "so the kerning offset will be negative.");
5965 gcd[i].gd.cid = CID_OnlyCloser;
5966 gcd[i].creator = GCheckBoxCreate;
5967 h5array[0] = &gcd[i++];
5968
5969 label[i].text = (unichar_t *) _("Autokern new entries");
5970 label[i].text_is_1byte = true;
5971 label[i].text_in_resource = true;
5972 gcd[i].gd.label = &label[i];
5973 gcd[i].gd.flags = gg_enabled|gg_visible;
5974 if ( !sub->dontautokern )
5975 gcd[i].gd.flags = gg_enabled|gg_visible|gg_cb_on;
5976 gcd[i].gd.popup_msg = _(
5977 "When adding new entries provide default kerning values.");
5978 gcd[i].gd.cid = CID_Autokern;
5979 gcd[i].creator = GCheckBoxCreate;
5980 h5array[1] = &gcd[i++]; h5array[2] = NULL;
5981
5982 memset(&hbox,0,sizeof(hbox));
5983 hbox.gd.flags = gg_enabled|gg_visible;
5984 hbox.gd.u.boxelements = h5array;
5985 hbox.creator = GHBoxCreate;
5986 varray[j++] = &hbox; varray[j++] = NULL;
5987
5988 guts_row = j/2;
5989 gcd[i].gd.flags = gg_enabled|gg_visible;
5990 gcd[i].gd.cid = CID_Guts;
5991 gcd[i].gd.u.drawable_e_h = kf_sub_e_h;
5992 gcd[i].creator = GDrawableCreate;
5993 varray[j++] = &gcd[i++]; varray[j++] = NULL;
5994
5995 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default;
5996 label[i].text = (unichar_t *) _("_OK");
5997 label[i].text_is_1byte = true;
5998 label[i].text_in_resource = true;
5999 gcd[i].gd.label = &label[i];
6000 gcd[i].gd.handle_controlevent = KF_OK;
6001 gcd[i++].creator = GButtonCreate;
6002
6003 gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
6004 label[i].text = (unichar_t *) _("_Cancel");
6005 label[i].text_is_1byte = true;
6006 label[i].text_in_resource = true;
6007 gcd[i].gd.label = &label[i];
6008 gcd[i].gd.handle_controlevent = KF_Cancel;
6009 gcd[i++].creator = GButtonCreate;
6010
6011 buttonarray[0] = GCD_Glue; buttonarray[1] = &gcd[i-2]; buttonarray[2] = GCD_Glue;
6012 buttonarray[3] = GCD_Glue; buttonarray[4] = &gcd[i-1]; buttonarray[5] = GCD_Glue;
6013 buttonarray[6] = NULL;
6014 boxes[6].gd.flags = gg_enabled|gg_visible;
6015 boxes[6].gd.u.boxelements = buttonarray;
6016 boxes[6].creator = GHBoxCreate;
6017 varray[j++] = &boxes[6]; varray[j++] = NULL; varray[j++] = NULL;
6018
6019 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
6020 boxes[0].gd.flags = gg_enabled|gg_visible;
6021 boxes[0].gd.u.boxelements = varray;
6022 boxes[0].creator = GHVGroupCreate;
6023
6024 GGadgetsCreate(kf.gw,boxes);
6025
6026 GHVBoxSetExpandableRow(boxes[0].ret,guts_row);
6027 GHVBoxSetExpandableCol(boxes[3].ret,gb_expandglue);
6028 GHVBoxSetExpandableCol(boxes[4].ret,gb_expandglue);
6029 GHVBoxSetExpandableCol(boxes[5].ret,gb_expandglue);
6030 GHVBoxSetExpandableCol(boxes[6].ret,gb_expandgluesame);
6031
6032 kf.topbox = boxes[0].ret;
6033 KFFontViewInits(&kf, GWidgetGetControl(kf.gw,CID_Guts));
6034 kf_activateMe((struct fvcontainer *) &kf,(struct fontviewbase *) kf.first_fv);
6035
6036 GHVBoxFitWindow(boxes[0].ret);
6037 GDrawSetVisible(kf.gw,true);
6038 while ( !kf.done )
6039 GDrawProcessOneEvent(NULL);
6040 FontViewFree(&kf.second_fv->b);
6041 FontViewFree(&kf.first_fv->b);
6042 GDrawSetUserData(kf.gw,NULL);
6043 GDrawDestroyWindow(kf.gw);
6044 return( results->asked );
6045 }
6046
6047 void _LookupSubtableContents(SplineFont *sf, struct lookup_subtable *sub,
6048 struct subtable_data *sd,int def_layer) {
6049 int lookup_type = sub->lookup->lookup_type;
6050 static int nested=0;
6051 extern int default_autokern_dlg;
6052
6053 if ( (lookup_type == gsub_context || lookup_type == gsub_contextchain ||
6054 lookup_type == gsub_reversecchain ||
6055 lookup_type == gpos_context || lookup_type == gpos_contextchain) &&
6056 sub->fpst==NULL ) {
6057 sub->fpst = chunkalloc(sizeof(FPST));
6058 sub->fpst->type = lookup_type == gsub_context ? pst_contextsub :
6059 lookup_type == gsub_contextchain ? pst_chainsub :
6060 lookup_type == gsub_reversecchain ? pst_reversesub :
6061 lookup_type == gpos_context ? pst_contextpos :
6062 pst_chainpos;
6063 if ( lookup_type == gsub_reversecchain )
6064 sub->fpst->format = pst_reversecoverage;
6065 sub->fpst->subtable = sub;
6066 sub->fpst->next = sf->possub;
6067 sf->possub = sub->fpst;
6068 } else if ( (lookup_type == morx_indic ||
6069 lookup_type == morx_context ||
6070 lookup_type == morx_insert ||
6071 lookup_type == kern_statemachine) &&
6072 sub->sm==NULL ) {
6073 sub->sm = chunkalloc(sizeof(ASM));
6074 sub->sm->type = lookup_type == morx_indic ? asm_indic :
6075 lookup_type == morx_context ? asm_context :
6076 lookup_type == morx_insert ? asm_insert :
6077 asm_kern;
6078 sub->sm->subtable = sub;
6079 sub->sm->next = sf->sm;
6080 sf->sm = sub->sm;
6081 } else if ( lookup_type==gpos_pair &&
6082 sub->kc==NULL &&
6083 !sub->per_glyph_pst_or_kern ) {
6084 char *buts[5];
6085 struct kf_results results;
6086
6087 memset(&results,0,sizeof(results));
6088 if ( sd!=NULL && sd->flags&sdf_verticalkern )
6089 sub->vertical_kerning = true;
6090 else if ( sd!=NULL && sd->flags&sdf_horizontalkern )
6091 sub->vertical_kerning = false;
6092 else
6093 sub->vertical_kerning = VerticalKernFeature(sf,sub->lookup,true);
6094
6095 if ( sd!=NULL && (sd->flags&sdf_kernclass) )
6096 results.asked = 1;
6097 else if ( sd!=NULL && (sd->flags&sdf_kernpair) )
6098 results.asked = 0;
6099 else {
6100 if ( sub->vertical_kerning || nested || !default_autokern_dlg ) {
6101 buts[0] = _("_Pairs"); buts[1] = _("C_lasses");
6102 buts[2] = _("_Cancel"); buts[3]=NULL;
6103 results.asked = gwwv_ask(_("Kerning format"),(const char **) buts,0,1,_("Kerning may be specified either by classes of glyphs\nor by pairwise combinations of individual glyphs.\nWhich do you want for this subtable?") );
6104 } else {
6105 nested = 1;
6106 kern_format_dlg(sf,def_layer,sub,&results);
6107 nested = 0;
6108 }
6109 if ( results.asked==2 )
6110 return;
6111 }
6112 if ( results.asked==0 ) {
6113 sub->per_glyph_pst_or_kern = true;
6114 if ( results.autokern ) {
6115 SplineChar **lefts, **rights;
6116 if ( sub->lookup->lookup_flags & pst_r2l ) {
6117 lefts = results.secondglyphs;
6118 rights = results.firstglyphs;
6119 } else {
6120 lefts = results.firstglyphs;
6121 rights = results.secondglyphs;
6122 }
6123 AutoKern2(sf, def_layer,lefts,rights,
6124 sub,
6125 /* If separation==0 and !touch then use default values */
6126 0,0,0,0, 0, NULL, NULL);
6127 }
6128 } else {
6129 sub->kc = chunkalloc(sizeof(KernClass));
6130 if ( sub->vertical_kerning ) {
6131 sub->kc->next = sf->vkerns;
6132 sf->vkerns = sub->kc;
6133 } else {
6134 sub->kc->next = sf->kerns;
6135 sf->kerns = sub->kc;
6136 }
6137 sub->kc->subtable = sub;
6138 sub->kc->first_cnt = sub->kc->second_cnt = 1;
6139 sub->kc->firsts = calloc(1,sizeof(char *));
6140 sub->kc->seconds = calloc(1,sizeof(char *));
6141 sub->kc->offsets = calloc(1,sizeof(int16_t));
6142 sub->kc->adjusts = calloc(1,sizeof(DeviceTable));
6143 /* Need to fix for Hebrew !!!! */
6144 if ( results.autobuild )
6145 /* Specifying separation==0 and !touching means use default values */
6146 AutoKern2BuildClasses(sf,def_layer,results.firstglyphs,
6147 results.secondglyphs,sub,0,0,0,0,0,results.good_enough);
6148 }
6149 free(results.firstglyphs);
6150 free(results.secondglyphs);
6151 }
6152
6153 if ( sub->fpst && sf->fontinfo!=NULL ) {
6154 ContextChainEdit(sf,sub->fpst,sf->fontinfo,NULL,def_layer);
6155 } else if ( sub->sm && sf->fontinfo!=NULL ) {
6156 StateMachineEdit(sf,sub->sm,sf->fontinfo);
6157 } else if ( sub->kc!=NULL ) {
6158 KernClassD(sub->kc,sf,def_layer,sub->vertical_kerning);
6159 } else if ( sub->lookup->lookup_type>=gpos_cursive &&
6160 sub->lookup->lookup_type<=gpos_mark2mark )
6161 AnchorClassD(sf,sub,def_layer);
6162 else
6163 PSTKernD(sf,sub,def_layer);
6164 }
6165 /******************************************************************************/
6166 /*************************** Add/Remove Language **************************/
6167 /******************************************************************************/
6168 static uint32_t StrNextLang(char **_pt) {
6169 unsigned char *pt = (unsigned char *) *_pt;
6170 unsigned char tag[4];
6171 int i;
6172
6173 memset(tag,' ',4);
6174 while ( *pt==' ' || *pt==',' ) ++pt;
6175 if ( *pt=='\0' )
6176 return( 0 );
6177
6178 for ( i=0; i<4 && *pt!='\0' && *pt!=','; ++i )
6179 tag[i] = *pt++;
6180 while ( *pt==' ' ) ++pt;
6181 if ( *pt!='\0' && *pt!=',' )
6182 return( 0xffffffff );
6183 *_pt = (char *) pt;
6184 return( (tag[0]<<24) | (tag[1]<<16) | (tag[2]<<8) | tag[3] );
6185 }
6186
6187 static void lk_AddRm(struct lkdata *lk,int add_lang,uint32_t script, char *langs) {
6188 int i,l;
6189 OTLookup *otl;
6190 FeatureScriptLangList *fl;
6191 struct scriptlanglist *sl;
6192 uint32_t lang;
6193 char *pt;
6194
6195 for ( i=0; i<lk->cnt; ++i ) {
6196 if ( lk->all[i].deleted || !lk->all[i].selected )
6197 continue;
6198 otl = lk->all[i].lookup;
6199 for ( fl= otl->features; fl!=NULL; fl=fl->next ) {
6200 for ( sl=fl->scripts; sl!=NULL; sl=sl->next ) if ( sl->script==script ) {
6201 pt = langs;
6202 while ( (lang = StrNextLang(&pt))!=0 ) {
6203 for ( l=sl->lang_cnt-1; l>=0; --l ) {
6204 if ( ((l>=MAX_LANG) ? sl->morelangs[l-MAX_LANG] : sl->langs[l]) == lang )
6205 break;
6206 }
6207 if ( add_lang && l<0 ) {
6208 if ( sl->lang_cnt<MAX_LANG ) {
6209 sl->langs[sl->lang_cnt++] = lang;
6210 } else {
6211 sl->morelangs = realloc(sl->morelangs,(++sl->lang_cnt-MAX_LANG)*sizeof(uint32_t));
6212 sl->morelangs[sl->lang_cnt-MAX_LANG-1] = lang;
6213 }
6214 } else if ( !add_lang && l>=0 ) {
6215 --sl->lang_cnt;
6216 while ( l<sl->lang_cnt ) {
6217 uint32_t nlang = l+1>=MAX_LANG ? sl->morelangs[l+1-MAX_LANG] : sl->langs[l+1];
6218 if ( l>=MAX_LANG )
6219 sl->morelangs[l-MAX_LANG] = nlang;
6220 else
6221 sl->langs[l] = nlang;
6222 ++l;
6223 }
6224 if ( sl->lang_cnt==0 ) {
6225 sl->langs[0] = DEFAULT_LANG;
6226 sl->lang_cnt = 1;
6227 }
6228 }
6229 }
6230 }
6231 }
6232 }
6233 }
6234
6235 #define CID_ScriptTag 1001
6236 #define CID_Langs 1002
6237
6238 struct addrmlang {
6239 GWindow gw;
6240 int done;
6241 int add_lang;
6242 struct lkdata *lk;
6243 };
6244
6245 static int ARL_OK(GGadget *g, GEvent *e) {
6246
6247 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
6248 struct addrmlang *arl = GDrawGetUserData(GGadgetGetWindow(g));
6249 const unichar_t *spt;
6250 char *langs, *pt;
6251 int i;
6252 unsigned char tag[4];
6253 uint32_t script_tag, lang;
6254
6255 memset(tag,' ',4);
6256 spt = _GGadgetGetTitle(GWidgetGetControl(arl->gw,CID_ScriptTag));
6257 while ( *spt==' ' ) ++spt;
6258 if ( *spt=='\0' ) {
6259 ff_post_error(_("No Script Tag"), _("Please specify a 4 letter opentype script tag"));
6260 return( true );
6261 }
6262 for ( i=0; i<4 && *spt!='\0'; ++i )
6263 tag[i] = *spt++;
6264 while ( *spt==' ' ) ++spt;
6265 if ( *spt!='\0' ) {
6266 ff_post_error(_("Script Tag too long"), _("Please specify a 4 letter opentype script tag"));
6267 return( true );
6268 }
6269 script_tag = (tag[0]<<24) | (tag[1]<<16) | (tag[2]<<8) | tag[3];
6270
6271 pt = langs = GGadgetGetTitle8(GWidgetGetControl(arl->gw,CID_Langs));
6272 while ( (lang = StrNextLang(&pt))!=0 ) {
6273 if ( lang==0xffffffff ) {
6274 ff_post_error(_("Invalid language"), _("Please specify a comma separated list of 4 letter opentype language tags"));
6275 return( true );
6276 }
6277 }
6278
6279 lk_AddRm(arl->lk,arl->add_lang,script_tag, langs);
6280 free(langs);
6281 arl->done = true;
6282 }
6283 return( true );
6284 }
6285
6286 static int ARL_Cancel(GGadget *g, GEvent *e) {
6287
6288 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
6289 struct addrmlang *arl = GDrawGetUserData(GGadgetGetWindow(g));
6290 arl->done = true;
6291 }
6292 return( true );
6293 }
6294
6295 static int ARL_TagChanged(GGadget *g, GEvent *e) {
6296 if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged &&
6297 e->u.control.u.tf_changed.from_pulldown != -1 ) {
6298 int which = e->u.control.u.tf_changed.from_pulldown;
6299 int len;
6300 GTextInfo **ti = GGadgetGetList(g,&len);
6301 char tag[8];
6302 uint32_t tagval = (intptr_t) (ti[which]->userdata);
6303
6304 tag[0] = tagval>>24;
6305 tag[1] = tagval>>16;
6306 tag[2] = tagval>>8;
6307 tag[3] = tagval;
6308 tag[4] = 0;
6309 GGadgetSetTitle8(g,tag);
6310 }
6311 return( true );
6312 }
6313
6314 static int arl_e_h(GWindow gw, GEvent *event) {
6315 struct addrmlang *arl = GDrawGetUserData(gw);
6316
6317 switch ( event->type ) {
6318 case et_char:
6319 return( false );
6320 case et_close:
6321 arl->done = true;
6322 break;
6323 default: break;
6324 }
6325 return( true );
6326 }
6327
6328 static GTextInfo *ScriptListOfFont(SplineFont *sf) {
6329 uint32_t *ourscripts = SFScriptsInLookups(sf);
6330 int i,j;
6331 GTextInfo *ti;
6332 char tag[8];
6333
6334 if ( ourscripts==NULL || ourscripts[0]==0 ) {
6335 free(ourscripts);
6336 ourscripts = malloc(2*sizeof(uint32_t));
6337 ourscripts[0] = DEFAULT_SCRIPT;
6338 ourscripts[1] = 0;
6339 }
6340 for ( i=0; ourscripts[i]!=0; ++i );
6341 ti = calloc(i+1,sizeof(GTextInfo));
6342 for ( i=0; ourscripts[i]!=0; ++i ) {
6343 ti[i].userdata = (void *) (intptr_t) ourscripts[i];
6344 for ( j=0; scripts[j].text!=NULL; ++j) {
6345 if ( scripts[j].userdata == (void *) (intptr_t) ourscripts[i])
6346 break;
6347 }
6348 if ( scripts[j].text!=NULL )
6349 ti[i].text = (unichar_t *) copy( (char *) scripts[j].text );
6350 else {
6351 tag[0] = ourscripts[i]>>24;
6352 tag[1] = ourscripts[i]>>16;
6353 tag[2] = ourscripts[i]>>8;
6354 tag[3] = ourscripts[i]&0xff;
6355 tag[4] = 0;
6356 ti[i].text = (unichar_t *) copy( (char *) tag );
6357 }
6358 ti[i].text_is_1byte = true;
6359 }
6360 ti[0].selected = true;
6361 free(ourscripts);
6362 return( ti );
6363 }
6364
6365 void AddRmLang(SplineFont *sf, struct lkdata *lk,int add_lang) {
6366 GRect pos;
6367 GWindow gw;
6368 GWindowAttrs wattrs;
6369 struct addrmlang arl;
6370 GGadgetCreateData gcd[14], *hvarray[4][3], *barray[8], boxes[3];
6371 GTextInfo label[14];
6372 int k;
6373 GEvent dummy;
6374
6375 LookupUIInit();
6376
6377 memset(&arl,0,sizeof(arl));
6378 arl.lk = lk;
6379 arl.add_lang = add_lang;
6380
6381 memset(&wattrs,0,sizeof(wattrs));
6382 memset(&gcd,0,sizeof(gcd));
6383 memset(&boxes,0,sizeof(boxes));
6384 memset(&label,0,sizeof(label));
6385
6386 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
6387 wattrs.event_masks = ~(1<<et_charup);
6388 wattrs.restrict_input_to_me = true;
6389 wattrs.undercursor = 1;
6390 wattrs.cursor = ct_pointer;
6391 wattrs.utf8_window_title = add_lang ? _("Add Language(s) to Script") : _("Remove Language(s) from Script");
6392 wattrs.is_dlg = true;
6393 pos.x = pos.y = 0;
6394 pos.width = 100;
6395 pos.height = 100;
6396 arl.gw = gw = GDrawCreateTopWindow(NULL,&pos,arl_e_h,&arl,&wattrs);
6397
6398 k = 0;
6399
6400 label[k].text = (unichar_t *) _("Script Tag:");
6401 label[k].text_is_1byte = true;
6402 gcd[k].gd.label = &label[k];
6403 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6404 gcd[k].gd.flags = gg_visible | gg_enabled;
6405 gcd[k++].creator = GLabelCreate;
6406 hvarray[0][0] = &gcd[k-1];
6407
6408 gcd[k].gd.u.list = ScriptListOfFont(sf);
6409 gcd[k].gd.flags = gg_visible | gg_enabled | gg_list_alphabetic;
6410 gcd[k].gd.cid = CID_ScriptTag;
6411 gcd[k].gd.handle_controlevent = ARL_TagChanged;
6412 gcd[k++].creator = GListFieldCreate;
6413 hvarray[0][1] = &gcd[k-1]; hvarray[0][2] = NULL;
6414
6415 label[k].text = (unichar_t *) _("Language Tag:");
6416 label[k].text_is_1byte = true;
6417 gcd[k].gd.label = &label[k];
6418 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6419 gcd[k].gd.flags = gg_visible | gg_enabled;
6420 gcd[k++].creator = GLabelCreate;
6421 hvarray[1][0] = &gcd[k-1];
6422
6423 gcd[k].gd.u.list = languages;
6424 gcd[k].gd.cid = CID_Langs;
6425 gcd[k].gd.flags = gg_visible | gg_enabled | gg_list_alphabetic;
6426 gcd[k].gd.handle_controlevent = ARL_TagChanged;
6427 gcd[k++].creator = GListFieldCreate;
6428 hvarray[1][1] = &gcd[k-1]; hvarray[1][2] = NULL;
6429
6430
6431 label[k].text = (unichar_t *) _("_OK");
6432 label[k].text_is_1byte = true;
6433 label[k].text_in_resource = true;
6434 gcd[k].gd.label = &label[k];
6435 gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_default;
6436 gcd[k].gd.handle_controlevent = ARL_OK;
6437 gcd[k++].creator = GButtonCreate;
6438
6439 label[k].text = (unichar_t *) _("_Cancel");
6440 label[k].text_is_1byte = true;
6441 label[k].text_in_resource = true;
6442 gcd[k].gd.label = &label[k];
6443 gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_cancel;
6444 gcd[k].gd.handle_controlevent = ARL_Cancel;
6445 gcd[k++].creator = GButtonCreate;
6446
6447 barray[0] = barray[2] = barray[3] = barray[4] = barray[6] = GCD_Glue; barray[7] = NULL;
6448 barray[1] = &gcd[k-2]; barray[5] = &gcd[k-1];
6449
6450 boxes[2].gd.flags = gg_enabled|gg_visible;
6451 boxes[2].gd.u.boxelements = barray;
6452 boxes[2].creator = GHBoxCreate;
6453
6454 hvarray[2][0] = &boxes[2]; hvarray[2][1] = GCD_ColSpan; hvarray[2][2] = NULL;
6455 hvarray[3][0] = NULL;
6456
6457 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
6458 boxes[0].gd.flags = gg_enabled|gg_visible;
6459 boxes[0].gd.u.boxelements = hvarray[0];
6460 boxes[0].creator = GHVGroupCreate;
6461
6462 GGadgetsCreate(gw,boxes);
6463
6464 memset(&dummy,0,sizeof(dummy));
6465 dummy.type = et_controlevent;
6466 dummy.u.control.subtype = et_textchanged;
6467 dummy.u.control.u.tf_changed.from_pulldown = GGadgetGetFirstListSelectedItem(gcd[1].ret);
6468 ARL_TagChanged(gcd[1].ret,&dummy);
6469
6470 GTextInfoListFree(gcd[1].gd.u.list);
6471
6472 GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame);
6473
6474 GHVBoxFitWindow(boxes[0].ret);
6475
6476 GDrawSetVisible(gw,true);
6477 while ( !arl.done )
6478 GDrawProcessOneEvent(NULL);
6479
6480 GDrawDestroyWindow(gw);
6481 }
6482
6483 /******************************************************************************/
6484 /**************************** Mass Glyph Rename ***************************/
6485 /******************************************************************************/
6486 typedef struct massrenamedlg {
6487 GWindow gw;
6488 int done;
6489 FontView *fv;
6490 } MassRenameDlg;
6491
6492 #undef CID_Suffix
6493 #define CID_SubTable 1001
6494 #define CID_Suffix 1002
6495 #define CID_StartName 1003
6496 #define CID_ReplaceSuffix 1004
6497 #define CID_Themselves 1005
6498
6499 static int MRD_OK(GGadget *g, GEvent *e) {
6500
6501 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
6502 MassRenameDlg *mrd = GDrawGetUserData(GGadgetGetWindow(g));
6503 int sel_cnt, enc, enc_max = mrd->fv->b.map->enccount;
6504 char *start_name, *suffix, *pt;
6505 int enc_start;
6506 SplineChar *sc, *sourcesc;
6507 GTextInfo *subti;
6508 struct lookup_subtable *sub;
6509 PST *pst;
6510 int themselves = GGadgetIsChecked(GWidgetGetControl(mrd->gw,CID_Themselves));
6511 int rplsuffix = GGadgetIsChecked(GWidgetGetControl(mrd->gw,CID_ReplaceSuffix));
6512
6513 for ( enc=sel_cnt=0; enc<enc_max; ++enc ) if ( mrd->fv->b.selected[enc] )
6514 ++sel_cnt;
6515 if ( !themselves ) {
6516 char *freeme = GGadgetGetTitle8(GWidgetGetControl(mrd->gw,CID_StartName));
6517 start_name = GlyphNameListDeUnicode(freeme);
6518 free(freeme);
6519 enc_start = SFFindSlot(mrd->fv->b.sf,mrd->fv->b.map,-1,start_name);
6520 if ( enc_start==-1 ) {
6521 ff_post_error(_("No Start Glyph"), _("The encoding does not contain something named %.40s"), start_name );
6522 free(start_name);
6523 return( true );
6524 }
6525 free( start_name );
6526 if ( enc_start+sel_cnt>=enc_max ) {
6527 ff_post_error(_("Not enough glyphs"), _("There aren't enough glyphs in the encoding to name all the selected characters"));
6528 return( true );
6529 }
6530 for ( enc=enc_start; enc<enc_start+sel_cnt; ++enc ) if ( mrd->fv->b.selected[enc]) {
6531 ff_post_error(_("Bad selection"), _("You may not rename any of the base glyphs, but your selection overlaps the set of base glyphs."));
6532 return( true );
6533 }
6534 } else
6535 enc_start = 0;
6536
6537 sub = NULL;
6538 subti = GGadgetGetListItemSelected(GWidgetGetControl(mrd->gw,CID_SubTable));
6539 if ( subti!=NULL )
6540 sub = subti->userdata;
6541 if ( sub==(struct lookup_subtable *)-1 )
6542 sub = NULL;
6543 if ( sub!=NULL && themselves ) {
6544 ff_post_error(_("Can't specify a subtable here"), _("As the selected glyphs are also source glyphs, they will be renamed, so they can't act as source glyphs for a lookup."));
6545 return( true );
6546 }
6547
6548 suffix = GGadgetGetTitle8(GWidgetGetControl(mrd->gw,CID_Suffix));
6549 if ( *suffix=='\0' || (*suffix=='.' && suffix[1]=='\0')) {
6550 ff_post_error(_("Missing suffix"), _("If you don't specify a suffix, the glyphs don't get renamed."));
6551 free(suffix);
6552 return( true );
6553 }
6554 if ( *suffix!='.' ) {
6555 char *old = suffix;
6556 suffix = strconcat(".",suffix);
6557 free(old);
6558 }
6559
6560 for ( enc=sel_cnt=0; enc<enc_max; ++enc ) if ( mrd->fv->b.selected[enc] ) {
6561 char *oldname;
6562 sourcesc = sc = SFMakeChar(mrd->fv->b.sf,mrd->fv->b.map,enc);
6563 if ( !themselves )
6564 sourcesc = SFMakeChar(mrd->fv->b.sf,mrd->fv->b.map,enc_start+sel_cnt);
6565 oldname = sc->name;
6566 if ( rplsuffix && (pt=strchr(sourcesc->name,'.'))!=NULL ) {
6567 char *name = malloc(pt-sourcesc->name+strlen(suffix)+2);
6568 strcpy(name,sourcesc->name);
6569 strcpy(name+(pt-sourcesc->name),suffix);
6570 sc->name = name;
6571 } else
6572 sc->name = strconcat(sourcesc->name,suffix);
6573 free(oldname);
6574 sc->unicodeenc = -1;
6575 if ( sub!=NULL ) {
6576 /* There can only be one single subs with this subtable */
6577 /* attached to the source glyph */
6578 for ( pst=sourcesc->possub; pst!=NULL && pst->subtable!=sub; pst=pst->next );
6579 if ( pst==NULL ) {
6580 pst = chunkalloc(sizeof(PST));
6581 pst->next = sourcesc->possub;
6582 sourcesc->possub = pst;
6583 pst->subtable = sub;
6584 pst->type = pst_substitution;
6585 }
6586 free(pst->u.subs.variant);
6587 pst->u.subs.variant = copy(sc->name);
6588 }
6589 ++sel_cnt;
6590 }
6591 free(suffix);
6592 mrd->done = true;
6593 }
6594 return( true );
6595 }
6596
6597 static int MRD_Cancel(GGadget *g, GEvent *e) {
6598
6599 if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
6600 MassRenameDlg *mrd = GDrawGetUserData(GGadgetGetWindow(g));
6601 mrd->done = true;
6602 }
6603 return( true );
6604 }
6605
6606 static int MRD_SuffixChange(GGadget *g, GEvent *e) {
6607
6608 if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) {
6609 MassRenameDlg *mrd = GDrawGetUserData(GGadgetGetWindow(g));
6610 char *suffix = GGadgetGetTitle8(g);
6611 int32_t len;
6612 int i;
6613 GTextInfo **ti = GGadgetGetList(GWidgetGetControl(mrd->gw,CID_SubTable),&len);
6614 struct lookup_subtable *sub;
6615
6616 for ( i=0; i<len; ++i ) {
6617 sub = ti[i]->userdata;
6618 if ( sub==NULL || sub==(struct lookup_subtable *) -1 )
6619 continue;
6620 if ( sub->suffix==NULL )
6621 continue;
6622 if ( strcmp(suffix,sub->suffix)==0 ) {
6623 GGadgetSelectOneListItem(GWidgetGetControl(mrd->gw,CID_SubTable),i);
6624 return( true );
6625 }
6626 }
6627 }
6628 return( true );
6629 }
6630
6631 static void MRD_SelectSubtable(MassRenameDlg *mrd,struct lookup_subtable *sub) {
6632 int32_t len;
6633 GTextInfo **ti = GGadgetGetList(GWidgetGetControl(mrd->gw,CID_SubTable),&len);
6634 int i, no_pos = -1;
6635
6636 for ( i=0; i<len; ++i ) if ( !ti[i]->line ) {
6637 if ( ti[i]->userdata == sub )
6638 break;
6639 else if ( ti[i]->userdata == (void *) -1 )
6640 no_pos = i;
6641 }
6642 if ( i==len )
6643 i = no_pos;
6644 if ( i!=-1 )
6645 GGadgetSelectOneListItem(GWidgetGetControl(mrd->gw,CID_SubTable),i);
6646 }
6647
6648 static int MRD_Subtable(GGadget *g, GEvent *e) {
6649 MassRenameDlg *mrd = GDrawGetUserData(GGadgetGetWindow(g));
6650 GTextInfo *ti;
6651 struct lookup_subtable *sub;
6652
6653 if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) {
6654 ti = GGadgetGetListItemSelected(g);
6655 if ( ti!=NULL ) {
6656 if ( ti->userdata==NULL ) {
6657 sub = SFNewLookupSubtableOfType(mrd->fv->b.sf,gsub_single,NULL,mrd->fv->b.active_layer);
6658 if ( sub!=NULL )
6659 GGadgetSetList(g,SFSubtablesOfType(mrd->fv->b.sf,gsub_single,false,true),false);
6660 MRD_SelectSubtable(mrd,sub);
6661 } else if ( (sub = ti->userdata) != (struct lookup_subtable *) -1 &&
6662 sub->suffix != NULL )
6663 GGadgetSetTitle8(GWidgetGetControl(mrd->gw,CID_Suffix),sub->suffix);
6664 }
6665 }
6666 return( true );
6667 }
6668
6669 static unichar_t **MRD_GlyphNameCompletion(GGadget *t,int from_tab) {
6670 MassRenameDlg *mrd = GDrawGetUserData(GGadgetGetWindow(t));
6671 SplineFont *sf = mrd->fv->b.sf;
6672
6673 return( SFGlyphNameCompletion(sf,t,from_tab,false));
6674 }
6675
6676 static int mrd_e_h(GWindow gw, GEvent *event) {
6677 MassRenameDlg *mrd = GDrawGetUserData(gw);
6678
6679 switch ( event->type ) {
6680 case et_char:
6681 return( false );
6682 case et_close:
6683 mrd->done = true;
6684 break;
6685 default: break;
6686 }
6687 return( true );
6688 }
6689
6690 void FVMassGlyphRename(FontView *fv) {
6691 GRect pos;
6692 GWindow gw;
6693 GWindowAttrs wattrs;
6694 MassRenameDlg mrd;
6695 GGadgetCreateData gcd[14], *hvarray[11][3], *barray[8], boxes[3];
6696 GTextInfo label[14];
6697 int i,k,subtablek, startnamek;
6698
6699 memset(&mrd,0,sizeof(mrd));
6700 mrd.fv = fv;
6701
6702 memset(&wattrs,0,sizeof(wattrs));
6703 memset(&gcd,0,sizeof(gcd));
6704 memset(&label,0,sizeof(label));
6705 memset(&boxes,0,sizeof(boxes));
6706
6707 wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
6708 wattrs.event_masks = ~(1<<et_charup);
6709 wattrs.restrict_input_to_me = true;
6710 wattrs.undercursor = 1;
6711 wattrs.cursor = ct_pointer;
6712 wattrs.utf8_window_title = _("Mass Glyph Rename");
6713 wattrs.is_dlg = true;
6714 pos.x = pos.y = 0;
6715 pos.width = 100;
6716 pos.height = 100;
6717 mrd.gw = gw = GDrawCreateTopWindow(NULL,&pos,mrd_e_h,&mrd,&wattrs);
6718
6719 k = i = 0;
6720
6721 label[k].text = (unichar_t *) _("Rename all glyphs in the selection");
6722 label[k].text_is_1byte = true;
6723 gcd[k].gd.label = &label[k];
6724 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6725 gcd[k].gd.flags = gg_visible | gg_enabled;
6726 gcd[k++].creator = GLabelCreate;
6727 hvarray[i][0] = &gcd[k-1]; hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL;
6728
6729 label[k].text = (unichar_t *) _("By appending the suffix:");
6730 label[k].text_is_1byte = true;
6731 gcd[k].gd.label = &label[k];
6732 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6733 gcd[k].gd.flags = gg_visible | gg_enabled;
6734 gcd[k++].creator = GLabelCreate;
6735 hvarray[i][0] = &gcd[k-1];
6736
6737 gcd[k].gd.flags = gg_visible | gg_enabled;
6738 gcd[k].gd.cid = CID_Suffix;
6739 gcd[k].gd.handle_controlevent = MRD_SuffixChange;
6740 gcd[k++].creator = GTextFieldCreate;
6741 hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL;
6742
6743 label[k].text = (unichar_t *) _("To their own names");
6744 label[k].text_is_1byte = true;
6745 gcd[k].gd.label = &label[k];
6746 gcd[k].gd.cid = CID_Themselves;
6747 gcd[k].gd.flags = gg_visible | gg_enabled | gg_cb_on;
6748 gcd[k++].creator = GRadioCreate;
6749 hvarray[i][0] = &gcd[k-1];
6750 hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL;
6751
6752 label[k].text = (unichar_t *) _("To the glyph names starting at:");
6753 label[k].text_is_1byte = true;
6754 gcd[k].gd.label = &label[k];
6755 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6756 gcd[k].gd.flags = gg_visible | gg_enabled;
6757 gcd[k].gd.popup_msg = _("So if you type \"A\" here the first selected glyph would be named \"A.suffix\".\nThe second \"B.suffix\", and so on.");
6758 gcd[k++].creator = GRadioCreate;
6759 hvarray[i][0] = &gcd[k-1];
6760
6761 startnamek = k;
6762 gcd[k].gd.flags = gg_visible | gg_enabled;
6763 gcd[k].gd.cid = CID_StartName;
6764 gcd[k].gd.popup_msg = _("So if you type \"A\" here the first selected glyph would be named \"A.suffix\".\nThe second \"B.suffix\", and so on.");
6765 gcd[k++].creator = GTextCompletionCreate;
6766 hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL;
6767
6768 label[k].text = (unichar_t *) _("If one of those glyphs already has a suffix");
6769 label[k].text_is_1byte = true;
6770 gcd[k].gd.label = &label[k];
6771 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6772 gcd[k].gd.flags = gg_visible | gg_enabled;
6773 gcd[k++].creator = GLabelCreate;
6774 hvarray[i][0] = &gcd[k-1]; hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL;
6775
6776 label[k].text = (unichar_t *) _("Append to it");
6777 label[k].text_is_1byte = true;
6778 gcd[k].gd.label = &label[k];
6779 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6780 gcd[k].gd.flags = gg_visible | gg_enabled;
6781 gcd[k++].creator = GRadioCreate;
6782 hvarray[i][0] = &gcd[k-1];
6783
6784 label[k].text = (unichar_t *) _("Replace it");
6785 label[k].text_is_1byte = true;
6786 gcd[k].gd.label = &label[k];
6787 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6788 gcd[k].gd.flags = gg_visible | gg_enabled | gg_cb_on;
6789 gcd[k].gd.cid = CID_ReplaceSuffix;
6790 gcd[k++].creator = GRadioCreate;
6791 hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL;
6792
6793 label[k].text = (unichar_t *) _("Optionally, add this mapping to the lookup subtable:");
6794 label[k].text_is_1byte = true;
6795 gcd[k].gd.label = &label[k];
6796 gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = 10;
6797 gcd[k].gd.flags = gg_visible | gg_enabled;
6798 gcd[k++].creator = GLabelCreate;
6799 hvarray[i][0] = &gcd[k-1]; hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL;
6800
6801 subtablek = k;
6802 gcd[k].gd.flags = gg_enabled|gg_visible;
6803 gcd[k].gd.cid = CID_SubTable;
6804 gcd[k].gd.handle_controlevent = MRD_Subtable;
6805 gcd[k++].creator = GListButtonCreate;
6806 hvarray[i][0] = GCD_Glue; hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL;
6807 hvarray[i][0] = hvarray[i][1] = GCD_Glue; hvarray[i++][2] = NULL;
6808
6809 label[k].text = (unichar_t *) _("_OK");
6810 label[k].text_is_1byte = true;
6811 label[k].text_in_resource = true;
6812 gcd[k].gd.label = &label[k];
6813 gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_default;
6814 gcd[k].gd.handle_controlevent = MRD_OK;
6815 gcd[k++].creator = GButtonCreate;
6816
6817 label[k].text = (unichar_t *) _("_Cancel");
6818 label[k].text_is_1byte = true;
6819 label[k].text_in_resource = true;
6820 gcd[k].gd.label = &label[k];
6821 gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_cancel;
6822 gcd[k].gd.handle_controlevent = MRD_Cancel;
6823 gcd[k++].creator = GButtonCreate;
6824
6825 barray[0] = barray[2] = barray[3] = barray[4] = barray[6] = GCD_Glue; barray[7] = NULL;
6826 barray[1] = &gcd[k-2]; barray[5] = &gcd[k-1];
6827 hvarray[i][0] = &boxes[2]; hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL;
6828 hvarray[i][0] = NULL;
6829
6830 boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
6831 boxes[0].gd.flags = gg_enabled|gg_visible;
6832 boxes[0].gd.u.boxelements = hvarray[0];
6833 boxes[0].creator = GHVGroupCreate;
6834
6835 boxes[2].gd.flags = gg_enabled|gg_visible;
6836 boxes[2].gd.u.boxelements = barray;
6837 boxes[2].creator = GHBoxCreate;
6838
6839 GGadgetsCreate(gw,boxes);
6840 GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame);
6841 GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue);
6842 GHVBoxSetExpandableCol(boxes[0].ret,1);
6843
6844 GGadgetSetList(gcd[subtablek].ret,SFSubtablesOfType(fv->b.sf,gsub_single,false,true),false);
6845 GGadgetSelectOneListItem(gcd[subtablek].ret,0);
6846 GCompletionFieldSetCompletion(gcd[startnamek].ret,MRD_GlyphNameCompletion);
6847 GWidgetIndicateFocusGadget(GWidgetGetControl(gw,CID_Suffix));
6848
6849 GHVBoxFitWindow(boxes[0].ret);
6850
6851 GDrawSetVisible(gw,true);
6852 while ( !mrd.done )
6853 GDrawProcessOneEvent(NULL);
6854
6855 GDrawDestroyWindow(gw);
6856 }
6857
6858 /* ************************************************************************** */
6859 /* ******************** Interface to FontInfo Lookup list ******************* */
6860 /* ************************************************************************** */
6861
6862 static void FI_SortInsertLookup(SplineFont *sf, OTLookup *newotl) {
6863 int isgpos = newotl->lookup_type>=gpos_start;
6864 int pos, i, k;
6865
6866 if ( sf->fontinfo ) {
6867 struct lkdata *lk = &sf->fontinfo->tables[isgpos];
6868 pos = FeatureOrderId(isgpos,newotl->features);
6869 if ( lk->cnt>=lk->max )
6870 lk->all = realloc(lk->all,(lk->max+=10)*sizeof(struct lkinfo));
6871 for ( i=0; i<lk->cnt && FeatureOrderId(isgpos,lk->all[i].lookup->features)<pos; ++i );
6872 for ( k=lk->cnt; k>i+1; --k )
6873 lk->all[k] = lk->all[k-1];
6874 memset(&lk->all[k],0,sizeof(struct lkinfo));
6875 lk->all[k].lookup = newotl;
6876 ++lk->cnt;
6877 GFI_LookupScrollbars(sf->fontinfo,isgpos, true);
6878 GFI_LookupEnableButtons(sf->fontinfo,isgpos);
6879 }
6880 }
6881
6882 /* Before may be:
6883 * A lookup in into_sf, in which case insert new lookup before it
6884 * NULL , in which case insert new lookup at end
6885 * -1 , in which case insert new lookup at start
6886 * -2 , try to guess a good position
6887 */
6888 static void FI_OrderNewLookup(SplineFont *into_sf,OTLookup *otl,OTLookup *before) {
6889 int isgpos = otl->lookup_type>=gpos_start;
6890 OTLookup **head = isgpos ? &into_sf->gpos_lookups : &into_sf->gsub_lookups;
6891 int i, k;
6892
6893 if ( into_sf->fontinfo ) {
6894 struct lkdata *lk = &into_sf->fontinfo->tables[isgpos];
6895
6896 if ( lk->cnt>=lk->max )
6897 lk->all = realloc(lk->all,(lk->max+=10)*sizeof(struct lkinfo));
6898
6899 if ( before == (OTLookup *) -2 )
6900 FI_SortInsertLookup(into_sf,otl);
6901 else {
6902 if ( before == (OTLookup *) -1 || *head==NULL || *head==before ) {
6903 i = 0;
6904 } else {
6905 for ( i=0; i<lk->cnt && lk->all[i].lookup!=before; ++i );
6906 }
6907 for ( k=lk->cnt; k>i; --k )
6908 lk->all[k] = lk->all[k-1];
6909 memset(&lk->all[i],0,sizeof(lk->all[i]));
6910 lk->all[i].lookup = otl;
6911 ++lk->cnt;
6912 GFI_LookupScrollbars(into_sf->fontinfo,isgpos, true);
6913 GFI_LookupEnableButtons(into_sf->fontinfo,isgpos);
6914 }
6915 }
6916 }
6917
6918 static void FI_OTLookupCopyInto(SplineFont *into_sf,SplineFont *from_sf,
6919 OTLookup *from_otl, OTLookup *to_otl, int scnt, OTLookup *before) {
6920 if ( into_sf->fontinfo ) {
6921 int isgpos = from_otl->lookup_type>=gpos_start;
6922 struct lkdata *lk = &into_sf->fontinfo->tables[isgpos];
6923 struct lookup_subtable *sub;
6924 int i;
6925 for ( i=0; i<lk->cnt; ++i )
6926 if ( lk->all[i].lookup==to_otl )
6927 break;
6928 if ( i==lk->cnt ) {
6929 FI_OrderNewLookup(into_sf,to_otl,before);
6930 for ( i=0; i<lk->cnt; ++i )
6931 if ( lk->all[i].lookup==to_otl )
6932 break;
6933 }
6934 lk->all[i].subtable_cnt = lk->all[i].subtable_max = scnt;
6935 lk->all[i].subtables = calloc(scnt,sizeof(struct lksubinfo));
6936 if ( scnt>0 )
6937 for ( sub=to_otl->subtables, scnt=0; sub!=NULL; sub=sub->next, ++scnt )
6938 lk->all[i].subtables[scnt].subtable = sub;
6939 }
6940 }
6941
6942 struct fi_interface gdraw_fi_interface = {
6943 FI_SortInsertLookup,
6944 FI_OTLookupCopyInto,
6945 FontInfoDestroy
6946 };