| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#include <fontforge-config.h> |
| 30 |
|
| 31 |
#include "fontforgeui.h" |
| 32 |
#include "fvfonts.h" |
| 33 |
#include "gfile.h" |
| 34 |
#include "gkeysym.h" |
| 35 |
#include "glyphcomp.h" |
| 36 |
#include "gresedit.h" |
| 37 |
#include "lookups.h" |
| 38 |
#include "splinefill.h" |
| 39 |
#include "splinesaveafm.h" |
| 40 |
#include "splineutil.h" |
| 41 |
#include "tottfaat.h" |
| 42 |
#include "tottfgpos.h" |
| 43 |
#include "ustring.h" |
| 44 |
#include "utype.h" |
| 45 |
|
| 46 |
#include "ttf.h" |
| 47 |
|
| 48 |
extern int _GScrollBar_Width; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
GResFont showatt_font = GRESFONT_INIT("400 12pt " SANS_UI_FAMILIES); |
| 54 |
GResFont showatt_monofont = GRESFONT_INIT("400 12pt " MONO_UI_FAMILIES); |
| 55 |
Color showatt_selcol = 0xff0000; |
| 56 |
Color showatt_glyphnamecol = 0x0000ff; |
| 57 |
|
| 58 |
struct att_dlg; |
| 59 |
struct node { |
| 60 |
unsigned int open: 1; |
| 61 |
unsigned int children_checked: 1; |
| 62 |
unsigned int used: 1; |
| 63 |
unsigned int macfeat: 1; |
| 64 |
unsigned int monospace: 1; |
| 65 |
unsigned int horizontal: 1; |
| 66 |
uint16_t cnt; |
| 67 |
struct node *children, *parent; |
| 68 |
void (*build)(struct node *,struct att_dlg *); |
| 69 |
char *label; |
| 70 |
uint32_t tag; |
| 71 |
union sak { |
| 72 |
SplineChar *sc; |
| 73 |
int index; |
| 74 |
OTLookup *otl; |
| 75 |
struct lookup_subtable *sub; |
| 76 |
struct baselangextent *langs; |
| 77 |
Justify *jscript; |
| 78 |
struct jstf_lang *jlang; |
| 79 |
OTLookup **otll; |
| 80 |
} u; |
| 81 |
int lpos; |
| 82 |
}; |
| 83 |
|
| 84 |
enum dlg_type { dt_show_att, dt_font_comp }; |
| 85 |
|
| 86 |
struct att_dlg { |
| 87 |
unsigned int done: 1; |
| 88 |
struct node *tables; |
| 89 |
int open_cnt, lines_page, off_top, off_left, page_width, bmargin; |
| 90 |
int maxl; |
| 91 |
SplineFont *sf; |
| 92 |
int def_layer; |
| 93 |
GWindow gw,v; |
| 94 |
GGadget *vsb, *hsb, *cancel; |
| 95 |
int fh, as; |
| 96 |
GFont *font, *monofont; |
| 97 |
struct node *current; |
| 98 |
enum dlg_type dlg_type; |
| 99 |
FontView *fv1, *fv2; |
| 100 |
struct node *popup_node; |
| 101 |
}; |
| 102 |
|
| 103 |
static void BuildGSUBlookups(struct node *node,struct att_dlg *att); |
| 104 |
|
| 105 |
static void nodesfree(struct node *node) { |
| 106 |
int i; |
| 107 |
|
| 108 |
if ( node==NULL ) |
| 109 |
return; |
| 110 |
for ( i=0; node[i].label!=NULL; ++i ) { |
| 111 |
nodesfree(node[i].children); |
| 112 |
free(node[i].label); |
| 113 |
} |
| 114 |
free(node); |
| 115 |
} |
| 116 |
|
| 117 |
static int node_alphabetize(const void *_n1, const void *_n2) { |
| 118 |
const struct node *n1 = _n1, *n2 = _n2; |
| 119 |
int ret; |
| 120 |
|
| 121 |
ret = strcasecmp(n1->label,n2->label); |
| 122 |
if ( ret!=0 ) |
| 123 |
return( ret ); |
| 124 |
|
| 125 |
return( strcmp(n1->label,n2->label)); |
| 126 |
} |
| 127 |
|
| 128 |
static void BuildMarkedLigatures(struct node *node,struct att_dlg *att) { |
| 129 |
SplineChar *sc = node->u.sc; |
| 130 |
struct lookup_subtable *sub = node->parent->parent->u.sub; |
| 131 |
AnchorClass *ac; |
| 132 |
int classcnt, j, max, k; |
| 133 |
AnchorPoint *ap; |
| 134 |
char buf[90]; |
| 135 |
SplineFont *sf = att->sf; |
| 136 |
|
| 137 |
if ( sf->cidmaster!=NULL ) sf = sf->cidmaster; |
| 138 |
|
| 139 |
classcnt = 0; |
| 140 |
for ( ap=sc->anchor; ap!=NULL; ap=ap->next ) |
| 141 |
if ( ap->anchor->subtable == sub ) |
| 142 |
++classcnt; |
| 143 |
max=0; |
| 144 |
for ( ap=sc->anchor; ap!=NULL ; ap=ap->next ) |
| 145 |
if ( ap->lig_index>max ) |
| 146 |
max = ap->lig_index; |
| 147 |
node->children = calloc(classcnt+1,sizeof(struct node)); |
| 148 |
for ( k=j=0; k<=max; ++k ) { |
| 149 |
for ( ac=sf->anchor; ac!=NULL; ac=ac->next ) if ( ac->subtable==sub ) { |
| 150 |
for ( ap=sc->anchor; ap!=NULL && (ap->type!=at_baselig || ap->anchor!=ac || ap->lig_index!=k); ap=ap->next ); |
| 151 |
if ( ap!=NULL ) { |
| 152 |
sprintf(buf,_("Component %d %.30s (%d,%d)"), |
| 153 |
k, ac->name, (int) ap->me.x, (int) ap->me.y ); |
| 154 |
node->children[j].label = copy(buf); |
| 155 |
node->children[j++].parent = node; |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
node->cnt = j; |
| 160 |
} |
| 161 |
|
| 162 |
static void BuildMarkedChars(struct node *node,struct att_dlg *att) { |
| 163 |
SplineChar *sc = node->u.sc; |
| 164 |
struct lookup_subtable *sub = node->parent->parent->u.sub; |
| 165 |
AnchorClass *ac; |
| 166 |
int classcnt, j; |
| 167 |
AnchorPoint *ap; |
| 168 |
char buf[80]; |
| 169 |
SplineFont *sf = att->sf; |
| 170 |
|
| 171 |
if ( sf->cidmaster!=NULL ) sf = sf->cidmaster; |
| 172 |
|
| 173 |
classcnt = 0; |
| 174 |
for ( ap=sc->anchor; ap!=NULL; ap=ap->next ) |
| 175 |
if ( ap->anchor->subtable == sub ) |
| 176 |
++classcnt; |
| 177 |
node->children = calloc(classcnt+1,sizeof(struct node)); |
| 178 |
for ( j=0, ac=sf->anchor; ac!=NULL; ac=ac->next ) if ( ac->subtable==sub ) { |
| 179 |
for ( ap=sc->anchor; ap!=NULL && (!(ap->type==at_basechar || ap->type==at_basemark) || ap->anchor!=ac); ap=ap->next ); |
| 180 |
if ( ap!=NULL ) { |
| 181 |
sprintf(buf,"%.30s (%d,%d)", ac->name, |
| 182 |
(int) ap->me.x, (int) ap->me.y ); |
| 183 |
node->children[j].label = copy(buf); |
| 184 |
node->children[j++].parent = node; |
| 185 |
} |
| 186 |
} |
| 187 |
qsort(node->children,j,sizeof(struct node), node_alphabetize); |
| 188 |
node->cnt = j; |
| 189 |
} |
| 190 |
|
| 191 |
static void BuildBase(struct node *node,SplineChar **bases,enum anchor_type at, struct node *parent) { |
| 192 |
int i; |
| 193 |
|
| 194 |
node->parent = parent; |
| 195 |
node->label = copy(at==at_basechar?_("Base Glyphs"): |
| 196 |
at==at_baselig?_("Base Ligatures"): |
| 197 |
_("Base Marks")); |
| 198 |
for ( i=0; bases[i]!=NULL; ++i ); |
| 199 |
if ( i==0 ) { |
| 200 |
node->cnt = 1; |
| 201 |
node->children = calloc(2,sizeof(struct node)); |
| 202 |
node->children[0].label = copy(_("Empty")); |
| 203 |
node->children[0].parent = node; |
| 204 |
} else { |
| 205 |
node->cnt = i; |
| 206 |
node->children = calloc(i+1,sizeof(struct node)); |
| 207 |
for ( i=0; bases[i]!=NULL; ++i ) { |
| 208 |
node->children[i].label = copy(bases[i]->name); |
| 209 |
node->children[i].parent = node; |
| 210 |
node->children[i].u.sc = bases[i]; |
| 211 |
node->children[i].build = at==at_baselig?BuildMarkedLigatures:BuildMarkedChars; |
| 212 |
} |
| 213 |
qsort(node->children,node->cnt,sizeof(struct node), node_alphabetize); |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
static void BuildMark(struct node *node,SplineChar **marks,AnchorClass *ac, struct node *parent) { |
| 218 |
int i; |
| 219 |
char buf[80]; |
| 220 |
AnchorPoint *ap; |
| 221 |
|
| 222 |
node->parent = parent; |
| 223 |
sprintf(buf,_("Mark Class %.20s"),ac->name); |
| 224 |
node->label = copy(buf); |
| 225 |
for ( i=0; marks[i]!=NULL; ++i ); |
| 226 |
if ( i==0 ) { |
| 227 |
node->cnt = 1; |
| 228 |
node->children = calloc(2,sizeof(struct node)); |
| 229 |
node->children[0].label = copy(_("Empty")); |
| 230 |
node->children[0].parent = node; |
| 231 |
} else { |
| 232 |
node->cnt = i; |
| 233 |
node->children = calloc(i+1,sizeof(struct node)); |
| 234 |
for ( i=0; marks[i]!=NULL; ++i ) { |
| 235 |
for ( ap=marks[i]->anchor; ap!=NULL && (ap->type!=at_mark || ap->anchor!=ac); ap=ap->next ); |
| 236 |
sprintf(buf,_("%.30s (%d,%d)"), marks[i]->name, |
| 237 |
(int) ap->me.x, (int) ap->me.y ); |
| 238 |
node->children[i].label = copy(buf); |
| 239 |
node->children[i].parent = node; |
| 240 |
} |
| 241 |
qsort(node->children,node->cnt,sizeof(struct node), node_alphabetize); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
static void BuildAnchorLists(struct node *node,struct att_dlg *att) { |
| 246 |
struct lookup_subtable *sub = node->u.sub; |
| 247 |
AnchorClass *ac, *ac2; |
| 248 |
int cnt, i, j, classcnt; |
| 249 |
AnchorPoint *ap, *ent, *ext; |
| 250 |
SplineChar **base, **lig, **mkmk, **entryexit; |
| 251 |
SplineChar ***marks; |
| 252 |
int *subcnts; |
| 253 |
SplineFont *sf = att->sf; |
| 254 |
char buf[80]; |
| 255 |
|
| 256 |
if ( sf->cidmaster!=NULL ) sf = sf->cidmaster; |
| 257 |
|
| 258 |
if ( sub->lookup->lookup_type==gpos_cursive ) { |
| 259 |
for ( ac = sf->anchor; ac!=NULL && ac->subtable!=sub; ac = ac->next ); |
| 260 |
entryexit = ac==NULL ? NULL : EntryExitDecompose(sf,ac,NULL); |
| 261 |
if ( entryexit==NULL ) { |
| 262 |
node->children = calloc(2,sizeof(struct node)); |
| 263 |
node->cnt = 1; |
| 264 |
node->children[0].label = copy(_("Empty")); |
| 265 |
node->children[0].parent = node; |
| 266 |
} else { |
| 267 |
for ( cnt=0; entryexit[cnt]!=NULL; ++cnt ); |
| 268 |
node->children = calloc(cnt+1,sizeof(struct node)); |
| 269 |
node->cnt = cnt; |
| 270 |
for ( cnt=0; entryexit[cnt]!=NULL; ++cnt ) { |
| 271 |
node->children[cnt].u.sc = entryexit[cnt]; |
| 272 |
node->children[cnt].label = copy(entryexit[cnt]->name); |
| 273 |
node->children[cnt].parent = node; |
| 274 |
} |
| 275 |
qsort(node->children,node->cnt,sizeof(struct node), node_alphabetize); |
| 276 |
for ( cnt=0; entryexit[cnt]!=NULL; ++cnt ) { |
| 277 |
for ( ent=ext=NULL, ap = node->children[cnt].u.sc->anchor; ap!=NULL; ap=ap->next ) { |
| 278 |
if ( ap->anchor==ac ) { |
| 279 |
if ( ap->type == at_centry ) |
| 280 |
ent = ap; |
| 281 |
else if ( ap->type == at_cexit ) |
| 282 |
ent = ap; |
| 283 |
} |
| 284 |
} |
| 285 |
node->children[cnt].cnt = (ent!=NULL)+(ext!=NULL); |
| 286 |
node->children[cnt].children = calloc((1+(ent!=NULL)+(ext!=NULL)),sizeof(struct node)); |
| 287 |
i = 0; |
| 288 |
if ( ent!=NULL ) { |
| 289 |
snprintf(buf,sizeof(buf), _("Entry (%d,%d)"), |
| 290 |
(int) ent->me.x, (int) ent->me.y); |
| 291 |
node->children[cnt].children[i].label = copy(buf); |
| 292 |
node->children[cnt].children[i].parent = &node->children[cnt]; |
| 293 |
++i; |
| 294 |
} |
| 295 |
if ( ext!=NULL ) { |
| 296 |
snprintf(buf,sizeof(buf), _("Exit (%d,%d)"), |
| 297 |
(int) ext->me.x, (int) ext->me.y); |
| 298 |
node->children[cnt].children[i].label = copy(buf); |
| 299 |
node->children[cnt].children[i].parent = &node->children[cnt]; |
| 300 |
++i; |
| 301 |
} |
| 302 |
} |
| 303 |
} |
| 304 |
free(entryexit); |
| 305 |
} else { |
| 306 |
classcnt = 0; |
| 307 |
ac = NULL; |
| 308 |
for ( ac2=sf->anchor; ac2!=NULL; ac2=ac2->next ) { |
| 309 |
if ( ac2->subtable == sub ) { |
| 310 |
if ( ac==NULL ) ac=ac2; |
| 311 |
ac2->matches = true; |
| 312 |
++classcnt; |
| 313 |
} else |
| 314 |
ac2->matches = false; |
| 315 |
} |
| 316 |
if ( classcnt==0 ) |
| 317 |
return; |
| 318 |
|
| 319 |
marks = malloc(classcnt*sizeof(SplineChar **)); |
| 320 |
subcnts = malloc(classcnt*sizeof(int)); |
| 321 |
AnchorClassDecompose(sf,ac,classcnt,subcnts,marks,&base,&lig,&mkmk,NULL); |
| 322 |
node->cnt = classcnt+(base!=NULL)+(lig!=NULL)+(mkmk!=NULL); |
| 323 |
node->children = calloc(node->cnt+1,sizeof(struct node)); |
| 324 |
i=0; |
| 325 |
if ( base!=NULL ) |
| 326 |
BuildBase(&node->children[i++],base,at_basechar,node); |
| 327 |
if ( lig!=NULL ) |
| 328 |
BuildBase(&node->children[i++],lig,at_baselig,node); |
| 329 |
if ( mkmk!=NULL ) |
| 330 |
BuildBase(&node->children[i++],mkmk,at_basemark,node); |
| 331 |
for ( j=0, ac2=ac; j<classcnt; ac2=ac2->next ) if ( ac2->matches ) { |
| 332 |
if ( marks[j]!=NULL ) |
| 333 |
BuildMark(&node->children[i++],marks[j],ac2,node); |
| 334 |
++j; |
| 335 |
} |
| 336 |
node->cnt = i; |
| 337 |
for ( i=0; i<classcnt; ++i ) |
| 338 |
free(marks[i]); |
| 339 |
free(marks); |
| 340 |
free(subcnts); |
| 341 |
free(base); |
| 342 |
free(lig); |
| 343 |
free(mkmk); |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
static void BuildKC2(struct node *node,struct att_dlg *att) { |
| 348 |
KernClass *kc = node->parent->u.sub->kc; |
| 349 |
struct node *seconds; |
| 350 |
int index=node->u.index,i,cnt, len; |
| 351 |
char buf[32]; |
| 352 |
char *name; |
| 353 |
|
| 354 |
for ( i=1,cnt=0; i<kc->second_cnt; ++i ) |
| 355 |
if ( kc->offsets[index*kc->second_cnt+i]!=0 && strlen(kc->seconds[i])!=0 ) |
| 356 |
++cnt; |
| 357 |
|
| 358 |
node->children = seconds = calloc(cnt+1,sizeof(struct node)); |
| 359 |
node->cnt = cnt; |
| 360 |
cnt = 0; |
| 361 |
for ( i=1; i<kc->second_cnt; ++i ) if ( kc->offsets[index*kc->second_cnt+i]!=0 && strlen(kc->seconds[i])!=0 ) { |
| 362 |
sprintf( buf, "%d ", kc->offsets[index*kc->second_cnt+i]); |
| 363 |
len = strlen(buf)+strlen(kc->seconds[i])+1; |
| 364 |
name = malloc(len); |
| 365 |
strcpy(name,buf); |
| 366 |
strcat(name,kc->seconds[i]); |
| 367 |
seconds[cnt].label = name; |
| 368 |
seconds[cnt].parent = node; |
| 369 |
seconds[cnt].build = NULL; |
| 370 |
seconds[cnt++].u.index = i; |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
static void BuildKC(struct node *node,struct att_dlg *att) { |
| 375 |
KernClass *kc = node->u.sub->kc; |
| 376 |
struct node *firsts; |
| 377 |
int i,j,cnt,cnt2; |
| 378 |
|
| 379 |
for ( i=1,cnt=0; i<kc->first_cnt; ++i ) { |
| 380 |
for ( j=1,cnt2=0 ; j<kc->second_cnt; ++j ) { |
| 381 |
if ( kc->offsets[i*kc->second_cnt+j]!=0 ) |
| 382 |
++cnt2; |
| 383 |
} |
| 384 |
if ( cnt2 && strlen(kc->firsts[i])>0 ) |
| 385 |
++cnt; |
| 386 |
} |
| 387 |
|
| 388 |
node->children = firsts = calloc(cnt+1,sizeof(struct node)); |
| 389 |
node->cnt = cnt; |
| 390 |
for ( i=1,cnt=0; i<kc->first_cnt; ++i ) { |
| 391 |
for ( j=1,cnt2=0 ; j<kc->second_cnt; ++j ) { |
| 392 |
if ( kc->offsets[i*kc->second_cnt+j]!=0 ) |
| 393 |
++cnt2; |
| 394 |
} |
| 395 |
if ( cnt2==0 || strlen(kc->firsts[i])==0 ) |
| 396 |
continue; |
| 397 |
firsts[cnt].label = copy(kc->firsts[i]); |
| 398 |
firsts[cnt].parent = node; |
| 399 |
firsts[cnt].build = BuildKC2; |
| 400 |
firsts[cnt++].u.index = i; |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
static int PSTAllComponentsExist(SplineFont *sf,char *glyphnames ) { |
| 405 |
char *start, *end, ch; |
| 406 |
int ret; |
| 407 |
|
| 408 |
if ( glyphnames==NULL ) |
| 409 |
return( false ); |
| 410 |
for ( start=glyphnames; *start; start = end ) { |
| 411 |
while ( *start==' ' ) ++start; |
| 412 |
for ( end = start; *end!=' ' && *end!='\0'; ++end ); |
| 413 |
if ( end==start ) |
| 414 |
break; |
| 415 |
ch = *end; *end = '\0'; |
| 416 |
ret = SCWorthOutputting(SFGetChar(sf,-1,start)); |
| 417 |
*end = ch; |
| 418 |
if ( !ret ) |
| 419 |
return( false ); |
| 420 |
} |
| 421 |
return( true ); |
| 422 |
} |
| 423 |
|
| 424 |
static void BuildFPSTRule(struct node *node,struct att_dlg *att) { |
| 425 |
FPST *fpst = node->parent->u.sub->fpst; |
| 426 |
int index = node->u.index; |
| 427 |
struct fpst_rule *r = &fpst->rules[index]; |
| 428 |
int len, i, j; |
| 429 |
struct node *lines; |
| 430 |
char buf[200], *pt, *start, *spt; |
| 431 |
char *upt; |
| 432 |
GrowBuf gb; |
| 433 |
|
| 434 |
memset(&gb,0,sizeof(gb)); |
| 435 |
|
| 436 |
for ( i=0; i<2; ++i ) { |
| 437 |
len = 0; |
| 438 |
|
| 439 |
switch ( fpst->format ) { |
| 440 |
case pst_glyphs: |
| 441 |
if ( r->u.glyph.back!=NULL && *r->u.glyph.back!='\0' ) { |
| 442 |
if ( i ) { |
| 443 |
strcpy(buf, _("Backtrack Match: ") ); |
| 444 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.glyph.back)+1)); |
| 445 |
strcpy(lines[len].label,buf); |
| 446 |
upt = lines[len].label+strlen(lines[len].label); |
| 447 |
for ( pt=r->u.glyph.back+strlen(r->u.glyph.back); pt>r->u.glyph.back; pt=start ) { |
| 448 |
for ( start = pt-1; start>=r->u.glyph.back&& *start!=' '; --start ); |
| 449 |
for ( spt=start+1; spt<pt; ) |
| 450 |
*upt++ = *spt++; |
| 451 |
*upt++ = ' '; |
| 452 |
} |
| 453 |
upt[-1] = '\0'; |
| 454 |
lines[len].parent = node; |
| 455 |
} |
| 456 |
++len; |
| 457 |
} |
| 458 |
if ( i ) { |
| 459 |
strcpy(buf, _("Match: ") ); |
| 460 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.glyph.names)+1)); |
| 461 |
strcpy(lines[len].label,buf); |
| 462 |
strcat(lines[len].label,r->u.glyph.names); |
| 463 |
lines[len].parent = node; |
| 464 |
} |
| 465 |
++len; |
| 466 |
if ( r->u.glyph.fore!=NULL && *r->u.glyph.fore!='\0' ) { |
| 467 |
if ( i ) { |
| 468 |
strcpy(buf, _("Lookahead Match: ") ); |
| 469 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.glyph.fore)+1)); |
| 470 |
strcpy(lines[len].label,buf); |
| 471 |
strcat(lines[len].label,r->u.glyph.fore); |
| 472 |
lines[len].parent = node; |
| 473 |
} |
| 474 |
++len; |
| 475 |
} |
| 476 |
break; |
| 477 |
case pst_class: |
| 478 |
if ( r->u.fpc_class.bcnt!=0 ) { |
| 479 |
if ( i ) { |
| 480 |
gb.pt = gb.base; |
| 481 |
GrowBufferAddStr(&gb,P_("Backtrack class: ","Backtrack classes: ",r->u.fpc_class.bcnt)); |
| 482 |
for ( j=r->u.fpc_class.bcnt-1; j>=0; --j ) { |
| 483 |
if ( fpst->bclassnames==NULL || fpst->bclassnames[r->u.fpc_class.bclasses[j]]==NULL ) { |
| 484 |
sprintf( buf, "%d ", r->u.fpc_class.bclasses[j] ); |
| 485 |
GrowBufferAddStr(&gb,buf); |
| 486 |
} else |
| 487 |
GrowBufferAddStr(&gb,fpst->bclassnames[r->u.fpc_class.bclasses[j]]); |
| 488 |
} |
| 489 |
lines[len].label = copy((char*)gb.base); |
| 490 |
lines[len].parent = node; |
| 491 |
} |
| 492 |
++len; |
| 493 |
} |
| 494 |
if ( i ) { |
| 495 |
gb.pt = gb.base; |
| 496 |
GrowBufferAddStr(&gb, P_("Class","Classes",r->u.fpc_class.ncnt)); |
| 497 |
for ( j=0; j<r->u.fpc_class.ncnt; ++j ) { |
| 498 |
if ( fpst->nclassnames==NULL || fpst->nclassnames[r->u.fpc_class.nclasses[j]]==NULL ) { |
| 499 |
sprintf( buf, "%d ", r->u.fpc_class.nclasses[j] ); |
| 500 |
GrowBufferAddStr(&gb,buf); |
| 501 |
} else |
| 502 |
GrowBufferAddStr(&gb,fpst->nclassnames[r->u.fpc_class.nclasses[j]]); |
| 503 |
} |
| 504 |
lines[len].label = copy((char*)gb.base); |
| 505 |
lines[len].parent = node; |
| 506 |
} |
| 507 |
++len; |
| 508 |
if ( r->u.fpc_class.fcnt!=0 ) { |
| 509 |
if ( i ) { |
| 510 |
gb.pt = gb.base; |
| 511 |
GrowBufferAddStr(&gb, P_("Lookahead Class","Lookahead Classes",r->u.fpc_class.fcnt)); |
| 512 |
for ( j=0; j<r->u.fpc_class.fcnt; ++j ) { |
| 513 |
if ( fpst->fclassnames==NULL || fpst->fclassnames[r->u.fpc_class.fclasses[j]]==NULL ) { |
| 514 |
sprintf( buf, "%d ", r->u.fpc_class.fclasses[j] ); |
| 515 |
GrowBufferAddStr(&gb,buf); |
| 516 |
} else |
| 517 |
GrowBufferAddStr(&gb,fpst->fclassnames[r->u.fpc_class.fclasses[j]]); |
| 518 |
} |
| 519 |
lines[len].label = copy((char*)gb.base); |
| 520 |
lines[len].parent = node; |
| 521 |
} |
| 522 |
++len; |
| 523 |
} |
| 524 |
break; |
| 525 |
case pst_coverage: |
| 526 |
case pst_reversecoverage: |
| 527 |
for ( j=r->u.coverage.bcnt-1; j>=0; --j ) { |
| 528 |
if ( i ) { |
| 529 |
sprintf(buf, _("Back coverage %d: "), -j-1); |
| 530 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.coverage.bcovers[j])+1)); |
| 531 |
strcpy(lines[len].label,buf); |
| 532 |
strcat(lines[len].label,r->u.coverage.bcovers[j]); |
| 533 |
lines[len].parent = node; |
| 534 |
} |
| 535 |
++len; |
| 536 |
} |
| 537 |
for ( j=0; j<r->u.coverage.ncnt; ++j ) { |
| 538 |
if ( i ) { |
| 539 |
sprintf(buf, _("Coverage %d: "), j); |
| 540 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.coverage.ncovers[j])+1)); |
| 541 |
strcpy(lines[len].label,buf); |
| 542 |
strcat(lines[len].label,r->u.coverage.ncovers[j]); |
| 543 |
lines[len].parent = node; |
| 544 |
} |
| 545 |
++len; |
| 546 |
} |
| 547 |
for ( j=0; j<r->u.coverage.fcnt; ++j ) { |
| 548 |
if ( i ) { |
| 549 |
sprintf(buf, _("Lookahead coverage %d: "), j+r->u.coverage.ncnt); |
| 550 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.coverage.fcovers[j])+1)); |
| 551 |
strcpy(lines[len].label,buf); |
| 552 |
strcat(lines[len].label,r->u.coverage.fcovers[j]); |
| 553 |
lines[len].parent = node; |
| 554 |
} |
| 555 |
++len; |
| 556 |
} |
| 557 |
break; |
| 558 |
} |
| 559 |
switch ( fpst->format ) { |
| 560 |
case pst_glyphs: |
| 561 |
case pst_class: |
| 562 |
case pst_coverage: |
| 563 |
for ( j=0; j<r->lookup_cnt; ++j ) { |
| 564 |
if ( i ) { |
| 565 |
sprintf(buf, _("Apply at %d %.80s"), r->lookups[j].seq, |
| 566 |
r->lookups[j].lookup->lookup_name ); |
| 567 |
lines[len].label = copy(buf); |
| 568 |
lines[len].parent = node; |
| 569 |
lines[len].u.otl = r->lookups[j].lookup; |
| 570 |
lines[len].build = BuildGSUBlookups; |
| 571 |
} |
| 572 |
++len; |
| 573 |
} |
| 574 |
break; |
| 575 |
case pst_reversecoverage: |
| 576 |
if ( i ) { |
| 577 |
strcpy(buf, _("Replacement: ") ); |
| 578 |
lines[len].label = malloc((strlen(buf)+strlen(r->u.rcoverage.replacements)+1)); |
| 579 |
strcpy(lines[len].label,buf); |
| 580 |
strcat(lines[len].label,r->u.rcoverage.replacements); |
| 581 |
lines[len].parent = node; |
| 582 |
} |
| 583 |
++len; |
| 584 |
break; |
| 585 |
} |
| 586 |
if ( i==0 ) { |
| 587 |
node->children = lines = calloc(len+1,sizeof(struct node)); |
| 588 |
node->cnt = len; |
| 589 |
} |
| 590 |
} |
| 591 |
free(gb.base); |
| 592 |
} |
| 593 |
|
| 594 |
static void BuildFPST(struct node *node,struct att_dlg *att) { |
| 595 |
FPST *fpst = node->u.sub->fpst; |
| 596 |
int len, i, j; |
| 597 |
struct node *lines; |
| 598 |
char buf[200]; |
| 599 |
static char *type[] = { N_("Contextual Positioning"), N_("Contextual Substitution"), |
| 600 |
N_("Chaining Positioning"), N_("Chaining Substitution"), |
| 601 |
N_("Reverse Chaining Subs") }; |
| 602 |
static char *format[] = { N_("glyphs"), N_("classes"), N_("coverage"), N_("coverage") }; |
| 603 |
|
| 604 |
lines = NULL; |
| 605 |
for ( i=0; i<2; ++i ) { |
| 606 |
len = 0; |
| 607 |
|
| 608 |
if ( i ) { |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
sprintf(buf, _("%s by %s"), _(type[fpst->type-pst_contextpos]), |
| 616 |
_(format[fpst->format])); |
| 617 |
lines[len].label = copy(buf); |
| 618 |
lines[len].parent = node; |
| 619 |
} |
| 620 |
++len; |
| 621 |
if ( fpst->format==pst_class ) { |
| 622 |
for ( j=1; j<fpst->bccnt ; ++j ) { |
| 623 |
if ( i ) { |
| 624 |
sprintf(buf, _("Backtrack class %d: "), j); |
| 625 |
lines[len].label = malloc((strlen(buf)+strlen(fpst->bclass[j])+1)); |
| 626 |
strcpy(lines[len].label,buf); |
| 627 |
strcat(lines[len].label,fpst->bclass[j]); |
| 628 |
lines[len].parent = node; |
| 629 |
} |
| 630 |
++len; |
| 631 |
} |
| 632 |
for ( j=1; j<fpst->nccnt ; ++j ) { |
| 633 |
if ( i ) { |
| 634 |
sprintf(buf, _("Class %d: "), j); |
| 635 |
lines[len].label = malloc((strlen(buf)+strlen(fpst->nclass[j])+1)); |
| 636 |
strcpy(lines[len].label,buf); |
| 637 |
strcat(lines[len].label,fpst->nclass[j]); |
| 638 |
lines[len].parent = node; |
| 639 |
} |
| 640 |
++len; |
| 641 |
} |
| 642 |
for ( j=1; j<fpst->fccnt ; ++j ) { |
| 643 |
if ( i ) { |
| 644 |
sprintf(buf, _("Lookahead class %d: "), j); |
| 645 |
lines[len].label = malloc((strlen(buf)+strlen(fpst->fclass[j])+1)); |
| 646 |
strcpy(lines[len].label,buf); |
| 647 |
strcat(lines[len].label,fpst->fclass[j]); |
| 648 |
lines[len].parent = node; |
| 649 |
} |
| 650 |
++len; |
| 651 |
} |
| 652 |
} |
| 653 |
for ( j=0; j<fpst->rule_cnt; ++j ) { |
| 654 |
if ( i ) { |
| 655 |
sprintf(buf, _("Rule %d"), j); |
| 656 |
lines[len].label = copy(buf); |
| 657 |
lines[len].parent = node; |
| 658 |
lines[len].u.index = j; |
| 659 |
lines[len].build = BuildFPSTRule; |
| 660 |
} |
| 661 |
++len; |
| 662 |
} |
| 663 |
if ( i==0 ) { |
| 664 |
node->children = lines = calloc(len+1,sizeof(struct node)); |
| 665 |
node->cnt = len; |
| 666 |
} |
| 667 |
} |
| 668 |
} |
| 669 |
|
| 670 |
static void BuildASM(struct node *node,struct att_dlg *att) { |
| 671 |
ASM *sm = node->u.sub->sm; |
| 672 |
int len, i, j, k, scnt = 0; |
| 673 |
struct node *lines; |
| 674 |
char buf[200], *space; |
| 675 |
static char *type[] = { N_("Indic Reordering"), N_("Contextual Substitution"), |
| 676 |
N_("Ligatures"), N_("<undefined>"), N_("Simple Substitution"), |
| 677 |
N_("Glyph Insertion"), N_("<undefined>"), N_("<undefined>"), N_("<undefined>"), |
| 678 |
N_("<undefined>"), N_("<undefined>"), N_("<undefined>"),N_("<undefined>"), |
| 679 |
N_("<undefined>"), N_("<undefined>"), N_("<undefined>"), N_("<undefined>"), |
| 680 |
N_("Kern by State") }; |
| 681 |
OTLookup **used; |
| 682 |
|
| 683 |
if ( sm->type == asm_context ) { |
| 684 |
used = malloc(sm->class_cnt*sm->state_cnt*2*sizeof(OTLookup *)); |
| 685 |
for ( i=scnt=0; i<sm->class_cnt*sm->state_cnt; ++i ) { |
| 686 |
OTLookup *otl; |
| 687 |
otl = sm->state[i].u.context.mark_lookup; |
| 688 |
if ( otl!=NULL ) { |
| 689 |
for ( k=0; k<scnt && used[k]!=otl; ++k ); |
| 690 |
if ( k==scnt ) used[scnt++] = otl; |
| 691 |
} |
| 692 |
otl = sm->state[i].u.context.cur_lookup; |
| 693 |
if ( otl!=NULL ) { |
| 694 |
for ( k=0; k<scnt && used[k]!=otl; ++k ); |
| 695 |
if ( k==scnt ) used[scnt++] = otl; |
| 696 |
} |
| 697 |
} |
| 698 |
} |
| 699 |
|
| 700 |
lines = NULL; |
| 701 |
space = malloc( 81*sm->class_cnt+40 ); |
| 702 |
for ( i=0; i<2; ++i ) { |
| 703 |
len = 0; |
| 704 |
|
| 705 |
if ( i ) { |
| 706 |
lines[len].label = copy(_(type[sm->type])); |
| 707 |
lines[len].parent = node; |
| 708 |
} |
| 709 |
++len; |
| 710 |
for ( j=4; j<sm->class_cnt ; ++j ) { |
| 711 |
if ( i ) { |
| 712 |
sprintf(buf, _("Class %d: "), j); |
| 713 |
lines[len].label = malloc((strlen(buf)+strlen(sm->classes[j])+1)); |
| 714 |
strcpy(lines[len].label,buf); |
| 715 |
strcat(lines[len].label,sm->classes[j]); |
| 716 |
lines[len].parent = node; |
| 717 |
} |
| 718 |
++len; |
| 719 |
} |
| 720 |
for ( j=0; j<sm->state_cnt; ++j ) { |
| 721 |
if ( i ) { |
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
sprintf(space, _("State %4d Next: "), j ); |
| 726 |
for ( k=0; k<sm->class_cnt; ++k ) |
| 727 |
sprintf( space+strlen(space), "%5d", sm->state[j*sm->class_cnt+k].next_state ); |
| 728 |
lines[len].label = copy(space); |
| 729 |
lines[len].parent = node; |
| 730 |
lines[len].monospace = true; |
| 731 |
} |
| 732 |
++len; |
| 733 |
if ( i ) { |
| 734 |
sprintf(space, _("State %4d Flags:"), j ); |
| 735 |
for ( k=0; k<sm->class_cnt; ++k ) |
| 736 |
sprintf( space+strlen(space), " %04x", sm->state[j*sm->class_cnt+k].flags ); |
| 737 |
lines[len].label = copy(space); |
| 738 |
lines[len].parent = node; |
| 739 |
lines[len].monospace = true; |
| 740 |
} |
| 741 |
++len; |
| 742 |
if ( sm->type==asm_context ) { |
| 743 |
if ( i ) { |
| 744 |
sprintf(space, _("State %4d Mark: "), j ); |
| 745 |
for ( k=0; k<sm->class_cnt; ++k ) |
| 746 |
if ( sm->state[j*sm->class_cnt+k].u.context.mark_lookup==NULL ) |
| 747 |
strcat(space," "); |
| 748 |
else |
| 749 |
sprintf( space+strlen(space), " %.80s", sm->state[j*sm->class_cnt+k].u.context.mark_lookup->lookup_name ); |
| 750 |
lines[len].label = copy(space); |
| 751 |
lines[len].parent = node; |
| 752 |
lines[len].monospace = true; |
| 753 |
} |
| 754 |
++len; |
| 755 |
if ( i ) { |
| 756 |
sprintf(space, _("State %4d Cur: "), j ); |
| 757 |
for ( k=0; k<sm->class_cnt; ++k ) |
| 758 |
if ( sm->state[j*sm->class_cnt+k].u.context.cur_lookup==NULL ) |
| 759 |
strcat(space," "); |
| 760 |
else |
| 761 |
sprintf( space+strlen(space), " %.80s", sm->state[j*sm->class_cnt+k].u.context.cur_lookup->lookup_name ); |
| 762 |
lines[len].label = copy(space); |
| 763 |
lines[len].parent = node; |
| 764 |
lines[len].monospace = true; |
| 765 |
} |
| 766 |
++len; |
| 767 |
} |
| 768 |
} |
| 769 |
for ( j=0; j<scnt; ++j ) { |
| 770 |
if ( i ) { |
| 771 |
sprintf(buf, _("Nested Substitution %.80s"), used[j]->lookup_name ); |
| 772 |
lines[len].label = copy(buf); |
| 773 |
lines[len].parent = node; |
| 774 |
lines[len].u.otl = used[j]; |
| 775 |
lines[len].build = BuildGSUBlookups; |
| 776 |
} |
| 777 |
++len; |
| 778 |
} |
| 779 |
if ( i==0 ) { |
| 780 |
node->children = lines = calloc(len+1,sizeof(struct node)); |
| 781 |
node->cnt = len; |
| 782 |
} |
| 783 |
} |
| 784 |
free(space); |
| 785 |
free(used); |
| 786 |
} |
| 787 |
|
| 788 |
static void BuildKern2(struct node *node,struct att_dlg *att) { |
| 789 |
struct lookup_subtable *sub = node->parent->u.sub; |
| 790 |
SplineChar *base = node->u.sc; |
| 791 |
SplineFont *_sf = att->sf; |
| 792 |
int doit, cnt; |
| 793 |
int isv; |
| 794 |
PST *pst; |
| 795 |
KernPair *kp; |
| 796 |
char buffer[200]; |
| 797 |
struct node *lines; |
| 798 |
|
| 799 |
for ( doit = 0; doit<2; ++doit ) { |
| 800 |
cnt = 0; |
| 801 |
for ( pst=base->possub; pst!=NULL; pst = pst->next ) { |
| 802 |
if ( pst->subtable==sub && pst->type==pst_pair && |
| 803 |
PSTAllComponentsExist(_sf,pst->u.pair.paired)) { |
| 804 |
if ( doit ) { |
| 805 |
sprintf(buffer, "%.80s ", pst->u.pair.paired ); |
| 806 |
if ( pst->u.pair.vr[0].xoff!=0 || |
| 807 |
|
| 808 |
|
| 809 |
( pst->u.pair.vr[0].yoff == 0 && |
| 810 |
pst->u.pair.vr[0].h_adv_off ==0 && |
| 811 |
pst->u.pair.vr[0].v_adv_off ==0 && |
| 812 |
pst->u.pair.vr[1].xoff ==0 && |
| 813 |
pst->u.pair.vr[1].yoff ==0 && |
| 814 |
pst->u.pair.vr[1].h_adv_off ==0 && |
| 815 |
pst->u.pair.vr[1].v_adv_off == 0 )) |
| 816 |
sprintf( buffer+strlen(buffer), " âxÂč=%d", pst->u.pair.vr[0].xoff ); |
| 817 |
if ( pst->u.pair.vr[0].yoff!=0 ) |
| 818 |
sprintf( buffer+strlen(buffer), " âyÂč=%d", pst->u.pair.vr[0].yoff ); |
| 819 |
if ( pst->u.pair.vr[0].h_adv_off!=0 ) |
| 820 |
sprintf( buffer+strlen(buffer), " âx_advÂč=%d", pst->u.pair.vr[0].h_adv_off ); |
| 821 |
if ( pst->u.pair.vr[0].v_adv_off!=0 ) |
| 822 |
sprintf( buffer+strlen(buffer), " ây_advÂč=%d", pst->u.pair.vr[0].v_adv_off ); |
| 823 |
if ( pst->u.pair.vr[1].xoff!=0 ) |
| 824 |
sprintf( buffer+strlen(buffer), " âxÂČ=%d", pst->u.pair.vr[1].xoff ); |
| 825 |
if ( pst->u.pair.vr[1].yoff!=0 ) |
| 826 |
sprintf( buffer+strlen(buffer), " âyÂČ=%d", pst->u.pair.vr[1].yoff ); |
| 827 |
if ( pst->u.pair.vr[1].h_adv_off!=0 ) |
| 828 |
sprintf( buffer+strlen(buffer), " âx_advÂČ=%d", pst->u.pair.vr[1].h_adv_off ); |
| 829 |
if ( pst->u.pair.vr[1].v_adv_off!=0 ) |
| 830 |
sprintf( buffer+strlen(buffer), " ây_advÂČ=%d", pst->u.pair.vr[1].v_adv_off ); |
| 831 |
lines[cnt].label = copy(buffer); |
| 832 |
lines[cnt].parent = node; |
| 833 |
} |
| 834 |
++cnt; |
| 835 |
} |
| 836 |
} |
| 837 |
for ( isv=0; isv<2 ; ++isv ) { |
| 838 |
for ( kp= isv ? base->vkerns : base->kerns ; kp!=NULL; kp=kp->next ) { |
| 839 |
if ( kp->subtable==sub ) { |
| 840 |
if ( doit ) { |
| 841 |
if ( isv ) |
| 842 |
sprintf( buffer, "%.80s ây_advÂč=%d", kp->sc->name, kp->off ); |
| 843 |
else if ( sub->lookup->lookup_flags&pst_r2l ) |
| 844 |
sprintf( buffer, "%.80s âx_advÂČ=%d", kp->sc->name, kp->off ); |
| 845 |
else |
| 846 |
sprintf( buffer, "%.80s âx_advÂč=%d", kp->sc->name, kp->off ); |
| 847 |
lines[cnt].label = copy(buffer); |
| 848 |
lines[cnt].parent = node; |
| 849 |
} |
| 850 |
++cnt; |
| 851 |
} |
| 852 |
} |
| 853 |
} |
| 854 |
if ( !doit ) { |
| 855 |
node->children = lines = calloc(cnt+1,sizeof(struct node)); |
| 856 |
node->cnt = cnt; |
| 857 |
} else |
| 858 |
qsort(lines,cnt,sizeof(struct node), node_alphabetize); |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
static void BuildKern(struct node *node,struct att_dlg *att) { |
| 863 |
struct lookup_subtable *sub = node->u.sub; |
| 864 |
SplineFont *_sf = att->sf, *sf; |
| 865 |
int k, gid, doit, cnt, maxc, isv; |
| 866 |
SplineChar *sc; |
| 867 |
PST *pst; |
| 868 |
KernPair *kp; |
| 869 |
struct node *lines; |
| 870 |
|
| 871 |
if ( _sf->cidmaster!=NULL ) _sf = _sf->cidmaster; |
| 872 |
|
| 873 |
k=maxc=0; |
| 874 |
do { |
| 875 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[k]; |
| 876 |
if ( sf->glyphcnt>maxc ) maxc = sf->glyphcnt; |
| 877 |
++k; |
| 878 |
} while ( k<_sf->subfontcnt ); |
| 879 |
|
| 880 |
for ( doit = 0; doit<2; ++doit ) { |
| 881 |
cnt = 0; |
| 882 |
for ( gid=0; gid<maxc; ++gid ) { |
| 883 |
k=0; |
| 884 |
sc = NULL; |
| 885 |
do { |
| 886 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[k]; |
| 887 |
if ( gid<sf->glyphcnt && sf->glyphs[gid]!=NULL ) { |
| 888 |
sc = sf->glyphs[gid]; |
| 889 |
break; |
| 890 |
} |
| 891 |
++k; |
| 892 |
} while ( k<_sf->subfontcnt ); |
| 893 |
if ( sc!=NULL ) { |
| 894 |
int found = false; |
| 895 |
for ( pst=sc->possub; pst!=NULL; pst = pst->next ) { |
| 896 |
if ( pst->subtable==sub ) { |
| 897 |
found = true; |
| 898 |
break; |
| 899 |
} |
| 900 |
} |
| 901 |
for ( isv=0; isv<2 && !found; ++isv ) { |
| 902 |
for ( kp= isv ? sc->vkerns : sc->kerns ; kp!=NULL; kp=kp->next ) { |
| 903 |
if ( kp->subtable==sub ) { |
| 904 |
found = true; |
| 905 |
break; |
| 906 |
} |
| 907 |
} |
| 908 |
} |
| 909 |
if ( found ) { |
| 910 |
if ( doit ) { |
| 911 |
lines[cnt].label = copy(sc->name); |
| 912 |
lines[cnt].parent = node; |
| 913 |
lines[cnt].build = BuildKern2; |
| 914 |
lines[cnt].u.sc = sc; |
| 915 |
} |
| 916 |
++cnt; |
| 917 |
} |
| 918 |
} |
| 919 |
} |
| 920 |
if ( !doit ) { |
| 921 |
node->children = lines = calloc(cnt+1,sizeof(struct node)); |
| 922 |
node->cnt = cnt; |
| 923 |
} else |
| 924 |
qsort(lines,cnt,sizeof(struct node), node_alphabetize); |
| 925 |
} |
| 926 |
} |
| 927 |
|
| 928 |
static void BuildPST(struct node *node,struct att_dlg *att) { |
| 929 |
struct lookup_subtable *sub = node->u.sub; |
| 930 |
SplineFont *_sf = att->sf, *sf; |
| 931 |
int k, gid, doit, cnt, maxl, len, maxc; |
| 932 |
SplineChar *sc; |
| 933 |
PST *pst; |
| 934 |
struct node *lines; |
| 935 |
char *lbuf=NULL; |
| 936 |
|
| 937 |
if ( _sf->cidmaster!=NULL ) _sf = _sf->cidmaster; |
| 938 |
|
| 939 |
k=maxc=0; |
| 940 |
do { |
| 941 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[k]; |
| 942 |
if ( sf->glyphcnt>maxc ) maxc = sf->glyphcnt; |
| 943 |
++k; |
| 944 |
} while ( k<_sf->subfontcnt ); |
| 945 |
|
| 946 |
for ( doit = 0; doit<2; ++doit ) { |
| 947 |
cnt = maxl = 0; |
| 948 |
for ( gid=0; gid<maxc; ++gid ) { |
| 949 |
k=0; |
| 950 |
sc = NULL; |
| 951 |
do { |
| 952 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[k]; |
| 953 |
if ( gid<sf->glyphcnt && sf->glyphs[gid]!=NULL ) { |
| 954 |
sc = sf->glyphs[gid]; |
| 955 |
break; |
| 956 |
} |
| 957 |
++k; |
| 958 |
} while ( k<_sf->subfontcnt ); |
| 959 |
if ( sc!=NULL ) { |
| 960 |
for ( pst=sc->possub; pst!=NULL; pst = pst->next ) { |
| 961 |
if ( pst->subtable==sub ) { |
| 962 |
if ( doit ) { |
| 963 |
if ( pst->type==pst_position ) |
| 964 |
sprintf(lbuf,"%s âx=%d ây=%d âx_adv=%d ây_adv=%d", |
| 965 |
sc->name, |
| 966 |
pst->u.pos.xoff, pst->u.pos.yoff, |
| 967 |
pst->u.pos.h_adv_off, pst->u.pos.v_adv_off ); |
| 968 |
else |
| 969 |
sprintf(lbuf, "%s %s %s", sc->name, |
| 970 |
pst->type==pst_ligature ? "<=" : "=>", |
| 971 |
pst->u.subs.variant ); |
| 972 |
lines[cnt].label = copy(lbuf); |
| 973 |
lines[cnt].parent = node; |
| 974 |
} else { |
| 975 |
if ( pst->type==pst_position ) |
| 976 |
len = strlen(sc->name)+40; |
| 977 |
else |
| 978 |
len = strlen(sc->name)+strlen(pst->u.subs.variant)+8; |
| 979 |
if ( len>maxl ) maxl = len; |
| 980 |
} |
| 981 |
++cnt; |
| 982 |
} |
| 983 |
} |
| 984 |
} |
| 985 |
} |
| 986 |
if ( !doit ) { |
| 987 |
lbuf = malloc(maxl*sizeof(unichar_t)); |
| 988 |
node->children = lines = calloc(cnt+1,sizeof(struct node)); |
| 989 |
node->cnt = cnt; |
| 990 |
} else |
| 991 |
qsort(lines,cnt,sizeof(struct node), node_alphabetize); |
| 992 |
} |
| 993 |
free(lbuf); |
| 994 |
} |
| 995 |
|
| 996 |
static void BuildSubtableDispatch(struct node *node,struct att_dlg *att) { |
| 997 |
struct lookup_subtable *sub = node->u.sub; |
| 998 |
int lookup_type = sub->lookup->lookup_type; |
| 999 |
|
| 1000 |
switch ( lookup_type ) { |
| 1001 |
case gpos_context: case gpos_contextchain: |
| 1002 |
case gsub_context: case gsub_contextchain: case gsub_reversecchain: |
| 1003 |
BuildFPST(node,att); |
| 1004 |
return; |
| 1005 |
case gpos_cursive: case gpos_mark2base: case gpos_mark2ligature: case gpos_mark2mark: |
| 1006 |
BuildAnchorLists(node,att); |
| 1007 |
return; |
| 1008 |
case gpos_pair: |
| 1009 |
if ( sub->kc!=NULL ) |
| 1010 |
BuildKC(node,att); |
| 1011 |
else |
| 1012 |
BuildKern(node,att); |
| 1013 |
return; |
| 1014 |
case gpos_single: |
| 1015 |
case gsub_single: case gsub_multiple: case gsub_alternate: case gsub_ligature: |
| 1016 |
BuildPST(node,att); |
| 1017 |
return; |
| 1018 |
case morx_indic: case morx_context: case morx_insert: |
| 1019 |
case kern_statemachine: |
| 1020 |
BuildASM(node,att); |
| 1021 |
return; |
| 1022 |
} |
| 1023 |
IError( "Unknown lookup type in BuildDispatch"); |
| 1024 |
} |
| 1025 |
|
| 1026 |
static void BuildGSUBlookups(struct node *node,struct att_dlg *att) { |
| 1027 |
OTLookup *otl = node->u.otl; |
| 1028 |
struct lookup_subtable *sub; |
| 1029 |
struct node *subslist; |
| 1030 |
int cnt; |
| 1031 |
|
| 1032 |
for ( sub = otl->subtables, cnt=0; sub!=NULL; sub=sub->next, ++cnt ); |
| 1033 |
subslist = calloc(cnt+1,sizeof(struct node)); |
| 1034 |
for ( sub = otl->subtables, cnt=0; sub!=NULL; sub=sub->next, ++cnt ) { |
| 1035 |
subslist[cnt].parent = node; |
| 1036 |
subslist[cnt].u.sub = sub; |
| 1037 |
subslist[cnt].build = BuildSubtableDispatch; |
| 1038 |
subslist[cnt].label = copy(sub->subtable_name); |
| 1039 |
} |
| 1040 |
|
| 1041 |
node->children = subslist; |
| 1042 |
node->cnt = cnt; |
| 1043 |
} |
| 1044 |
|
| 1045 |
static void BuildGSUBfeatures(struct node *node,struct att_dlg *att) { |
| 1046 |
int isgsub = node->parent->parent->parent->tag==CHR('G','S','U','B'); |
| 1047 |
uint32_t script = node->parent->parent->tag, lang = node->parent->tag, feat=node->tag; |
| 1048 |
OTLookup *otl; |
| 1049 |
SplineFont *sf = att->sf; |
| 1050 |
int match; |
| 1051 |
FeatureScriptLangList *fl; |
| 1052 |
struct scriptlanglist *sl; |
| 1053 |
int cnt, j,l; |
| 1054 |
struct node *lookups = NULL; |
| 1055 |
|
| 1056 |
for ( j=0; j<2; ++j ) { |
| 1057 |
cnt = 0; |
| 1058 |
for ( otl = isgsub ? sf->gsub_lookups : sf->gpos_lookups ; otl!=NULL ; otl=otl->next ) { |
| 1059 |
match = false; |
| 1060 |
for ( fl = otl->features; fl!=NULL && !match; fl=fl->next ) { |
| 1061 |
if ( fl->featuretag == feat ) { |
| 1062 |
for ( sl = fl->scripts; sl!=NULL && !match; sl=sl->next ) { |
| 1063 |
if ( sl->script == script ) { |
| 1064 |
for ( l=0; l<sl->lang_cnt; ++l ) { |
| 1065 |
uint32_t _lang = l<MAX_LANG ? sl->langs[l] : sl->morelangs[l-MAX_LANG]; |
| 1066 |
if ( _lang == lang ) { |
| 1067 |
match = true; |
| 1068 |
break; |
| 1069 |
} |
| 1070 |
} |
| 1071 |
} |
| 1072 |
} |
| 1073 |
} |
| 1074 |
} |
| 1075 |
if ( match ) { |
| 1076 |
if ( lookups ) { |
| 1077 |
lookups[cnt].parent = node; |
| 1078 |
lookups[cnt].build = BuildGSUBlookups; |
| 1079 |
lookups[cnt].label = copy(otl->lookup_name); |
| 1080 |
lookups[cnt].u.otl = otl; |
| 1081 |
} |
| 1082 |
++cnt; |
| 1083 |
} |
| 1084 |
} |
| 1085 |
if ( lookups == NULL ) |
| 1086 |
lookups = calloc(cnt+1,sizeof(struct node)); |
| 1087 |
} |
| 1088 |
|
| 1089 |
node->children = lookups; |
| 1090 |
node->cnt = cnt; |
| 1091 |
} |
| 1092 |
|
| 1093 |
static void BuildGSUBlang(struct node *node,struct att_dlg *att) { |
| 1094 |
int isgsub = node->parent->parent->tag==CHR('G','S','U','B'); |
| 1095 |
uint32_t script = node->parent->tag, lang = node->tag; |
| 1096 |
int i,j; |
| 1097 |
SplineFont *_sf = att->sf; |
| 1098 |
struct node *featnodes; |
| 1099 |
uint32_t *featlist; |
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
featlist = SFFeaturesInScriptLang(_sf,!isgsub,script,lang); |
| 1104 |
for ( j=0; featlist[j]!=0; ++j ); |
| 1105 |
featnodes = calloc(j+1,sizeof(struct node)); |
| 1106 |
for ( i=0; featlist[i]!=0; ++i ) { |
| 1107 |
featnodes[i].tag = featlist[i]; |
| 1108 |
featnodes[i].parent = node; |
| 1109 |
featnodes[i].build = BuildGSUBfeatures; |
| 1110 |
featnodes[i].label = TagFullName(_sf,featnodes[i].tag,false,false); |
| 1111 |
} |
| 1112 |
free( featlist ); |
| 1113 |
|
| 1114 |
node->children = featnodes; |
| 1115 |
node->cnt = j; |
| 1116 |
} |
| 1117 |
|
| 1118 |
static void BuildGSUBscript(struct node *node,struct att_dlg *att) { |
| 1119 |
SplineFont *sf = att->sf; |
| 1120 |
int lang_max; |
| 1121 |
int i,j; |
| 1122 |
struct node *langnodes; |
| 1123 |
uint32_t *langlist; |
| 1124 |
extern GTextInfo languages[]; |
| 1125 |
char buf[100]; |
| 1126 |
int isgpos = node->parent->tag == CHR('G','P','O','S'); |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
langlist = SFLangsInScript(sf,isgpos,node->tag); |
| 1132 |
for ( j=0; langlist[j]!=0; ++j ); |
| 1133 |
lang_max = j; |
| 1134 |
langnodes = calloc(lang_max+1,sizeof(struct node)); |
| 1135 |
for ( i=0; langlist[i]!=0; ++i ) |
| 1136 |
langnodes[i].tag = langlist[i]; |
| 1137 |
free( langlist ); |
| 1138 |
|
| 1139 |
for ( i=0; i<lang_max; ++i ) { |
| 1140 |
for ( j=0; languages[j].text!=NULL && langnodes[i].tag!=(uint32_t) (intptr_t) languages[j].userdata; ++j ); |
| 1141 |
buf[0] = '\''; |
| 1142 |
buf[1] = langnodes[i].tag>>24; |
| 1143 |
buf[2] = (langnodes[i].tag>>16)&0xff; |
| 1144 |
buf[3] = (langnodes[i].tag>>8)&0xff; |
| 1145 |
buf[4] = langnodes[i].tag&0xff; |
| 1146 |
buf[5] = '\''; |
| 1147 |
buf[6] = ' '; |
| 1148 |
if ( languages[j].text!=NULL ) { |
| 1149 |
strcpy(buf+7,S_((char *) languages[j].text)); |
| 1150 |
strcat(buf," "); |
| 1151 |
} else |
| 1152 |
buf[7]='\0'; |
| 1153 |
strcat(buf,_("Language")); |
| 1154 |
langnodes[i].label = copy(buf); |
| 1155 |
langnodes[i].build = BuildGSUBlang; |
| 1156 |
langnodes[i].parent = node; |
| 1157 |
} |
| 1158 |
node->children = langnodes; |
| 1159 |
node->cnt = i; |
| 1160 |
} |
| 1161 |
|
| 1162 |
static void BuildLookupList(struct node *node,struct att_dlg *att) { |
| 1163 |
OTLookup **otll = node->u.otll; |
| 1164 |
int i; |
| 1165 |
struct node *lookupnodes; |
| 1166 |
|
| 1167 |
for ( i=0; otll[i]!=NULL; ++i ); |
| 1168 |
lookupnodes = calloc(i+1,sizeof(struct node)); |
| 1169 |
for ( i=0; otll[i]!=NULL; ++i ) { |
| 1170 |
lookupnodes[i].label = copy(otll[i]->lookup_name); |
| 1171 |
lookupnodes[i].parent = node; |
| 1172 |
lookupnodes[i].build = BuildGSUBlookups; |
| 1173 |
lookupnodes[i].u.otl = otll[i]; |
| 1174 |
} |
| 1175 |
|
| 1176 |
node->children = lookupnodes; |
| 1177 |
node->cnt = i; |
| 1178 |
} |
| 1179 |
|
| 1180 |
static void BuildJSTFPrio(struct node *node, struct node *parent, OTLookup **otll, |
| 1181 |
char *label_if_some, char *label_if_none ) { |
| 1182 |
|
| 1183 |
node->parent = parent; |
| 1184 |
if ( otll==NULL || otll[0]==NULL ) { |
| 1185 |
node->label = copy(label_if_none); |
| 1186 |
node->children_checked = true; |
| 1187 |
node->cnt = 0; |
| 1188 |
} else { |
| 1189 |
node->label = copy(label_if_some); |
| 1190 |
node->build = BuildLookupList; |
| 1191 |
node->u.otll = otll; |
| 1192 |
} |
| 1193 |
} |
| 1194 |
|
| 1195 |
static void BuildJSTFlang(struct node *node,struct att_dlg *att) { |
| 1196 |
struct jstf_lang *jlang = node->u.jlang; |
| 1197 |
int i; |
| 1198 |
struct node *prionodes, *kids; |
| 1199 |
char buf[120]; |
| 1200 |
|
| 1201 |
prionodes = calloc(jlang->cnt+1,sizeof(struct node)); |
| 1202 |
for ( i=0; i<jlang->cnt; ++i ) { |
| 1203 |
kids = calloc(7,sizeof(struct node)); |
| 1204 |
BuildJSTFPrio(&kids[0],&prionodes[i],jlang->prios[i].enableExtend,_("Lookups Enabled for Expansion"), _("No Lookups Enabled for Expansion")); |
| 1205 |
BuildJSTFPrio(&kids[1],&prionodes[i],jlang->prios[i].disableExtend,_("Lookups Disabled for Expansion"), _("No Lookups Disabled for Expansion")); |
| 1206 |
BuildJSTFPrio(&kids[2],&prionodes[i],jlang->prios[i].maxExtend,_("Lookups Limiting Expansion"), _("No Lookups Limiting Expansion")); |
| 1207 |
BuildJSTFPrio(&kids[3],&prionodes[i],jlang->prios[i].enableShrink,_("Lookups Enabled for Shrinkage"), _("No Lookups Enabled for Shrinkage")); |
| 1208 |
BuildJSTFPrio(&kids[4],&prionodes[i],jlang->prios[i].disableShrink,_("Lookups Disabled for Shrinkage"), _("No Lookups Disabled for Shrinkage")); |
| 1209 |
BuildJSTFPrio(&kids[5],&prionodes[i],jlang->prios[i].maxShrink,_("Lookups Limiting Shrinkage"), _("No Lookups Limiting Shrinkage")); |
| 1210 |
sprintf( buf, _("Priority: %d"), i ); |
| 1211 |
prionodes[i].label = copy(buf); |
| 1212 |
prionodes[i].parent = node; |
| 1213 |
prionodes[i].children_checked = true; |
| 1214 |
prionodes[i].children = kids; |
| 1215 |
prionodes[i].cnt = 6; |
| 1216 |
} |
| 1217 |
|
| 1218 |
node->children = prionodes; |
| 1219 |
node->cnt = i; |
| 1220 |
} |
| 1221 |
|
| 1222 |
static void BuildJSTFscript(struct node *node,struct att_dlg *att) { |
| 1223 |
SplineFont *sf = att->sf; |
| 1224 |
Justify *jscript = node->u.jscript; |
| 1225 |
int lang_max; |
| 1226 |
int i,j, ch; |
| 1227 |
struct node *langnodes, *extenders=NULL; |
| 1228 |
extern GTextInfo languages[]; |
| 1229 |
char buf[100]; |
| 1230 |
struct jstf_lang *jlang; |
| 1231 |
char *start, *end; |
| 1232 |
int gc; |
| 1233 |
SplineChar *sc; |
| 1234 |
|
| 1235 |
for ( jlang=jscript->langs, lang_max=0; jlang!=NULL; jlang=jlang->next, ++lang_max ); |
| 1236 |
langnodes = calloc(lang_max+2,sizeof(struct node)); |
| 1237 |
gc =0; |
| 1238 |
if ( jscript->extenders!=NULL ) { |
| 1239 |
for ( start= jscript->extenders; ; ) { |
| 1240 |
for ( ; *start==',' || *start==' '; ++start ); |
| 1241 |
for ( end=start ; *end!='\0' && *end!=',' && *end!=' '; ++end ); |
| 1242 |
if ( start==end ) |
| 1243 |
break; |
| 1244 |
++gc; |
| 1245 |
if ( *end=='\0' ) |
| 1246 |
break; |
| 1247 |
start = end; |
| 1248 |
} |
| 1249 |
extenders = calloc(gc+1,sizeof(struct node)); |
| 1250 |
gc=0; |
| 1251 |
for ( start= jscript->extenders; ; ) { |
| 1252 |
for ( ; *start==',' || *start==' '; ++start ); |
| 1253 |
for ( end=start ; *end!='\0' && *end!=',' && *end!=' '; ++end ); |
| 1254 |
if ( start==end ) |
| 1255 |
break; |
| 1256 |
ch = *end; *end='\0'; |
| 1257 |
sc = SFGetChar(sf,-1,start); |
| 1258 |
*end = ch; |
| 1259 |
if ( sc!=NULL ) { |
| 1260 |
extenders[gc].label = copy(sc->name); |
| 1261 |
extenders[gc].parent = &langnodes[0]; |
| 1262 |
extenders[gc].children_checked = true; |
| 1263 |
extenders[gc].u.sc = sc; |
| 1264 |
++gc; |
| 1265 |
} |
| 1266 |
if ( *end=='\0' ) |
| 1267 |
break; |
| 1268 |
start = end; |
| 1269 |
} |
| 1270 |
} |
| 1271 |
if ( gc==0 ) { |
| 1272 |
free(extenders); |
| 1273 |
extenders=NULL; |
| 1274 |
langnodes[0].label = copy(_("No Extender Glyphs")); |
| 1275 |
langnodes[0].parent = node; |
| 1276 |
langnodes[0].children_checked = true; |
| 1277 |
} else { |
| 1278 |
langnodes[0].label = copy(_("Extender Glyphs")); |
| 1279 |
langnodes[0].parent = node; |
| 1280 |
langnodes[0].children_checked = true; |
| 1281 |
langnodes[0].children = extenders; |
| 1282 |
langnodes[0].cnt = gc; |
| 1283 |
} |
| 1284 |
|
| 1285 |
for ( jlang=jscript->langs, i=1; jlang!=NULL; jlang=jlang->next, ++i ) { |
| 1286 |
langnodes[i].tag = jlang->lang; |
| 1287 |
for ( j=0; languages[j].text!=NULL && langnodes[i].tag!=(uint32_t) (intptr_t) languages[j].userdata; ++j ); |
| 1288 |
buf[0] = '\''; |
| 1289 |
buf[1] = langnodes[i].tag>>24; |
| 1290 |
buf[2] = (langnodes[i].tag>>16)&0xff; |
| 1291 |
buf[3] = (langnodes[i].tag>>8)&0xff; |
| 1292 |
buf[4] = langnodes[i].tag&0xff; |
| 1293 |
buf[5] = '\''; |
| 1294 |
buf[6] = ' '; |
| 1295 |
if ( languages[j].text!=NULL ) { |
| 1296 |
strcpy(buf+7,S_((char *) languages[j].text)); |
| 1297 |
strcat(buf," "); |
| 1298 |
} else |
| 1299 |
buf[7]='\0'; |
| 1300 |
strcat(buf,_("Language")); |
| 1301 |
langnodes[i].label = copy(buf); |
| 1302 |
langnodes[i].build = BuildJSTFlang; |
| 1303 |
langnodes[i].parent = node; |
| 1304 |
langnodes[i].u.jlang = jlang; |
| 1305 |
} |
| 1306 |
node->children = langnodes; |
| 1307 |
node->cnt = i; |
| 1308 |
} |
| 1309 |
|
| 1310 |
static void BuildMClass(struct node *node,struct att_dlg *att) { |
| 1311 |
SplineFont *_sf = att->sf; |
| 1312 |
struct node *glyphs; |
| 1313 |
int i; |
| 1314 |
char *temp; |
| 1315 |
|
| 1316 |
node->children = glyphs = calloc(_sf->mark_class_cnt,sizeof(struct node)); |
| 1317 |
node->cnt = _sf->mark_class_cnt-1; |
| 1318 |
for ( i=1; i<_sf->mark_class_cnt; ++i ) { |
| 1319 |
glyphs[i-1].parent = node; |
| 1320 |
temp = malloc((strlen(_sf->mark_classes[i]) + strlen(_sf->mark_class_names[i]) + 4)); |
| 1321 |
strcpy(temp,_sf->mark_class_names[i]); |
| 1322 |
strcat(temp,": "); |
| 1323 |
strcat(temp,_sf->mark_classes[i]); |
| 1324 |
glyphs[i-1].label = temp; |
| 1325 |
} |
| 1326 |
} |
| 1327 |
|
| 1328 |
static void BuildLCarets(struct node *node,struct att_dlg *att) { |
| 1329 |
SplineChar *sc = node->u.sc; |
| 1330 |
PST *pst; |
| 1331 |
int i,j; |
| 1332 |
char buffer[20]; |
| 1333 |
struct node *lcars; |
| 1334 |
|
| 1335 |
j = -1; |
| 1336 |
for ( pst=sc->possub; pst!=NULL; pst=pst->next ) if ( pst->type==pst_lcaret ) { |
| 1337 |
for ( j=pst->u.lcaret.cnt-1; j>=0; --j ) |
| 1338 |
if ( pst->u.lcaret.carets[j]!=0 ) |
| 1339 |
goto break2; |
| 1340 |
} |
| 1341 |
break2: |
| 1342 |
if ( j==-1 ) |
| 1343 |
return; |
| 1344 |
++j; |
| 1345 |
node->children = lcars = calloc(j+1,sizeof(struct node)); |
| 1346 |
node->cnt = j; |
| 1347 |
for ( j=i=0; j<pst->u.lcaret.cnt; ++j ) { |
| 1348 |
if ( pst->u.lcaret.carets[j]!=0 ) { |
| 1349 |
sprintf( buffer,"%d", pst->u.lcaret.carets[j] ); |
| 1350 |
lcars[i].parent = node; |
| 1351 |
lcars[i++].label = copy(buffer); |
| 1352 |
} |
| 1353 |
} |
| 1354 |
} |
| 1355 |
|
| 1356 |
static void BuildLcar(struct node *node,struct att_dlg *att) { |
| 1357 |
SplineFont *sf, *_sf = att->sf; |
| 1358 |
struct node *glyphs; |
| 1359 |
int i,j,k,l, lcnt; |
| 1360 |
PST *pst; |
| 1361 |
|
| 1362 |
glyphs = NULL; |
| 1363 |
for ( k=0; k<2; ++k ) { |
| 1364 |
lcnt = 0; |
| 1365 |
l = 0; |
| 1366 |
do { |
| 1367 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1368 |
for ( i=0; i<sf->glyphcnt; ++i ) if ( sf->glyphs[i]!=NULL && sf->glyphs[i]->ttf_glyph!=-1 ) { |
| 1369 |
for ( pst=sf->glyphs[i]->possub; pst!=NULL; pst=pst->next ) { |
| 1370 |
if ( pst->type == pst_lcaret ) { |
| 1371 |
for ( j=pst->u.lcaret.cnt-1; j>=0; --j ) |
| 1372 |
if ( pst->u.lcaret.carets[j]!=0 ) |
| 1373 |
break; |
| 1374 |
if ( j!=-1 ) |
| 1375 |
break; |
| 1376 |
} |
| 1377 |
} |
| 1378 |
if ( pst!=NULL ) { |
| 1379 |
if ( glyphs!=NULL ) { |
| 1380 |
glyphs[lcnt].parent = node; |
| 1381 |
glyphs[lcnt].build = BuildLCarets; |
| 1382 |
glyphs[lcnt].u.sc = sf->glyphs[i]; |
| 1383 |
glyphs[lcnt].label = copy(sf->glyphs[i]->name); |
| 1384 |
} |
| 1385 |
++lcnt; |
| 1386 |
} |
| 1387 |
} |
| 1388 |
++l; |
| 1389 |
} while ( l<_sf->subfontcnt ); |
| 1390 |
if ( lcnt==0 ) |
| 1391 |
break; |
| 1392 |
if ( glyphs!=NULL ) |
| 1393 |
break; |
| 1394 |
node->children = glyphs = calloc(lcnt+1,sizeof(struct node)); |
| 1395 |
node->cnt = lcnt; |
| 1396 |
} |
| 1397 |
if ( glyphs!=NULL ) |
| 1398 |
qsort(glyphs,lcnt,sizeof(struct node), node_alphabetize); |
| 1399 |
} |
| 1400 |
|
| 1401 |
static void BuildGdefs(struct node *node,struct att_dlg *att) { |
| 1402 |
SplineFont *sf, *_sf = att->sf; |
| 1403 |
int i, cmax, l,j, ccnt; |
| 1404 |
SplineChar *sc; |
| 1405 |
struct node *chars; |
| 1406 |
char buffer[100]; |
| 1407 |
|
| 1408 |
cmax = 0; |
| 1409 |
l = 0; |
| 1410 |
do { |
| 1411 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1412 |
if ( cmax<sf->glyphcnt ) cmax = sf->glyphcnt; |
| 1413 |
++l; |
| 1414 |
} while ( l<_sf->subfontcnt ); |
| 1415 |
|
| 1416 |
chars = NULL; |
| 1417 |
for ( j=0; j<2; ++j ) { |
| 1418 |
ccnt = 0; |
| 1419 |
for ( i=0; i<cmax; ++i ) { |
| 1420 |
l = 0; |
| 1421 |
sc = NULL; |
| 1422 |
do { |
| 1423 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1424 |
if ( l<sf->glyphcnt && sf->glyphs[i]!=NULL ) { |
| 1425 |
sc = sf->glyphs[i]; |
| 1426 |
break; |
| 1427 |
} |
| 1428 |
++l; |
| 1429 |
} while ( l<_sf->subfontcnt ); |
| 1430 |
if ( sc!=NULL && SCWorthOutputting(sc) ) { |
| 1431 |
if ( chars!=NULL ) { |
| 1432 |
int gdefc = gdefclass(sc); |
| 1433 |
sprintf(buffer,"%.70s %s", sc->name, |
| 1434 |
gdefc==0 ? _("Not classified") : |
| 1435 |
gdefc==1 ? _("Base") : |
| 1436 |
gdefc==2 ? _("Ligature") : |
| 1437 |
gdefc==3 ? _("Mark") : |
| 1438 |
_("Component") ); |
| 1439 |
chars[ccnt].parent = node; |
| 1440 |
chars[ccnt].label = copy(buffer); |
| 1441 |
} |
| 1442 |
++ccnt; |
| 1443 |
} |
| 1444 |
} |
| 1445 |
if ( ccnt==0 ) |
| 1446 |
break; |
| 1447 |
if ( chars==NULL ) { |
| 1448 |
node->cnt = ccnt; |
| 1449 |
node->children = chars = calloc(ccnt+1,sizeof(struct node)); |
| 1450 |
} |
| 1451 |
} |
| 1452 |
} |
| 1453 |
|
| 1454 |
static void BuildGDEF(struct node *node,struct att_dlg *att) { |
| 1455 |
SplineFont *sf, *_sf = att->sf; |
| 1456 |
AnchorClass *ac; |
| 1457 |
PST *pst; |
| 1458 |
int l,j,i; |
| 1459 |
int gdef, lcar, mclass; |
| 1460 |
|
| 1461 |
for ( ac = _sf->anchor; ac!=NULL; ac=ac->next ) { |
| 1462 |
if ( ac->type==act_curs ) |
| 1463 |
break; |
| 1464 |
} |
| 1465 |
gdef = lcar = 0; |
| 1466 |
if ( ac!=NULL ) |
| 1467 |
gdef = 1; |
| 1468 |
l = 0; |
| 1469 |
pst = NULL; |
| 1470 |
do { |
| 1471 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1472 |
for ( i=0; i<sf->glyphcnt; ++i ) if ( sf->glyphs[i]!=NULL && sf->glyphs[i]->ttf_glyph!=-1 ) { |
| 1473 |
for ( pst=sf->glyphs[i]->possub; pst!=NULL; pst=pst->next ) { |
| 1474 |
if ( pst->type == pst_lcaret ) { |
| 1475 |
for ( j=pst->u.lcaret.cnt-1; j>=0; --j ) |
| 1476 |
if ( pst->u.lcaret.carets[j]!=0 ) { |
| 1477 |
lcar = 1; |
| 1478 |
break; |
| 1479 |
} |
| 1480 |
if ( j!=-1 ) |
| 1481 |
break; |
| 1482 |
} |
| 1483 |
} |
| 1484 |
if ( sf->glyphs[i]->glyph_class!=0 ) |
| 1485 |
gdef = 1; |
| 1486 |
} |
| 1487 |
++l; |
| 1488 |
} while ( l<_sf->subfontcnt ); |
| 1489 |
|
| 1490 |
mclass = _sf->mark_class_cnt!=0; |
| 1491 |
|
| 1492 |
if ( gdef+lcar+mclass!=0 ) { |
| 1493 |
node->children = calloc(gdef+lcar+mclass+1,sizeof(struct node)); |
| 1494 |
node->cnt = gdef+lcar+mclass; |
| 1495 |
if ( gdef ) { |
| 1496 |
node->children[0].label = copy(_("Glyph Definition Sub-Table")); |
| 1497 |
node->children[0].build = BuildGdefs; |
| 1498 |
node->children[0].parent = node; |
| 1499 |
} |
| 1500 |
if ( lcar ) { |
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
node->children[gdef].label = copy(_("Ligature Caret Sub-Table")); |
| 1505 |
node->children[gdef].build = BuildLcar; |
| 1506 |
node->children[gdef].parent = node; |
| 1507 |
} |
| 1508 |
if ( mclass ) { |
| 1509 |
node->children[gdef+lcar].label = copy(_("Mark Attachment Classes")); |
| 1510 |
node->children[gdef+lcar].build = BuildMClass; |
| 1511 |
node->children[gdef+lcar].parent = node; |
| 1512 |
} |
| 1513 |
} |
| 1514 |
} |
| 1515 |
|
| 1516 |
static void BuildBaseLangs(struct node *node,struct att_dlg *att) { |
| 1517 |
struct baselangextent *bl = node->u.langs, *lf; |
| 1518 |
int cnt; |
| 1519 |
struct node *langs; |
| 1520 |
char buffer[300]; |
| 1521 |
|
| 1522 |
for ( lf = bl, cnt=0; lf!=NULL; lf=lf->next, ++cnt ); |
| 1523 |
|
| 1524 |
node->children = langs = calloc(cnt+1,sizeof(struct node)); |
| 1525 |
node->cnt = cnt; |
| 1526 |
|
| 1527 |
for ( lf = bl, cnt=0; lf!=NULL; lf=lf->next, ++cnt ) { |
| 1528 |
sprintf( buffer, _("%c%c%c%c Min Extent=%d, Max Extent=%d"), |
| 1529 |
lf->lang>>24, lf->lang>>16, lf->lang>>8, lf->lang, |
| 1530 |
lf->descent, lf->ascent ); |
| 1531 |
langs[cnt].label = copy(buffer); |
| 1532 |
langs[cnt].parent = node; |
| 1533 |
if ( lf->features!=NULL ) { |
| 1534 |
langs[cnt].build = BuildBaseLangs; |
| 1535 |
langs[cnt].u.langs = lf->features; |
| 1536 |
} |
| 1537 |
} |
| 1538 |
} |
| 1539 |
|
| 1540 |
static void BuildBASE(struct node *node,struct att_dlg *att) { |
| 1541 |
SplineFont *_sf = att->sf; |
| 1542 |
struct Base *base = node->horizontal ? _sf->horiz_base : _sf->vert_base; |
| 1543 |
struct basescript *bs; |
| 1544 |
int cnt, i; |
| 1545 |
struct node *scripts; |
| 1546 |
char buffer[300]; |
| 1547 |
|
| 1548 |
for ( bs=base->scripts, cnt=0; bs!=NULL; bs=bs->next, ++cnt ); |
| 1549 |
|
| 1550 |
node->children = scripts = calloc(cnt+1,sizeof(struct node)); |
| 1551 |
node->cnt = cnt; |
| 1552 |
|
| 1553 |
for ( bs=base->scripts, cnt=0; bs!=NULL; bs=bs->next, ++cnt ) { |
| 1554 |
if ( base->baseline_cnt!=0 ) { |
| 1555 |
i = bs->def_baseline; |
| 1556 |
sprintf( buffer, _("Script '%c%c%c%c' on %c%c%c%c "), |
| 1557 |
bs->script>>24, bs->script>>16, bs->script>>8, bs->script, |
| 1558 |
base->baseline_tags[i]>>24, base->baseline_tags[i]>>16, |
| 1559 |
base->baseline_tags[i]>>8, base->baseline_tags[i] ); |
| 1560 |
for ( i=0; i<base->baseline_cnt; ++i ) |
| 1561 |
sprintf(buffer+strlen(buffer), " %c%c%c%c: %d ", |
| 1562 |
base->baseline_tags[i]>>24, base->baseline_tags[i]>>16, |
| 1563 |
base->baseline_tags[i]>>8, base->baseline_tags[i], |
| 1564 |
bs->baseline_pos[i]); |
| 1565 |
} else |
| 1566 |
sprintf( buffer, _("Script '%c%c%c%c' "), |
| 1567 |
bs->script>>24, bs->script>>16, bs->script>>8, bs->script ); |
| 1568 |
scripts[cnt].label = copy(buffer); |
| 1569 |
scripts[cnt].parent = node; |
| 1570 |
if ( bs->langs!=NULL ) { |
| 1571 |
scripts[cnt].build = BuildBaseLangs; |
| 1572 |
scripts[cnt].u.langs = bs->langs; |
| 1573 |
} |
| 1574 |
} |
| 1575 |
} |
| 1576 |
|
| 1577 |
static void BuildBsLnTable(struct node *node,struct att_dlg *att) { |
| 1578 |
SplineFont *_sf = att->sf; |
| 1579 |
int def_baseline; |
| 1580 |
int offsets[32]; |
| 1581 |
int16_t *baselines; |
| 1582 |
char buffer[300]; |
| 1583 |
struct node *glyphs; |
| 1584 |
int gid,i; |
| 1585 |
SplineChar *sc; |
| 1586 |
|
| 1587 |
baselines = PerGlyphDefBaseline(_sf,&def_baseline); |
| 1588 |
FigureBaseOffsets(_sf,def_baseline&0x1f,offsets); |
| 1589 |
|
| 1590 |
node->children = calloc(3+1,sizeof(struct node)); |
| 1591 |
node->cnt = 3; |
| 1592 |
|
| 1593 |
sprintf( buffer, _("Default Baseline: '%s'"), |
| 1594 |
(def_baseline&0x1f)==0 ? "romn" : |
| 1595 |
(def_baseline&0x1f)==1 ? "idcn" : |
| 1596 |
(def_baseline&0x1f)==2 ? "ideo" : |
| 1597 |
(def_baseline&0x1f)==3 ? "hang" : |
| 1598 |
(def_baseline&0x1f)==4 ? "math" : "????" ); |
| 1599 |
node->children[0].label = copy(buffer); |
| 1600 |
node->children[0].parent = node; |
| 1601 |
sprintf( buffer, _("Offsets from def. baseline: romn: %d idcn: %d ideo: %d hang: %d math: %d"), |
| 1602 |
offsets[0], offsets[1], offsets[2], offsets[3], offsets[4] ); |
| 1603 |
node->children[1].label = copy(buffer); |
| 1604 |
node->children[1].parent = node; |
| 1605 |
if ( def_baseline&0x100 ) { |
| 1606 |
node->children[2].label = copy(_("All glyphs have the same baseline")); |
| 1607 |
node->children[2].parent = node; |
| 1608 |
} else { |
| 1609 |
node->children[2].label = copy(_("Per glyph baseline data")); |
| 1610 |
node->children[2].parent = node; |
| 1611 |
node->children[2].children_checked = true; |
| 1612 |
node->children[2].children = glyphs = calloc(_sf->glyphcnt+1,sizeof(struct node)); |
| 1613 |
for ( gid=i=0; gid<_sf->glyphcnt; ++gid ) if ( (sc=_sf->glyphs[gid])!=NULL ) { |
| 1614 |
sprintf( buffer, "%s: %s", sc->name, |
| 1615 |
(baselines[gid])==0 ? "romn" : |
| 1616 |
(baselines[gid])==1 ? "idcn" : |
| 1617 |
(baselines[gid])==2 ? "ideo" : |
| 1618 |
(baselines[gid])==3 ? "hang" : |
| 1619 |
(baselines[gid])==4 ? "math" : "????" ); |
| 1620 |
glyphs[i].label = copy(buffer); |
| 1621 |
glyphs[i++].parent = &node->children[2]; |
| 1622 |
} |
| 1623 |
node->children[2].cnt = i; |
| 1624 |
} |
| 1625 |
free(baselines); |
| 1626 |
} |
| 1627 |
|
| 1628 |
static void BuildOpticalBounds(struct node *node,struct att_dlg *att) { |
| 1629 |
SplineFont *sf, *_sf = att->sf; |
| 1630 |
int i, cmax, l,j, ccnt; |
| 1631 |
SplineChar *sc; |
| 1632 |
struct node *chars; |
| 1633 |
char buffer[200]; |
| 1634 |
PST *left, *right; |
| 1635 |
|
| 1636 |
cmax = 0; |
| 1637 |
l = 0; |
| 1638 |
do { |
| 1639 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1640 |
if ( cmax<sf->glyphcnt ) cmax = sf->glyphcnt; |
| 1641 |
++l; |
| 1642 |
} while ( l<_sf->subfontcnt ); |
| 1643 |
|
| 1644 |
chars = NULL; |
| 1645 |
for ( j=0; j<2; ++j ) { |
| 1646 |
ccnt = 0; |
| 1647 |
for ( i=0; i<cmax; ++i ) { |
| 1648 |
l = 0; |
| 1649 |
sc = NULL; |
| 1650 |
do { |
| 1651 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1652 |
if ( i<sf->glyphcnt && sf->glyphs[i]!=NULL ) { |
| 1653 |
sc = sf->glyphs[i]; |
| 1654 |
break; |
| 1655 |
} |
| 1656 |
++l; |
| 1657 |
} while ( l<_sf->subfontcnt ); |
| 1658 |
if ( sc!=NULL && SCWorthOutputting(sc) && |
| 1659 |
haslrbounds(sc,&left,&right)) { |
| 1660 |
if ( chars!=NULL ) { |
| 1661 |
strncpy(buffer,sc->name,70); |
| 1662 |
if ( left!=NULL ) |
| 1663 |
sprintf(buffer+strlen(buffer), _(" Left Bound=%d"), |
| 1664 |
left->u.pos.xoff ); |
| 1665 |
if ( right!=NULL ) |
| 1666 |
sprintf(buffer+strlen(buffer), _(" Right Bound=%d"), |
| 1667 |
-right->u.pos.h_adv_off ); |
| 1668 |
chars[ccnt].parent = node; |
| 1669 |
chars[ccnt].label = copy(buffer); |
| 1670 |
} |
| 1671 |
++ccnt; |
| 1672 |
} |
| 1673 |
} |
| 1674 |
if ( ccnt==0 ) |
| 1675 |
return; |
| 1676 |
if ( chars==NULL ) { |
| 1677 |
node->children = chars = calloc(ccnt+1,sizeof(struct node)); |
| 1678 |
node->cnt = ccnt; |
| 1679 |
} |
| 1680 |
} |
| 1681 |
} |
| 1682 |
|
| 1683 |
static void BuildProperties(struct node *node,struct att_dlg *att) { |
| 1684 |
SplineFont *sf, *_sf = att->sf; |
| 1685 |
int i, cmax, l,j,k, ccnt; |
| 1686 |
SplineChar *sc; |
| 1687 |
struct node *chars; |
| 1688 |
uint16_t *props; |
| 1689 |
char buffer[200]; |
| 1690 |
|
| 1691 |
cmax = 0; |
| 1692 |
l = 0; |
| 1693 |
do { |
| 1694 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1695 |
if ( cmax<sf->glyphcnt ) cmax = sf->glyphcnt; |
| 1696 |
++l; |
| 1697 |
} while ( l<_sf->subfontcnt ); |
| 1698 |
|
| 1699 |
chars = NULL; props = NULL; |
| 1700 |
for ( j=0; j<2; ++j ) { |
| 1701 |
ccnt = 0; |
| 1702 |
for ( i=0; i<cmax; ++i ) { |
| 1703 |
l = 0; |
| 1704 |
sc = NULL; |
| 1705 |
do { |
| 1706 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[l]; |
| 1707 |
if ( i<sf->glyphcnt && sf->glyphs[i]!=NULL ) { |
| 1708 |
sc = sf->glyphs[i]; |
| 1709 |
break; |
| 1710 |
} |
| 1711 |
++l; |
| 1712 |
} while ( l<_sf->subfontcnt ); |
| 1713 |
if ( sc!=NULL ) { |
| 1714 |
if ( chars==NULL ) { |
| 1715 |
if ( SCWorthOutputting(sc)) |
| 1716 |
sc->ttf_glyph = ccnt++; |
| 1717 |
else |
| 1718 |
sc->ttf_glyph = -1; |
| 1719 |
} else if ( sc->ttf_glyph!=-1 ) { |
| 1720 |
int prop = props[sc->ttf_glyph], offset; |
| 1721 |
sprintf( buffer, "%.70s dir=%s", sc->name, |
| 1722 |
(prop&0x7f)==0 ? _("Strong Left to Right"): |
| 1723 |
(prop&0x7f)==1 ? _("Strong Right to Left"): |
| 1724 |
(prop&0x7f)==2 ? _("Arabic Right to Left"): |
| 1725 |
(prop&0x7f)==3 ? _("European Number"): |
| 1726 |
(prop&0x7f)==4 ? _("European Number Separator"): |
| 1727 |
(prop&0x7f)==5 ? _("European Number Terminator"): |
| 1728 |
(prop&0x7f)==6 ? _("Arabic Number"): |
| 1729 |
(prop&0x7f)==7 ? _("Common Number Separator"): |
| 1730 |
(prop&0x7f)==8 ? _("Block Separator"): |
| 1731 |
(prop&0x7f)==9 ? _("Segment Separator"): |
| 1732 |
(prop&0x7f)==10 ? _("White Space"): |
| 1733 |
(prop&0x7f)==11 ? _("Neutral"): |
| 1734 |
_("<Unknown direction>") ); |
| 1735 |
if ( prop&0x8000 ) |
| 1736 |
strcat(buffer,_(" Floating accent")); |
| 1737 |
if ( prop&0x4000 ) |
| 1738 |
strcat(buffer,_(" Hang left")); |
| 1739 |
if ( prop&0x2000 ) |
| 1740 |
strcat(buffer,_(" Hang right")); |
| 1741 |
if ( prop&0x80 ) |
| 1742 |
strcat(buffer,_(" Attach right")); |
| 1743 |
if ( prop&0x1000 ) { |
| 1744 |
offset = (prop&0xf00)>>8; |
| 1745 |
if ( offset&0x8 ) |
| 1746 |
offset |= 0xfffffff0; |
| 1747 |
if ( offset>0 ) { |
| 1748 |
for ( k=i+offset; k<sf->glyphcnt; ++k ) |
| 1749 |
if ( sf->glyphs[k]!=NULL && sf->glyphs[k]->ttf_glyph==sc->ttf_glyph+offset ) { |
| 1750 |
sprintf( buffer+strlen(buffer), _(" Mirror=%.30s"), sf->glyphs[k]->name ); |
| 1751 |
break; |
| 1752 |
} |
| 1753 |
} else { |
| 1754 |
for ( k=i+offset; k>=0; --k ) |
| 1755 |
if ( sf->glyphs[k]!=NULL && sf->glyphs[k]->ttf_glyph==sc->ttf_glyph+offset ) { |
| 1756 |
sprintf( buffer+strlen(buffer), _(" Mirror=%.30s"), sf->glyphs[k]->name ); |
| 1757 |
break; |
| 1758 |
} |
| 1759 |
} |
| 1760 |
} |
| 1761 |
chars[ccnt].parent = node; |
| 1762 |
chars[ccnt++].label = copy(buffer); |
| 1763 |
} |
| 1764 |
} |
| 1765 |
} |
| 1766 |
if ( chars==NULL ) { |
| 1767 |
struct glyphinfo gi; |
| 1768 |
memset(&gi,0,sizeof(gi)); gi.gcnt = _sf->glyphcnt; |
| 1769 |
props = props_array(_sf,&gi); |
| 1770 |
if ( props==NULL ) |
| 1771 |
return; |
| 1772 |
node->children = chars = calloc(ccnt+1,sizeof(struct node)); |
| 1773 |
} |
| 1774 |
node->cnt = ccnt; |
| 1775 |
} |
| 1776 |
free(props); |
| 1777 |
} |
| 1778 |
|
| 1779 |
static void BuildKernTable(struct node *node,struct att_dlg *att) { |
| 1780 |
SplineFont *_sf = att->sf; |
| 1781 |
OTLookup *otl; |
| 1782 |
FeatureScriptLangList *fl; |
| 1783 |
int doit, cnt; |
| 1784 |
struct node *kerns = NULL; |
| 1785 |
|
| 1786 |
if ( _sf->cidmaster ) _sf = _sf->cidmaster; |
| 1787 |
|
| 1788 |
for ( doit=0; doit<2; ++doit ) { |
| 1789 |
cnt = 0; |
| 1790 |
for ( otl = _sf->gpos_lookups; otl!=NULL ; otl=otl->next ) { |
| 1791 |
for ( fl=otl->features; fl!=NULL; fl=fl->next ) { |
| 1792 |
if ( (fl->featuretag==CHR('k','e','r','n') || fl->featuretag==CHR('v','k','r','n')) && |
| 1793 |
scriptsHaveDefault(fl->scripts)) |
| 1794 |
break; |
| 1795 |
} |
| 1796 |
if ( otl->lookup_type == gpos_pair && fl!=NULL ) { |
| 1797 |
if ( doit ) { |
| 1798 |
kerns[cnt].parent = node; |
| 1799 |
kerns[cnt].build = BuildGSUBlookups; |
| 1800 |
kerns[cnt].label = copy(otl->lookup_name); |
| 1801 |
kerns[cnt].u.otl = otl; |
| 1802 |
} |
| 1803 |
++cnt; |
| 1804 |
} |
| 1805 |
} |
| 1806 |
if ( !doit ) { |
| 1807 |
node->children = kerns = calloc(cnt+1,sizeof(struct node)); |
| 1808 |
node->cnt = cnt; |
| 1809 |
} |
| 1810 |
} |
| 1811 |
} |
| 1812 |
|
| 1813 |
static void BuildMorxTable(struct node *node,struct att_dlg *att) { |
| 1814 |
SplineFont *_sf = att->sf; |
| 1815 |
OTLookup *otl; |
| 1816 |
FeatureScriptLangList *fl; |
| 1817 |
int doit, cnt; |
| 1818 |
struct node *lookups = NULL; |
| 1819 |
int feat, set; |
| 1820 |
|
| 1821 |
if ( _sf->cidmaster ) _sf = _sf->cidmaster; |
| 1822 |
|
| 1823 |
for ( doit=0; doit<2; ++doit ) { |
| 1824 |
cnt = 0; |
| 1825 |
for ( otl = _sf->gsub_lookups; otl!=NULL ; otl=otl->next ) { |
| 1826 |
for ( fl=otl->features; fl!=NULL; fl=fl->next ) { |
| 1827 |
if ( fl->ismac || |
| 1828 |
(OTTagToMacFeature(fl->featuretag,&feat,&set) && |
| 1829 |
scriptsHaveDefault(fl->scripts) && |
| 1830 |
(otl->lookup_type==gsub_single || otl->lookup_type==gsub_ligature))) |
| 1831 |
break; |
| 1832 |
} |
| 1833 |
if ( fl!=NULL ) { |
| 1834 |
if ( doit ) { |
| 1835 |
lookups[cnt].parent = node; |
| 1836 |
lookups[cnt].build = BuildGSUBlookups; |
| 1837 |
lookups[cnt].label = copy(otl->lookup_name); |
| 1838 |
lookups[cnt].u.otl = otl; |
| 1839 |
} |
| 1840 |
++cnt; |
| 1841 |
} |
| 1842 |
} |
| 1843 |
if ( !doit ) { |
| 1844 |
node->children = lookups = calloc(cnt+1,sizeof(struct node)); |
| 1845 |
node->cnt = cnt; |
| 1846 |
} |
| 1847 |
} |
| 1848 |
} |
| 1849 |
|
| 1850 |
static void BuildTable(struct node *node,struct att_dlg *att) { |
| 1851 |
SplineFont *_sf = att->sf; |
| 1852 |
int script_max; |
| 1853 |
int i,j; |
| 1854 |
uint32_t *scriptlist; |
| 1855 |
struct node *scriptnodes; |
| 1856 |
extern GTextInfo scripts[]; |
| 1857 |
char buf[120]; |
| 1858 |
|
| 1859 |
|
| 1860 |
scriptlist = SFScriptsInLookups(_sf); |
| 1861 |
if ( scriptlist==NULL ) |
| 1862 |
return; |
| 1863 |
for ( i=0; scriptlist[i]!=0; ++i ); |
| 1864 |
script_max = i; |
| 1865 |
scriptnodes = calloc(script_max+1,sizeof(struct node)); |
| 1866 |
for ( i=0; scriptlist[i]!=0; ++i ) |
| 1867 |
scriptnodes[i].tag = scriptlist[i]; |
| 1868 |
free( scriptlist ); |
| 1869 |
|
| 1870 |
for ( i=0; i<script_max; ++i ) { |
| 1871 |
for ( j=0; scripts[j].text!=NULL && scriptnodes[i].tag!=(uint32_t) (intptr_t) scripts[j].userdata; ++j ); |
| 1872 |
buf[0] = '\''; |
| 1873 |
buf[1] = scriptnodes[i].tag>>24; |
| 1874 |
buf[2] = (scriptnodes[i].tag>>16)&0xff; |
| 1875 |
buf[3] = (scriptnodes[i].tag>>8)&0xff; |
| 1876 |
buf[4] = scriptnodes[i].tag&0xff; |
| 1877 |
buf[5] = '\''; |
| 1878 |
buf[6] = ' '; |
| 1879 |
if ( scripts[j].text!=NULL ) { |
| 1880 |
strcpy(buf+7,S_((char*) scripts[j].text)); |
| 1881 |
strcat(buf," "); |
| 1882 |
} else |
| 1883 |
buf[7]='\0'; |
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
strcat(buf,S_("writing system|Script")); |
| 1889 |
scriptnodes[i].label = copy(buf); |
| 1890 |
scriptnodes[i].build = BuildGSUBscript; |
| 1891 |
scriptnodes[i].parent = node; |
| 1892 |
} |
| 1893 |
node->children = scriptnodes; |
| 1894 |
node->cnt = i; |
| 1895 |
} |
| 1896 |
|
| 1897 |
static void BuildJSTFTable(struct node *node,struct att_dlg *att) { |
| 1898 |
SplineFont *_sf = att->sf; |
| 1899 |
int sub_cnt,i,j; |
| 1900 |
Justify *jscript; |
| 1901 |
struct node *scriptnodes; |
| 1902 |
char buf[120]; |
| 1903 |
extern GTextInfo scripts[]; |
| 1904 |
|
| 1905 |
for ( sub_cnt=0, jscript=_sf->justify; jscript!=NULL; jscript=jscript->next, ++sub_cnt ); |
| 1906 |
scriptnodes = calloc(sub_cnt+1,sizeof(struct node)); |
| 1907 |
for ( i=0, jscript=_sf->justify; jscript!=NULL; jscript=jscript->next, ++i ) { |
| 1908 |
scriptnodes[i].tag = jscript->script; |
| 1909 |
for ( j=0; scripts[j].text!=NULL && scriptnodes[i].tag!=(uint32_t) (intptr_t) scripts[j].userdata; ++j ); |
| 1910 |
buf[0] = '\''; |
| 1911 |
buf[1] = scriptnodes[i].tag>>24; |
| 1912 |
buf[2] = (scriptnodes[i].tag>>16)&0xff; |
| 1913 |
buf[3] = (scriptnodes[i].tag>>8)&0xff; |
| 1914 |
buf[4] = scriptnodes[i].tag&0xff; |
| 1915 |
buf[5] = '\''; |
| 1916 |
buf[6] = ' '; |
| 1917 |
if ( scripts[j].text!=NULL ) { |
| 1918 |
strcpy(buf+7,S_((char*) scripts[j].text)); |
| 1919 |
strcat(buf," "); |
| 1920 |
} else |
| 1921 |
buf[7]='\0'; |
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
strcat(buf,S_("writing system|Script")); |
| 1927 |
scriptnodes[i].label = copy(buf); |
| 1928 |
scriptnodes[i].build = BuildJSTFscript; |
| 1929 |
scriptnodes[i].parent = node; |
| 1930 |
scriptnodes[i].u.jscript = jscript; |
| 1931 |
} |
| 1932 |
node->children = scriptnodes; |
| 1933 |
node->cnt = i; |
| 1934 |
} |
| 1935 |
|
| 1936 |
static void BuildTop(struct att_dlg *att) { |
| 1937 |
SplineFont *sf, *_sf = att->sf; |
| 1938 |
int hasgsub=0, hasgpos=0, hasgdef=0, hasbase=0, hasjstf=0; |
| 1939 |
int hasmorx=0, haskern=0, hasvkern=0, haslcar=0, hasprop=0, hasopbd=0, hasbsln=0; |
| 1940 |
int haskc=0, hasvkc=0; |
| 1941 |
int feat, set; |
| 1942 |
struct node *tables; |
| 1943 |
PST *pst; |
| 1944 |
SplineChar *sc; |
| 1945 |
int i,k,j; |
| 1946 |
AnchorClass *ac; |
| 1947 |
OTLookup *otl; |
| 1948 |
FeatureScriptLangList *fl; |
| 1949 |
char buffer[200]; |
| 1950 |
|
| 1951 |
SFFindClearUnusedLookupBits(_sf); |
| 1952 |
|
| 1953 |
for ( otl=_sf->gsub_lookups; otl!=NULL; otl=otl->next ) { |
| 1954 |
for ( fl = otl->features; fl!=NULL ; fl=fl->next ) { |
| 1955 |
if ( !fl->ismac ) |
| 1956 |
hasgsub = true; |
| 1957 |
if ( fl->ismac || |
| 1958 |
(OTTagToMacFeature(fl->featuretag,&feat,&set) && |
| 1959 |
scriptsHaveDefault(fl->scripts) && |
| 1960 |
(otl->lookup_type==gsub_single || otl->lookup_type==gsub_ligature))) |
| 1961 |
hasmorx = true; |
| 1962 |
} |
| 1963 |
} |
| 1964 |
for ( otl=_sf->gpos_lookups; otl!=NULL; otl=otl->next ) { |
| 1965 |
if ( otl->lookup_type==kern_statemachine ) |
| 1966 |
haskern = true; |
| 1967 |
else |
| 1968 |
hasgpos = true; |
| 1969 |
if ( otl->lookup_type == gpos_single ) |
| 1970 |
for ( fl = otl->features; fl!=NULL ; fl=fl->next ) { |
| 1971 |
if ( fl->featuretag==CHR('l','f','b','d') || fl->featuretag==CHR('r','t','b','d') ) |
| 1972 |
hasopbd = true; |
| 1973 |
} |
| 1974 |
} |
| 1975 |
|
| 1976 |
k=0; |
| 1977 |
do { |
| 1978 |
sf = _sf->subfonts==NULL ? _sf : _sf->subfonts[k]; |
| 1979 |
for ( i=0; i<sf->glyphcnt; ++i ) if ( (sc=sf->glyphs[i])!=NULL ) { |
| 1980 |
if (( sc->unicodeenc>=0x10800 && sc->unicodeenc<=0x10fff ) || |
| 1981 |
( sc->unicodeenc!=-1 && sc->unicodeenc<0x10fff && |
| 1982 |
isrighttoleft(sc->unicodeenc)) || |
| 1983 |
ScriptIsRightToLeft(SCScriptFromUnicode(sc)) ) { |
| 1984 |
hasprop = true; |
| 1985 |
} |
| 1986 |
if ( sc->glyph_class!=0 ) |
| 1987 |
hasgdef = true; |
| 1988 |
for ( pst=sc->possub; pst!=NULL; pst=pst->next ) { |
| 1989 |
if ( pst->type == pst_lcaret ) { |
| 1990 |
for ( j=pst->u.lcaret.cnt-1; j>=0; --j ) |
| 1991 |
if ( pst->u.lcaret.carets[j]!=0 ) |
| 1992 |
break; |
| 1993 |
if ( j!=-1 ) |
| 1994 |
hasgdef = haslcar = true; |
| 1995 |
} |
| 1996 |
} |
| 1997 |
if ( sc->kerns!=NULL || sc->vkerns!=NULL ) |
| 1998 |
haskern = hasgpos = true; |
| 1999 |
} |
| 2000 |
++k; |
| 2001 |
} while ( k<_sf->subfontcnt ); |
| 2002 |
if ( _sf->vkerns!=NULL || _sf->kerns!=NULL ) |
| 2003 |
haskern = hasgpos = true; |
| 2004 |
if ( _sf->anchor!=NULL ) |
| 2005 |
hasgpos = true; |
| 2006 |
for ( ac = sf->anchor; ac!=NULL; ac=ac->next ) { |
| 2007 |
if ( ac->type==act_curs ) |
| 2008 |
break; |
| 2009 |
} |
| 2010 |
if ( ac!=NULL ) |
| 2011 |
hasgdef = true; |
| 2012 |
hasbase = ( _sf->horiz_base!=NULL || _sf->vert_base!=NULL ); |
| 2013 |
hasbsln = ( _sf->horiz_base!=NULL && _sf->horiz_base->baseline_cnt!=0 ); |
| 2014 |
hasjstf = ( _sf->justify!=NULL ); |
| 2015 |
|
| 2016 |
if ( hasgsub+hasgpos+hasgdef+hasmorx+haskern+haslcar+hasopbd+hasprop+hasbase+hasjstf==0 ) { |
| 2017 |
tables = calloc(2,sizeof(struct node)); |
| 2018 |
tables[0].label = copy(_("No Advanced Typography")); |
| 2019 |
} else { |
| 2020 |
tables = calloc((hasgsub||hasgpos||hasgdef||hasbase||hasjstf)+ |
| 2021 |
(hasmorx||haskern||haslcar||hasopbd||hasprop||hasbsln)+1,sizeof(struct node)); |
| 2022 |
i=0; |
| 2023 |
if ( hasgsub || hasgpos || hasgdef || hasbase || hasjstf ) { |
| 2024 |
tables[i].label = copy(_("OpenType Tables")); |
| 2025 |
tables[i].children_checked = true; |
| 2026 |
tables[i].children = calloc(hasgsub+hasgpos+hasgdef+hasbase+hasjstf+1,sizeof(struct node)); |
| 2027 |
tables[i].cnt = hasgsub + hasgpos + hasgdef + hasbase + hasjstf; |
| 2028 |
if ( hasbase ) { |
| 2029 |
int sub_cnt= (sf->horiz_base!=NULL) + (sf->vert_base!=NULL), j=0; |
| 2030 |
tables[i].children[0].label = copy(_("'BASE' Baseline Table")); |
| 2031 |
tables[i].children[0].tag = CHR('B','A','S','E'); |
| 2032 |
tables[i].children[0].parent = &tables[i]; |
| 2033 |
tables[i].children[0].children_checked = true; |
| 2034 |
tables[i].children[0].children = calloc(sub_cnt+1,sizeof(struct node)); |
| 2035 |
tables[i].children[0].cnt = sub_cnt; |
| 2036 |
if ( _sf->horiz_base!=NULL ) { |
| 2037 |
snprintf(buffer,sizeof(buffer), |
| 2038 |
P_("Horizontal: %d baseline","Horizontal: %d baselines",_sf->horiz_base->baseline_cnt), |
| 2039 |
_sf->horiz_base->baseline_cnt ); |
| 2040 |
tables[i].children[0].children[j].label = copy(buffer); |
| 2041 |
tables[i].children[0].children[j].horizontal = true; |
| 2042 |
tables[i].children[0].children[j].parent = &tables[i].children[0]; |
| 2043 |
tables[i].children[0].children[j].build = BuildBASE; |
| 2044 |
++j; |
| 2045 |
} |
| 2046 |
if ( _sf->vert_base!=NULL ) { |
| 2047 |
snprintf(buffer,sizeof(buffer), |
| 2048 |
P_("Vertical: %d baseline","Vertical: %d baselines",_sf->vert_base->baseline_cnt), |
| 2049 |
_sf->vert_base->baseline_cnt ); |
| 2050 |
tables[i].children[0].children[j].label = copy(buffer); |
| 2051 |
tables[i].children[0].children[j].horizontal = false; |
| 2052 |
tables[i].children[0].children[j].parent = &tables[i].children[0]; |
| 2053 |
tables[i].children[0].children[j].build = BuildBASE; |
| 2054 |
++j; |
| 2055 |
} |
| 2056 |
} |
| 2057 |
if ( hasgdef ) { |
| 2058 |
tables[i].children[hasbase].label = copy(_("'GDEF' Glyph Definition Table")); |
| 2059 |
tables[i].children[hasbase].tag = CHR('G','D','E','F'); |
| 2060 |
tables[i].children[hasbase].build = BuildGDEF; |
| 2061 |
tables[i].children[hasbase].parent = &tables[i]; |
| 2062 |
} |
| 2063 |
if ( hasgpos ) { |
| 2064 |
tables[i].children[hasgdef+hasbase].label = copy(_("'GPOS' Glyph Positioning Table")); |
| 2065 |
tables[i].children[hasgdef+hasbase].tag = CHR('G','P','O','S'); |
| 2066 |
tables[i].children[hasgdef+hasbase].build = BuildTable; |
| 2067 |
tables[i].children[hasgdef+hasbase].parent = &tables[i]; |
| 2068 |
} |
| 2069 |
if ( hasgsub ) { |
| 2070 |
tables[i].children[hasgdef+hasgpos+hasbase].label = copy(_("'GSUB' Glyph Substitution Table")); |
| 2071 |
tables[i].children[hasgdef+hasgpos+hasbase].tag = CHR('G','S','U','B'); |
| 2072 |
tables[i].children[hasgdef+hasgpos+hasbase].build = BuildTable; |
| 2073 |
tables[i].children[hasgdef+hasgpos+hasbase].parent = &tables[i]; |
| 2074 |
} |
| 2075 |
if ( hasjstf ) { |
| 2076 |
int k = hasgdef+hasgpos+hasbase+hasgsub; |
| 2077 |
tables[i].children[k].label = copy(_("'JSTF' Justification Table")); |
| 2078 |
tables[i].children[k].tag = CHR('J','S','T','F'); |
| 2079 |
tables[i].children[k].parent = &tables[i]; |
| 2080 |
tables[i].children[k].build = BuildJSTFTable; |
| 2081 |
} |
| 2082 |
++i; |
| 2083 |
} |
| 2084 |
if ( hasmorx || haskern || haslcar || hasopbd || hasprop || hasbsln ) { |
| 2085 |
int j = 0; |
| 2086 |
tables[i].label = copy(_("Apple Advanced Typography")); |
| 2087 |
tables[i].children_checked = true; |
| 2088 |
tables[i].children = calloc(hasmorx+haskern+haslcar+hasopbd+hasprop+hasvkern+haskc+hasvkc+hasbsln+1,sizeof(struct node)); |
| 2089 |
tables[i].cnt = hasmorx+haskern+hasopbd+hasprop+haslcar+hasvkern+haskc+hasvkc+hasbsln; |
| 2090 |
if ( hasbsln ) { |
| 2091 |
tables[i].children[j].label = copy(_("'bsln' Horizontal Baseline Table")); |
| 2092 |
tables[i].children[j].tag = CHR('b','s','l','n'); |
| 2093 |
tables[i].children[j].build = BuildBsLnTable; |
| 2094 |
tables[i].children[j++].parent = &tables[i]; |
| 2095 |
} |
| 2096 |
if ( haskern ) { |
| 2097 |
tables[i].children[j].label = copy(_("'kern' Horizontal Kerning Table")); |
| 2098 |
tables[i].children[j].tag = CHR('k','e','r','n'); |
| 2099 |
tables[i].children[j].build = BuildKernTable; |
| 2100 |
tables[i].children[j++].parent = &tables[i]; |
| 2101 |
} |
| 2102 |
if ( haslcar ) { |
| 2103 |
tables[i].children[j].label = copy(_("'lcar' Ligature Caret Table")); |
| 2104 |
tables[i].children[j].tag = CHR('l','c','a','r'); |
| 2105 |
tables[i].children[j].build = BuildLcar; |
| 2106 |
tables[i].children[j++].parent = &tables[i]; |
| 2107 |
} |
| 2108 |
if ( hasmorx ) { |
| 2109 |
tables[i].children[j].label = copy(_("'morx' Glyph Extended Metamorphosis Table")); |
| 2110 |
tables[i].children[j].tag = CHR('m','o','r','x'); |
| 2111 |
tables[i].children[j].build = BuildMorxTable; |
| 2112 |
tables[i].children[j++].parent = &tables[i]; |
| 2113 |
} |
| 2114 |
if ( hasopbd ) { |
| 2115 |
tables[i].children[j].label = copy(_("'opbd' Optical Bounds Table")); |
| 2116 |
tables[i].children[j].tag = CHR('o','p','b','d'); |
| 2117 |
tables[i].children[j].build = BuildOpticalBounds; |
| 2118 |
tables[i].children[j++].parent = &tables[i]; |
| 2119 |
} |
| 2120 |
if ( hasprop ) { |
| 2121 |
tables[i].children[j].label = copy(_("'prop' Glyph Properties Table")); |
| 2122 |
tables[i].children[j].tag = CHR('p','r','o','p'); |
| 2123 |
tables[i].children[j].build = BuildProperties; |
| 2124 |
tables[i].children[j++].parent = &tables[i]; |
| 2125 |
} |
| 2126 |
++i; |
| 2127 |
} |
| 2128 |
} |
| 2129 |
|
| 2130 |
att->tables = tables; |
| 2131 |
att->current = tables; |
| 2132 |
} |
| 2133 |
|
| 2134 |
static int _SizeCnt(struct att_dlg *att,struct node *node, int lpos,int depth) { |
| 2135 |
int i, len; |
| 2136 |
|
| 2137 |
if ( node->monospace ) |
| 2138 |
GDrawSetFont(att->v,att->monofont); |
| 2139 |
node->lpos = lpos++; |
| 2140 |
len = 5+8*depth+ att->as + 5 + GDrawGetText8Width(att->v,node->label,-1); |
| 2141 |
if ( len>att->maxl ) att->maxl = len; |
| 2142 |
if ( node->monospace ) |
| 2143 |
GDrawSetFont(att->v,att->font); |
| 2144 |
|
| 2145 |
if ( node->open ) { |
| 2146 |
if ( !node->children_checked && node->build!=NULL ) { |
| 2147 |
(node->build)(node,att); |
| 2148 |
node->children_checked = true; |
| 2149 |
} |
| 2150 |
for ( i=0; i<node->cnt; ++i ) |
| 2151 |
lpos = _SizeCnt(att,&node->children[i],lpos,depth+1); |
| 2152 |
} |
| 2153 |
return( lpos ); |
| 2154 |
} |
| 2155 |
|
| 2156 |
static int SizeCnt(struct att_dlg *att,struct node *node, int lpos) { |
| 2157 |
att->maxl = 0; |
| 2158 |
GDrawSetFont(att->v,att->font); |
| 2159 |
while ( node->label ) { |
| 2160 |
lpos = _SizeCnt(att,node,lpos,0); |
| 2161 |
++node; |
| 2162 |
} |
| 2163 |
|
| 2164 |
GScrollBarSetBounds(att->vsb,0,lpos,att->lines_page); |
| 2165 |
GScrollBarSetBounds(att->hsb,0,att->maxl,att->page_width); |
| 2166 |
att->open_cnt = lpos; |
| 2167 |
return( lpos ); |
| 2168 |
} |
| 2169 |
|
| 2170 |
static struct node *NodeFindLPos(struct node *node,int lpos,int *depth) { |
| 2171 |
for (;;) { |
| 2172 |
if ( node->lpos==lpos ) |
| 2173 |
return( node ); |
| 2174 |
if ( node[1].label!=NULL && node[1].lpos<=lpos ) |
| 2175 |
++node; |
| 2176 |
else if ( node->children==NULL || !node->open ) |
| 2177 |
return( NULL ); |
| 2178 |
else { |
| 2179 |
node = node->children; |
| 2180 |
++*depth; |
| 2181 |
} |
| 2182 |
} |
| 2183 |
} |
| 2184 |
|
| 2185 |
static struct node *NodeNext(struct node *node,int *depth) { |
| 2186 |
if ( node->open && node->children && node->children[0].label ) { |
| 2187 |
++*depth; |
| 2188 |
return( node->children ); |
| 2189 |
} |
| 2190 |
for (;;) { |
| 2191 |
if ( node[1].label ) |
| 2192 |
return( node+1 ); |
| 2193 |
node = node->parent; |
| 2194 |
--*depth; |
| 2195 |
if ( node==NULL ) |
| 2196 |
return( NULL ); |
| 2197 |
} |
| 2198 |
} |
| 2199 |
|
| 2200 |
static struct node *NodePrev(struct att_dlg *att, struct node *node,int *depth) { |
| 2201 |
while ( node->parent!=NULL && node==node->parent->children ) { |
| 2202 |
node = node->parent; |
| 2203 |
--*depth; |
| 2204 |
} |
| 2205 |
if ( node->parent==NULL && node==att->tables ) |
| 2206 |
return( NULL ); |
| 2207 |
--node; |
| 2208 |
while ( node->open ) { |
| 2209 |
node = &node->children[node->cnt-1]; |
| 2210 |
++*depth; |
| 2211 |
} |
| 2212 |
return( node ); |
| 2213 |
} |
| 2214 |
|
| 2215 |
static char *findstartquote(char *str) { |
| 2216 |
static int quotes[] = { '"', 0x00ab, 0x2018, 0x201b, 0x201c, 0x201e, 0 }; |
| 2217 |
char *last, *cur; |
| 2218 |
int i, ch; |
| 2219 |
|
| 2220 |
for ( cur=str; *cur!='\0'; ) { |
| 2221 |
last = cur; |
| 2222 |
ch = utf8_ildb((const char **) &cur); |
| 2223 |
for ( i=0; quotes[i]!=0; ++i ) |
| 2224 |
if ( ch==quotes[i] ) |
| 2225 |
return( last ); |
| 2226 |
} |
| 2227 |
return( NULL ); |
| 2228 |
} |
| 2229 |
|
| 2230 |
static char *findendquote(char *str) { |
| 2231 |
static int endquotes[] = { '"', 0x00bb, 0x2019, 0x201b, 0x201d, 0x201e, 0 }; |
| 2232 |
char *last, *cur; |
| 2233 |
int i, ch; |
| 2234 |
|
| 2235 |
utf8_ildb((const char **) &str); |
| 2236 |
for ( cur=str; *cur!='\0'; ) { |
| 2237 |
last = cur; |
| 2238 |
ch = utf8_ildb((const char **) &cur); |
| 2239 |
if ( ch==' ' ) |
| 2240 |
return( NULL ); |
| 2241 |
for ( i=0; endquotes[i]!=0; ++i ) |
| 2242 |
if ( ch==endquotes[i] ) |
| 2243 |
return( last ); |
| 2244 |
} |
| 2245 |
return( NULL ); |
| 2246 |
} |
| 2247 |
|
| 2248 |
static void AttExpose(struct att_dlg *att,GWindow pixmap,GRect *rect) { |
| 2249 |
int depth, y; |
| 2250 |
struct node *node; |
| 2251 |
GRect r; |
| 2252 |
Color fg; |
| 2253 |
char *spt, *ept; |
| 2254 |
|
| 2255 |
GDrawFillRect(pixmap,rect,GDrawGetDefaultBackground(NULL)); |
| 2256 |
GDrawSetLineWidth(pixmap,0); |
| 2257 |
|
| 2258 |
Color deffg = GDrawGetDefaultForeground(NULL); |
| 2259 |
r.height = r.width = att->as; |
| 2260 |
y = (rect->y/att->fh) * att->fh + att->as; |
| 2261 |
depth=0; |
| 2262 |
node = NodeFindLPos(att->tables,rect->y/att->fh+att->off_top,&depth); |
| 2263 |
GDrawSetFont(pixmap,att->font); |
| 2264 |
while ( node!=NULL ) { |
| 2265 |
r.y = y-att->as+1; |
| 2266 |
r.x = 5+8*depth - att->off_left; |
| 2267 |
fg = node==att->current ? showatt_selcol : deffg; |
| 2268 |
if ( node->build || node->children ) { |
| 2269 |
GDrawDrawRect(pixmap,&r,fg); |
| 2270 |
GDrawDrawLine(pixmap,r.x+2,r.y+att->as/2,r.x+att->as-2,r.y+att->as/2, |
| 2271 |
fg); |
| 2272 |
if ( !node->open ) |
| 2273 |
GDrawDrawLine(pixmap,r.x+att->as/2,r.y+2,r.x+att->as/2,r.y+att->as-2, |
| 2274 |
fg); |
| 2275 |
} |
| 2276 |
if ( node->monospace ) |
| 2277 |
GDrawSetFont(pixmap,att->monofont); |
| 2278 |
ept = NULL; |
| 2279 |
if ( att->dlg_type==dt_font_comp ) { |
| 2280 |
if ( (spt = findstartquote(node->label))!=NULL ) |
| 2281 |
ept = findendquote(spt); |
| 2282 |
} |
| 2283 |
if ( ept==NULL ) |
| 2284 |
GDrawDrawText8(pixmap,r.x+r.width+5,y,node->label,-1,fg); |
| 2285 |
else { |
| 2286 |
int len; |
| 2287 |
len = GDrawDrawText8(pixmap,r.x+r.width+5,y,node->label,spt-node->label,fg); |
| 2288 |
len += GDrawDrawText8(pixmap,r.x+r.width+5+len,y,spt,ept-spt,showatt_glyphnamecol); |
| 2289 |
GDrawDrawText8(pixmap,r.x+r.width+5+len,y,ept,-1,fg); |
| 2290 |
} |
| 2291 |
if ( node->monospace ) |
| 2292 |
GDrawSetFont(pixmap,att->font); |
| 2293 |
node = NodeNext(node,&depth); |
| 2294 |
y += att->fh; |
| 2295 |
if ( y-att->fh>rect->y+rect->height ) |
| 2296 |
break; |
| 2297 |
} |
| 2298 |
} |
| 2299 |
|
| 2300 |
static void ATTChangeCurrent(struct att_dlg *att,struct node *node) { |
| 2301 |
int oldl = att->current->lpos, newl; |
| 2302 |
GRect r; |
| 2303 |
if ( node==NULL ) |
| 2304 |
return; |
| 2305 |
newl = node->lpos; |
| 2306 |
att->current = node; |
| 2307 |
r.x =0; r.width = 3000; |
| 2308 |
if ( newl<att->off_top || newl>=att->off_top+att->lines_page ) { |
| 2309 |
att->off_top = newl-att->lines_page/3; |
| 2310 |
if ( att->off_top<0 ) att->off_top = 0; |
| 2311 |
GScrollBarSetPos(att->vsb,att->off_top); |
| 2312 |
GDrawRequestExpose(att->v,NULL,false); |
| 2313 |
} else if ( newl==oldl+1 ) { |
| 2314 |
r.y = (oldl-att->off_top)*att->fh; r.height = 2*att->fh; |
| 2315 |
GDrawRequestExpose(att->v,&r,false); |
| 2316 |
} else if ( newl==oldl-1 ) { |
| 2317 |
r.y = (newl-att->off_top)*att->fh; r.height = 2*att->fh; |
| 2318 |
GDrawRequestExpose(att->v,&r,false); |
| 2319 |
} else { |
| 2320 |
r.y = (newl-att->off_top)*att->fh; r.height = att->fh; |
| 2321 |
GDrawRequestExpose(att->v,&r,false); |
| 2322 |
r.y = (oldl-att->off_top)*att->fh; r.height = att->fh; |
| 2323 |
GDrawRequestExpose(att->v,&r,false); |
| 2324 |
} |
| 2325 |
} |
| 2326 |
|
| 2327 |
static void pututf8(uint32_t ch,FILE *file) { |
| 2328 |
if ( ch<0x80 ) |
| 2329 |
putc(ch,file); |
| 2330 |
else if ( ch<0x800 ) { |
| 2331 |
putc(0xc0 | (ch>>6), file); |
| 2332 |
putc(0x80 | (ch&0x3f), file); |
| 2333 |
} else { |
| 2334 |
putc( 0xe0 | (ch>>12),file ); |
| 2335 |
putc( 0x80 | ((ch>>6)&0x3f),file ); |
| 2336 |
putc( 0x80 | (ch&0x3f),file ); |
| 2337 |
} |
| 2338 |
} |
| 2339 |
|
| 2340 |
static void AttSave(struct att_dlg *att) { |
| 2341 |
char *ret = gwwv_save_filename(_("Save"),NULL, |
| 2342 |
"*.txt"); |
| 2343 |
char *cret; |
| 2344 |
FILE *file; |
| 2345 |
char *pt; |
| 2346 |
struct node *node; |
| 2347 |
int depth=0, d; |
| 2348 |
|
| 2349 |
if ( ret==NULL ) |
| 2350 |
return; |
| 2351 |
cret = utf82def_copy(ret); |
| 2352 |
file = fopen(cret,"w"); |
| 2353 |
free(cret); |
| 2354 |
if ( file==NULL ) { |
| 2355 |
ff_post_error(_("Save Failed"),_("Save Failed"),ret); |
| 2356 |
free(ret); |
| 2357 |
return; |
| 2358 |
} |
| 2359 |
free(ret); |
| 2360 |
|
| 2361 |
pututf8(0xfeff,file); |
| 2362 |
node = NodeFindLPos(att->tables,0,&depth); |
| 2363 |
while ( node!=NULL ) { |
| 2364 |
d = depth; |
| 2365 |
while ( d>=4 ) { |
| 2366 |
pututf8('\t',file); |
| 2367 |
d -= 4; |
| 2368 |
} |
| 2369 |
while ( d>0 ) { |
| 2370 |
pututf8(' ',file); |
| 2371 |
pututf8(' ',file); |
| 2372 |
--d; |
| 2373 |
} |
| 2374 |
if ( !node->build && !node->children ) |
| 2375 |
pututf8(' ',file); |
| 2376 |
else if ( node->open ) |
| 2377 |
pututf8('-',file); |
| 2378 |
else |
| 2379 |
pututf8('+',file); |
| 2380 |
for ( pt=node->label; *pt; ++pt ) |
| 2381 |
putc(*pt,file); |
| 2382 |
pututf8('\n',file); |
| 2383 |
node = NodeNext(node,&depth); |
| 2384 |
} |
| 2385 |
fclose(file); |
| 2386 |
} |
| 2387 |
|
| 2388 |
static void AttSaveM(GWindow gw, GMenuItem *mi,GEvent *e) { |
| 2389 |
struct att_dlg *att = (struct att_dlg *) GDrawGetUserData(gw); |
| 2390 |
AttSave(att); |
| 2391 |
} |
| 2392 |
|
| 2393 |
static GMenuItem att_popuplist[] = { |
| 2394 |
{ { (unichar_t *) N_("Save"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, 'S' }, 'S', ksm_control, NULL, NULL, AttSaveM, 0 }, |
| 2395 |
GMENUITEM_EMPTY |
| 2396 |
}; |
| 2397 |
|
| 2398 |
static FontView *FVVerify(FontView *fv) { |
| 2399 |
FontView *test; |
| 2400 |
|
| 2401 |
for ( test= fv_list; test!=NULL && test!=fv; test=(FontView *) test->b.next ); |
| 2402 |
return( test ); |
| 2403 |
} |
| 2404 |
|
| 2405 |
static void FontCompActivate(struct att_dlg *att,struct node *node) { |
| 2406 |
char *pt, *pt2; int ch; |
| 2407 |
SplineChar *sc1=NULL, *sc2=NULL; |
| 2408 |
int size=0, depth=0; |
| 2409 |
BDFFont *bdf1, *bdf2; |
| 2410 |
|
| 2411 |
att->fv1 = FVVerify(att->fv1); |
| 2412 |
att->fv2 = FVVerify(att->fv2); |
| 2413 |
|
| 2414 |
pt = findstartquote(node->label); |
| 2415 |
if ( pt==NULL ) |
| 2416 |
return; |
| 2417 |
pt2 = findendquote(pt); |
| 2418 |
if ( pt2==NULL ) |
| 2419 |
return; |
| 2420 |
utf8_ildb((const char **) &pt); |
| 2421 |
ch = *pt2; *pt2 = '\0'; |
| 2422 |
if ( att->fv1!=NULL ) |
| 2423 |
sc1 = SFGetChar(att->fv1->b.sf,-1,pt); |
| 2424 |
if ( att->fv2!=NULL ) |
| 2425 |
sc2 = SFGetChar(att->fv2->b.sf,-1,pt); |
| 2426 |
*pt2 = ch; |
| 2427 |
|
| 2428 |
pt = strchr(node->label,'@'); |
| 2429 |
if ( pt!=NULL ) { |
| 2430 |
for (pt2 = pt-1; pt2>=node->label && isdigit(*pt2); --pt2 ); |
| 2431 |
size = strtol(pt2+1,NULL,10); |
| 2432 |
depth = strtol(pt+1,NULL,10); |
| 2433 |
} |
| 2434 |
if ( size!=0 && depth!=0 ) { |
| 2435 |
for ( bdf1 = att->fv1->b.sf->bitmaps; bdf1!=NULL && |
| 2436 |
(bdf1->pixelsize!=size || BDFDepth(bdf1)!=depth); bdf1=bdf1->next ); |
| 2437 |
for ( bdf2 = att->fv2->b.sf->bitmaps; bdf2!=NULL && |
| 2438 |
(bdf2->pixelsize!=size || BDFDepth(bdf2)!=depth); bdf2=bdf2->next ); |
| 2439 |
if ( bdf1!=NULL && sc1!=NULL && sc1->orig_pos<bdf1->glyphcnt && |
| 2440 |
bdf1->glyphs[sc1->orig_pos]!=NULL ) |
| 2441 |
BitmapViewCreate(bdf1->glyphs[sc1->orig_pos],bdf1,att->fv1, |
| 2442 |
att->fv1->b.map->backmap[sc1->orig_pos]); |
| 2443 |
if ( bdf2!=NULL && sc2!=NULL && sc2->orig_pos<bdf2->glyphcnt && |
| 2444 |
bdf2->glyphs[sc2->orig_pos]!=NULL ) |
| 2445 |
BitmapViewCreate(bdf2->glyphs[sc2->orig_pos],bdf2,att->fv2, |
| 2446 |
att->fv2->b.map->backmap[sc2->orig_pos]); |
| 2447 |
} else { |
| 2448 |
if ( sc1!=NULL ) |
| 2449 |
CharViewCreate(sc1,att->fv1,att->fv1->b.map->backmap[sc1->orig_pos]); |
| 2450 |
if ( sc2!=NULL ) |
| 2451 |
CharViewCreate(sc2,att->fv2,att->fv2->b.map->backmap[sc2->orig_pos]); |
| 2452 |
} |
| 2453 |
} |
| 2454 |
|
| 2455 |
static void _ATT_FreeImage(const void *_ci, GImage *img) { |
| 2456 |
GImageDestroy(img); |
| 2457 |
} |
| 2458 |
|
| 2459 |
static GImage *_ATT_PopupImage(const void *_att) { |
| 2460 |
const struct att_dlg *att = _att; |
| 2461 |
char *start, *pt; |
| 2462 |
int ch; |
| 2463 |
SplineChar *sc; |
| 2464 |
int isliga; |
| 2465 |
|
| 2466 |
if ( att->popup_node==NULL || att->popup_node->label==NULL ) |
| 2467 |
return( NULL ); |
| 2468 |
for ( start=att->popup_node->label; *start==' ' || isdigit(*start); ++start ); |
| 2469 |
for ( pt=start; *pt!='\0' && *pt!=' '; ++pt ); |
| 2470 |
ch = *pt; *pt = '\0'; |
| 2471 |
sc = SFGetChar(att->sf,-1,start); |
| 2472 |
*pt = ch; |
| 2473 |
if ( sc==NULL ) |
| 2474 |
return( NULL ); |
| 2475 |
|
| 2476 |
isliga = -1; |
| 2477 |
while ( *pt==' ' || *pt=='=' || *pt=='>' || *pt=='<' ) { |
| 2478 |
if ( *pt=='<' ) isliga = true; |
| 2479 |
if ( *pt=='>' ) isliga = false; |
| 2480 |
++pt; |
| 2481 |
} |
| 2482 |
if ( !isalpha(*pt)) |
| 2483 |
pt = ""; |
| 2484 |
return( NameList_GetImage(att->sf,sc,att->def_layer,pt,isliga)); |
| 2485 |
} |
| 2486 |
|
| 2487 |
static void ATTStartPopup(struct att_dlg *att,struct node *node) { |
| 2488 |
att->popup_node = node; |
| 2489 |
GGadgetPreparePopupImage(att->v,NULL,att,_ATT_PopupImage,_ATT_FreeImage); |
| 2490 |
} |
| 2491 |
|
| 2492 |
static void AttMouse(struct att_dlg *att,GEvent *event) { |
| 2493 |
int l, depth; |
| 2494 |
struct node *node; |
| 2495 |
GRect r; |
| 2496 |
|
| 2497 |
if ( event->type==et_mousedown ) { |
| 2498 |
GGadgetEndPopup(); |
| 2499 |
if ( event->u.mouse.button==3 ) { |
| 2500 |
static int done=false; |
| 2501 |
if ( !done ) { |
| 2502 |
done = true; |
| 2503 |
att_popuplist[0].ti.text = (unichar_t *) _( (char *)att_popuplist[0].ti.text); |
| 2504 |
} |
| 2505 |
GMenuCreatePopupMenu(att->v,event, att_popuplist); |
| 2506 |
} |
| 2507 |
return; |
| 2508 |
} |
| 2509 |
|
| 2510 |
l = (event->u.mouse.y/att->fh); |
| 2511 |
depth=0; |
| 2512 |
node = NodeFindLPos(att->tables,l+att->off_top,&depth); |
| 2513 |
if ( event->type==et_mouseup ) { |
| 2514 |
ATTChangeCurrent(att,node); |
| 2515 |
if ( event->u.mouse.y > l*att->fh+att->as || |
| 2516 |
event->u.mouse.x<5+8*depth || |
| 2517 |
event->u.mouse.x>=5+8*depth+att->as || node==NULL ) { |
| 2518 |
|
| 2519 |
if ( event->u.mouse.x > 5+8*depth+att->as && node!=NULL && |
| 2520 |
att->dlg_type == dt_font_comp && event->u.mouse.clicks>1 ) |
| 2521 |
FontCompActivate(att,node); |
| 2522 |
return; |
| 2523 |
} |
| 2524 |
node->open = !node->open; |
| 2525 |
|
| 2526 |
SizeCnt(att,att->tables,0); |
| 2527 |
|
| 2528 |
r.x = 0; r.width = 3000; |
| 2529 |
r.y = l*att->fh; r.height = 3000; |
| 2530 |
GDrawRequestExpose(att->v,&r,false); |
| 2531 |
} else if ( event->type == et_mousemove ) { |
| 2532 |
GGadgetEndPopup(); |
| 2533 |
ATTStartPopup(att,node); |
| 2534 |
} |
| 2535 |
} |
| 2536 |
|
| 2537 |
static void AttScroll(struct att_dlg *att,struct sbevent *sb) { |
| 2538 |
int newpos = att->off_top; |
| 2539 |
|
| 2540 |
switch( sb->type ) { |
| 2541 |
case et_sb_top: |
| 2542 |
newpos = 0; |
| 2543 |
break; |
| 2544 |
case et_sb_uppage: |
| 2545 |
newpos -= att->lines_page; |
| 2546 |
break; |
| 2547 |
case et_sb_up: |
| 2548 |
--newpos; |
| 2549 |
break; |
| 2550 |
case et_sb_down: |
| 2551 |
++newpos; |
| 2552 |
break; |
| 2553 |
case et_sb_downpage: |
| 2554 |
newpos += att->lines_page; |
| 2555 |
break; |
| 2556 |
case et_sb_bottom: |
| 2557 |
newpos = att->open_cnt-att->lines_page; |
| 2558 |
break; |
| 2559 |
case et_sb_thumb: |
| 2560 |
case et_sb_thumbrelease: |
| 2561 |
newpos = sb->pos; |
| 2562 |
break; |
| 2563 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 2564 |
} |
| 2565 |
if ( newpos>att->open_cnt-att->lines_page ) |
| 2566 |
newpos = att->open_cnt-att->lines_page; |
| 2567 |
if ( newpos<0 ) newpos =0; |
| 2568 |
if ( newpos!=att->off_top ) { |
| 2569 |
int diff = newpos-att->off_top; |
| 2570 |
att->off_top = newpos; |
| 2571 |
GScrollBarSetPos(att->vsb,att->off_top); |
| 2572 |
GDrawScroll(att->v,NULL,0,diff*att->fh); |
| 2573 |
} |
| 2574 |
} |
| 2575 |
|
| 2576 |
|
| 2577 |
static void AttHScroll(struct att_dlg *att,struct sbevent *sb) { |
| 2578 |
int newpos = att->off_left; |
| 2579 |
|
| 2580 |
switch( sb->type ) { |
| 2581 |
case et_sb_top: |
| 2582 |
newpos = 0; |
| 2583 |
break; |
| 2584 |
case et_sb_uppage: |
| 2585 |
newpos -= att->page_width; |
| 2586 |
break; |
| 2587 |
|
| 2588 |
case et_sb_up: |
| 2589 |
newpos -= (6*att->fh)/10; |
| 2590 |
break; |
| 2591 |
case et_sb_down: |
| 2592 |
newpos += (6*att->fh)/10; |
| 2593 |
break; |
| 2594 |
case et_sb_downpage: |
| 2595 |
newpos += att->page_width; |
| 2596 |
break; |
| 2597 |
case et_sb_bottom: |
| 2598 |
newpos = att->maxl-att->page_width; |
| 2599 |
break; |
| 2600 |
case et_sb_thumb: |
| 2601 |
case et_sb_thumbrelease: |
| 2602 |
newpos = sb->pos; |
| 2603 |
break; |
| 2604 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 2605 |
} |
| 2606 |
if ( newpos>att->maxl-att->page_width ) |
| 2607 |
newpos = att->maxl-att->page_width; |
| 2608 |
if ( newpos<0 ) newpos =0; |
| 2609 |
if ( newpos!=att->off_left ) { |
| 2610 |
int diff = newpos-att->off_left; |
| 2611 |
att->off_left = newpos; |
| 2612 |
GScrollBarSetPos(att->hsb,att->off_left); |
| 2613 |
GDrawScroll(att->v,NULL,-diff,0); |
| 2614 |
} |
| 2615 |
} |
| 2616 |
|
| 2617 |
static void AttResize(struct att_dlg *att,GEvent *event) { |
| 2618 |
GRect size, wsize; |
| 2619 |
int lcnt; |
| 2620 |
int sbsize = GDrawPointsToPixels(att->gw,_GScrollBar_Width); |
| 2621 |
|
| 2622 |
GDrawGetSize(att->gw,&size); |
| 2623 |
lcnt = (size.height-att->bmargin)/att->fh; |
| 2624 |
GGadgetResize(att->vsb,sbsize,lcnt*att->fh); |
| 2625 |
GGadgetMove(att->vsb,size.width-sbsize,0); |
| 2626 |
GGadgetResize(att->hsb,size.width-sbsize,sbsize); |
| 2627 |
GGadgetMove(att->hsb,0,lcnt*att->fh); |
| 2628 |
GDrawResize(att->v,size.width-sbsize,lcnt*att->fh); |
| 2629 |
att->page_width = size.width-sbsize; |
| 2630 |
att->lines_page = lcnt; |
| 2631 |
GScrollBarSetBounds(att->vsb,0,att->open_cnt,att->lines_page); |
| 2632 |
GScrollBarSetBounds(att->hsb,0,att->maxl,att->page_width); |
| 2633 |
|
| 2634 |
GGadgetGetSize(att->cancel,&wsize); |
| 2635 |
GGadgetMove(att->cancel,(size.width-wsize.width)/2,lcnt*att->fh+sbsize+5); |
| 2636 |
GDrawRequestExpose(att->v,NULL,true); |
| 2637 |
GDrawRequestExpose(att->gw,NULL,true); |
| 2638 |
} |
| 2639 |
|
| 2640 |
static int AttChar(struct att_dlg *att,GEvent *event) { |
| 2641 |
int depth = 0; |
| 2642 |
int pos; |
| 2643 |
|
| 2644 |
switch (event->u.chr.keysym) { |
| 2645 |
case GK_F1: case GK_Help: |
| 2646 |
help("ui/dialogs/showatt.html", NULL); |
| 2647 |
return( true ); |
| 2648 |
case GK_Return: case GK_KP_Enter: |
| 2649 |
att->current->open = !att->current->open; |
| 2650 |
|
| 2651 |
att->open_cnt = SizeCnt(att,att->tables,0); |
| 2652 |
GScrollBarSetBounds(att->vsb,0,att->open_cnt,att->lines_page); |
| 2653 |
|
| 2654 |
GDrawRequestExpose(att->v,NULL,false); |
| 2655 |
return( true ); |
| 2656 |
case GK_Page_Down: case GK_KP_Page_Down: |
| 2657 |
pos = att->off_top+(att->lines_page<=1?1:att->lines_page-1); |
| 2658 |
if ( pos >= att->open_cnt-att->lines_page ) |
| 2659 |
pos = att->open_cnt-att->lines_page; |
| 2660 |
if ( pos<0 ) pos = 0; |
| 2661 |
att->off_top = pos; |
| 2662 |
GScrollBarSetPos(att->vsb,pos); |
| 2663 |
GDrawRequestExpose(att->v,NULL,false); |
| 2664 |
return( true ); |
| 2665 |
case GK_Down: case GK_KP_Down: |
| 2666 |
ATTChangeCurrent(att,NodeNext(att->current,&depth)); |
| 2667 |
return( true ); |
| 2668 |
case GK_Up: case GK_KP_Up: |
| 2669 |
ATTChangeCurrent(att,NodePrev(att,att->current,&depth)); |
| 2670 |
return( true ); |
| 2671 |
case GK_Page_Up: case GK_KP_Page_Up: |
| 2672 |
pos = att->off_top-(att->lines_page<=1?1:att->lines_page-1); |
| 2673 |
if ( pos<0 ) pos = 0; |
| 2674 |
att->off_top = pos; |
| 2675 |
GScrollBarSetPos(att->vsb,pos); |
| 2676 |
GDrawRequestExpose(att->v,NULL,false); |
| 2677 |
return( true ); |
| 2678 |
case GK_Left: case GK_KP_Left: |
| 2679 |
ATTChangeCurrent(att,att->current->parent); |
| 2680 |
return( true ); |
| 2681 |
case GK_Right: case GK_KP_Right: |
| 2682 |
if ( !att->current->open ) { |
| 2683 |
att->current->open = !att->current->open; |
| 2684 |
|
| 2685 |
att->open_cnt = SizeCnt(att,att->tables,0); |
| 2686 |
GScrollBarSetBounds(att->vsb,0,att->open_cnt,att->lines_page); |
| 2687 |
if ( att->current->children!=NULL ) |
| 2688 |
att->current = att->current->children; |
| 2689 |
|
| 2690 |
GDrawRequestExpose(att->v,NULL,false); |
| 2691 |
} else |
| 2692 |
ATTChangeCurrent(att,att->current->children); |
| 2693 |
return( true ); |
| 2694 |
case GK_Home: case GK_KP_Home: |
| 2695 |
ATTChangeCurrent(att,att->tables); |
| 2696 |
return( true ); |
| 2697 |
case GK_End: case GK_KP_End: |
| 2698 |
ATTChangeCurrent(att,NodeFindLPos(att->tables,att->open_cnt-1,&depth)); |
| 2699 |
return( true ); |
| 2700 |
case 'S': case 's': |
| 2701 |
if ( event->u.mouse.state&ksm_control ) |
| 2702 |
AttSave(att); |
| 2703 |
return( true ); |
| 2704 |
} |
| 2705 |
return( false ); |
| 2706 |
} |
| 2707 |
|
| 2708 |
static int attv_e_h(GWindow gw, GEvent *event) { |
| 2709 |
struct att_dlg *att = (struct att_dlg *) GDrawGetUserData(gw); |
| 2710 |
|
| 2711 |
if (( event->type==et_mouseup || event->type==et_mousedown ) && |
| 2712 |
(event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { |
| 2713 |
return( GGadgetDispatchEvent(att->vsb,event)); |
| 2714 |
} |
| 2715 |
|
| 2716 |
switch ( event->type ) { |
| 2717 |
case et_expose: |
| 2718 |
AttExpose(att,gw,&event->u.expose.rect); |
| 2719 |
break; |
| 2720 |
case et_char: |
| 2721 |
return( AttChar(att,event)); |
| 2722 |
case et_mousedown: |
| 2723 |
case et_mousemove: |
| 2724 |
case et_mouseup: |
| 2725 |
AttMouse(att,event); |
| 2726 |
break; |
| 2727 |
default: break; |
| 2728 |
} |
| 2729 |
return( true ); |
| 2730 |
} |
| 2731 |
|
| 2732 |
static int att_e_h(GWindow gw, GEvent *event) { |
| 2733 |
struct att_dlg *att = (struct att_dlg *) GDrawGetUserData(gw); |
| 2734 |
|
| 2735 |
if (( event->type==et_mouseup || event->type==et_mousedown ) && |
| 2736 |
(event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { |
| 2737 |
return( GGadgetDispatchEvent(att->vsb,event)); |
| 2738 |
} |
| 2739 |
|
| 2740 |
switch ( event->type ) { |
| 2741 |
case et_expose: |
| 2742 |
break; |
| 2743 |
case et_char: |
| 2744 |
return( AttChar(att,event)); |
| 2745 |
break; |
| 2746 |
case et_resize: |
| 2747 |
if ( event->u.resize.sized ) |
| 2748 |
AttResize(att,event); |
| 2749 |
break; |
| 2750 |
case et_controlevent: |
| 2751 |
switch ( event->u.control.subtype ) { |
| 2752 |
case et_scrollbarchange: |
| 2753 |
if ( event->u.control.g == att->vsb ) |
| 2754 |
AttScroll(att,&event->u.control.u.sb); |
| 2755 |
else |
| 2756 |
AttHScroll(att,&event->u.control.u.sb); |
| 2757 |
break; |
| 2758 |
case et_buttonactivate: |
| 2759 |
att->done = true; |
| 2760 |
if ( att->dlg_type==dt_font_comp ) |
| 2761 |
GDrawDestroyWindow(gw); |
| 2762 |
break; |
| 2763 |
default: break; |
| 2764 |
} |
| 2765 |
break; |
| 2766 |
case et_close: |
| 2767 |
att->done = true; |
| 2768 |
if ( att->dlg_type==dt_font_comp ) |
| 2769 |
GDrawDestroyWindow(gw); |
| 2770 |
break; |
| 2771 |
case et_destroy: |
| 2772 |
if ( att!=NULL ) { |
| 2773 |
nodesfree(att->tables); |
| 2774 |
free(att); |
| 2775 |
} |
| 2776 |
default: break; |
| 2777 |
} |
| 2778 |
return( true ); |
| 2779 |
} |
| 2780 |
|
| 2781 |
static void ShowAttCreateDlg(struct att_dlg *att, SplineFont *sf, int which, |
| 2782 |
char *win_title) { |
| 2783 |
GRect pos; |
| 2784 |
GWindowAttrs wattrs; |
| 2785 |
int as, ds, ld; |
| 2786 |
GGadgetCreateData gcd[5]; |
| 2787 |
GTextInfo label[4]; |
| 2788 |
int sbsize = GDrawPointsToPixels(NULL,_GScrollBar_Width); |
| 2789 |
|
| 2790 |
if ( sf->cidmaster ) sf = sf->cidmaster; |
| 2791 |
|
| 2792 |
memset( att,0,sizeof(*att)); |
| 2793 |
att->sf = sf; |
| 2794 |
att->dlg_type = which; |
| 2795 |
|
| 2796 |
memset(&wattrs,0,sizeof(wattrs)); |
| 2797 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict; |
| 2798 |
wattrs.event_masks = ~(1<<et_charup); |
| 2799 |
wattrs.is_dlg = true; |
| 2800 |
wattrs.restrict_input_to_me = which==dt_show_att; |
| 2801 |
wattrs.undercursor = 1; |
| 2802 |
wattrs.cursor = ct_pointer; |
| 2803 |
wattrs.utf8_window_title = win_title; |
| 2804 |
pos.x = pos.y = 0; |
| 2805 |
pos.width = GDrawPointsToPixels(NULL,GGadgetScale(which==0?200:450)); |
| 2806 |
pos.height = GDrawPointsToPixels(NULL,300); |
| 2807 |
att->gw = GDrawCreateTopWindow(NULL,&pos,att_e_h,att,&wattrs); |
| 2808 |
|
| 2809 |
att->font = showatt_font.fi; |
| 2810 |
att->monofont = showatt_monofont.fi; |
| 2811 |
GDrawWindowFontMetrics(att->gw,att->font,&as,&ds,&ld); |
| 2812 |
att->fh = as+ds; att->as = as; |
| 2813 |
|
| 2814 |
att->bmargin = GDrawPointsToPixels(NULL,32)+sbsize; |
| 2815 |
|
| 2816 |
att->lines_page = (pos.height-att->bmargin)/att->fh; |
| 2817 |
att->page_width = pos.width-sbsize; |
| 2818 |
wattrs.mask = wam_events|wam_cursor; |
| 2819 |
wattrs.border_width = 1; |
| 2820 |
wattrs.border_color = GDrawGetDefaultForeground(NULL); |
| 2821 |
pos.x = 0; pos.y = 0; |
| 2822 |
pos.width -= sbsize; pos.height = att->lines_page*att->fh; |
| 2823 |
att->v = GWidgetCreateSubWindow(att->gw,&pos,attv_e_h,att,&wattrs); |
| 2824 |
GDrawSetVisible(att->v,true); |
| 2825 |
|
| 2826 |
memset(&label,0,sizeof(label)); |
| 2827 |
memset(&gcd,0,sizeof(gcd)); |
| 2828 |
|
| 2829 |
gcd[0].gd.pos.x = pos.width; gcd[0].gd.pos.y = 0; |
| 2830 |
gcd[0].gd.pos.width = sbsize; |
| 2831 |
gcd[0].gd.pos.height = pos.height; |
| 2832 |
gcd[0].gd.flags = gg_visible | gg_enabled | gg_pos_in_pixels | gg_sb_vert; |
| 2833 |
gcd[0].creator = GScrollBarCreate; |
| 2834 |
|
| 2835 |
gcd[1].gd.pos.x = 0; gcd[1].gd.pos.y = pos.height; |
| 2836 |
gcd[1].gd.pos.height = sbsize; |
| 2837 |
gcd[1].gd.pos.width = pos.width; |
| 2838 |
gcd[1].gd.flags = gg_visible | gg_enabled | gg_pos_in_pixels; |
| 2839 |
gcd[1].creator = GScrollBarCreate; |
| 2840 |
|
| 2841 |
gcd[2].gd.pos.width = -1; |
| 2842 |
gcd[2].gd.pos.x = (pos.width-sbsize-GIntGetResource(_NUM_Buttonsize)*100/GIntGetResource(_NUM_ScaleFactor))/2; |
| 2843 |
gcd[2].gd.pos.y = pos.height+sbsize+5; |
| 2844 |
gcd[2].gd.flags = gg_visible | gg_enabled | gg_but_default | gg_but_cancel | gg_pos_in_pixels; |
| 2845 |
label[2].text = (unichar_t *) _("_OK"); |
| 2846 |
label[2].text_is_1byte = true; |
| 2847 |
label[2].text_in_resource = true; |
| 2848 |
gcd[2].gd.label = &label[2]; |
| 2849 |
gcd[2].creator = GButtonCreate; |
| 2850 |
|
| 2851 |
GGadgetsCreate(att->gw,gcd); |
| 2852 |
att->vsb = gcd[0].ret; |
| 2853 |
att->hsb = gcd[1].ret; |
| 2854 |
att->cancel = gcd[2].ret; |
| 2855 |
} |
| 2856 |
|
| 2857 |
void ShowAtt(SplineFont *sf,int def_layer) { |
| 2858 |
struct att_dlg att; |
| 2859 |
|
| 2860 |
ShowAttCreateDlg(&att, sf, 0, _("Show ATT")); |
| 2861 |
att.def_layer = def_layer; |
| 2862 |
|
| 2863 |
BuildTop(&att); |
| 2864 |
att.open_cnt = SizeCnt(&att,att.tables,0); |
| 2865 |
GScrollBarSetBounds(att.vsb,0,att.open_cnt,att.lines_page); |
| 2866 |
|
| 2867 |
GDrawSetVisible(att.gw,true); |
| 2868 |
|
| 2869 |
while ( !att.done ) |
| 2870 |
GDrawProcessOneEvent(NULL); |
| 2871 |
GDrawSetUserData(att.gw,NULL); |
| 2872 |
nodesfree(att.tables); |
| 2873 |
GDrawDestroyWindow(att.gw); |
| 2874 |
} |
| 2875 |
|
| 2876 |
|
| 2877 |
|
| 2878 |
|
| 2879 |
|
| 2880 |
struct nested_file { |
| 2881 |
FILE *file; |
| 2882 |
char *linebuf; |
| 2883 |
int linemax; |
| 2884 |
int read_nest; |
| 2885 |
}; |
| 2886 |
|
| 2887 |
static int ReadNestedLine(struct nested_file *nf) { |
| 2888 |
char *pt, *end; |
| 2889 |
int ch; |
| 2890 |
int nest = 0; |
| 2891 |
|
| 2892 |
pt = nf->linebuf; end = pt + nf->linemax-1; |
| 2893 |
while ( (ch=getc(nf->file))==' ' ) |
| 2894 |
++nest; |
| 2895 |
if ( ch==EOF ) { |
| 2896 |
nf->read_nest = -1; |
| 2897 |
return( -1 ); |
| 2898 |
} |
| 2899 |
while ( ch!=EOF && ch!='\n' ) { |
| 2900 |
if ( pt>=end ) { |
| 2901 |
char *old = nf->linebuf; |
| 2902 |
nf->linemax += 200; |
| 2903 |
nf->linebuf = realloc(nf->linebuf, nf->linemax); |
| 2904 |
pt = nf->linebuf + (pt-old); |
| 2905 |
end = nf->linebuf + nf->linemax - 1; |
| 2906 |
} |
| 2907 |
*pt++ = ch; |
| 2908 |
ch = getc(nf->file); |
| 2909 |
} |
| 2910 |
*pt = '\0'; |
| 2911 |
nf->read_nest = nest; |
| 2912 |
return( nest ); |
| 2913 |
} |
| 2914 |
|
| 2915 |
static void ReadKids(struct nested_file *nf,int desired_nest,struct node *parent) { |
| 2916 |
int i=0, max=0, j, k; |
| 2917 |
|
| 2918 |
ReadNestedLine(nf); |
| 2919 |
for (;;) { |
| 2920 |
if ( nf->read_nest < desired_nest ) |
| 2921 |
break; |
| 2922 |
if ( i>=max-1 ) { |
| 2923 |
parent->children = realloc(parent->children,(max+=10)*sizeof( struct node )); |
| 2924 |
memset(parent->children+i,0,(max-i)*sizeof(struct node)); |
| 2925 |
} |
| 2926 |
parent->children[i].label = copy(nf->linebuf); |
| 2927 |
parent->children[i].parent = parent; |
| 2928 |
ReadKids(nf,desired_nest+1,&parent->children[i]); |
| 2929 |
++i; |
| 2930 |
} |
| 2931 |
if ( i!=0 ) { |
| 2932 |
if ( i<max-1 ) |
| 2933 |
parent->children = realloc(parent->children,(i+1)*sizeof(struct node)); |
| 2934 |
|
| 2935 |
for ( j=0; j<i; ++j ) |
| 2936 |
for ( k=0; k<parent->children[j].cnt; ++k ) |
| 2937 |
parent->children[j].children[k].parent = &parent->children[j]; |
| 2938 |
parent->cnt = i; |
| 2939 |
} |
| 2940 |
} |
| 2941 |
|
| 2942 |
static void BuildFCmpNodes(struct att_dlg *att, SplineFont *sf1, SplineFont *sf2,int flags) { |
| 2943 |
FILE *tmp = GFileTmpfile(); |
| 2944 |
struct node *tables; |
| 2945 |
struct nested_file nf; |
| 2946 |
|
| 2947 |
att->tables = tables = calloc(2,sizeof(struct node)); |
| 2948 |
att->current = tables; |
| 2949 |
if ( !CompareFonts(sf1,att->fv1->b.map,sf2,tmp,flags) && ftell(tmp)==0 ) { |
| 2950 |
tables[0].label = copy(_("No differences found")); |
| 2951 |
} else { |
| 2952 |
tables[0].label = copy(_("Differences...")); |
| 2953 |
rewind(tmp); |
| 2954 |
memset(&nf,0,sizeof(nf)); |
| 2955 |
nf.file = tmp; |
| 2956 |
nf.linebuf = malloc( nf.linemax = 300 ); |
| 2957 |
ReadKids(&nf,0,&tables[0]); |
| 2958 |
free(nf.linebuf); |
| 2959 |
} |
| 2960 |
fclose(tmp); |
| 2961 |
} |
| 2962 |
|
| 2963 |
static void FontCmpDlg(FontView *fv1, FontView *fv2,int flags) { |
| 2964 |
struct att_dlg *att; |
| 2965 |
char buffer[300]; |
| 2966 |
SplineFont *sf1 = fv1->b.sf, *sf2=fv2->b.sf; |
| 2967 |
|
| 2968 |
if ( strcmp(sf1->fontname,sf2->fontname)!=0 ) |
| 2969 |
snprintf( buffer, sizeof(buffer), _("Compare %s to %s"), sf1->fontname, sf2->fontname); |
| 2970 |
else if ( sf1->version!=NULL && sf2->version!=NULL && |
| 2971 |
strcmp(sf1->version,sf2->version)!=0 ) |
| 2972 |
snprintf( buffer, sizeof(buffer), _("Compare version %s of %s to %s"), |
| 2973 |
sf1->version, sf1->fontname, sf2->version); |
| 2974 |
else |
| 2975 |
strcpy( buffer, _("Font Compare")); |
| 2976 |
|
| 2977 |
att = malloc(sizeof(struct att_dlg)); |
| 2978 |
ShowAttCreateDlg(att, sf1, dt_font_comp, buffer); |
| 2979 |
att->fv1 = fv1; att->fv2 = fv2; |
| 2980 |
|
| 2981 |
GDrawSetCursor(fv1->v,ct_watch); |
| 2982 |
GDrawSetCursor(fv2->v,ct_watch); |
| 2983 |
BuildFCmpNodes(att,sf1,sf2,flags); |
| 2984 |
GDrawSetCursor(fv1->v,ct_pointer); |
| 2985 |
GDrawSetCursor(fv2->v,ct_pointer); |
| 2986 |
|
| 2987 |
att->open_cnt = SizeCnt(att,att->tables,0); |
| 2988 |
GScrollBarSetBounds(att->vsb,0,att->open_cnt,att->lines_page); |
| 2989 |
|
| 2990 |
GDrawSetVisible(att->gw,true); |
| 2991 |
} |
| 2992 |
|
| 2993 |
static void FCAskFilename(FontView *fv,int flags) { |
| 2994 |
char *filename = GetPostScriptFontName(NULL,false,true); |
| 2995 |
FontView *otherfv; |
| 2996 |
|
| 2997 |
if ( filename==NULL ) |
| 2998 |
return; |
| 2999 |
otherfv = (FontView *) ViewPostScriptFont(filename,0); |
| 3000 |
free(filename); filename = NULL; |
| 3001 |
if ( otherfv==NULL ) |
| 3002 |
return; |
| 3003 |
FontCmpDlg(fv,otherfv,flags); |
| 3004 |
} |
| 3005 |
|
| 3006 |
struct mf_data { |
| 3007 |
int done; |
| 3008 |
FontView *fv; |
| 3009 |
GGadget *other; |
| 3010 |
GGadget *amount; |
| 3011 |
}; |
| 3012 |
#define CID_Outlines 1 |
| 3013 |
#define CID_Exact 2 |
| 3014 |
#define CID_Warn 3 |
| 3015 |
#define CID_Fuzzy 4 |
| 3016 |
#define CID_Hinting 5 |
| 3017 |
#define CID_Bitmaps 6 |
| 3018 |
#define CID_Names 7 |
| 3019 |
#define CID_GPos 8 |
| 3020 |
#define CID_GSub 9 |
| 3021 |
#define CID_HintMasks 10 |
| 3022 |
#define CID_HintMasksWConflicts 11 |
| 3023 |
#define CID_NoHintMasks 12 |
| 3024 |
#define CID_RefContourWarn 13 |
| 3025 |
#define CID_AddDiffs 14 |
| 3026 |
#define CID_AddMissing 15 |
| 3027 |
|
| 3028 |
static int last_flags = fcf_outlines|fcf_hinting|fcf_bitmaps|fcf_names|fcf_gpos|fcf_gsub|fcf_adddiff2sf1; |
| 3029 |
|
| 3030 |
static int FC_OK(GGadget *g, GEvent *e) { |
| 3031 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 3032 |
GWindow gw = GGadgetGetWindow(g); |
| 3033 |
struct mf_data *d = GDrawGetUserData(gw); |
| 3034 |
int i, index = GGadgetGetFirstListSelectedItem(d->other); |
| 3035 |
FontView *fv; |
| 3036 |
int flags = 0; |
| 3037 |
for ( i=0, fv=fv_list; fv!=NULL; fv=(FontView *) (fv->b.next) ) { |
| 3038 |
if ( fv==d->fv ) |
| 3039 |
continue; |
| 3040 |
if ( i==index ) |
| 3041 |
break; |
| 3042 |
++i; |
| 3043 |
} |
| 3044 |
|
| 3045 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Outlines)) ) |
| 3046 |
flags |= fcf_outlines; |
| 3047 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Exact)) ) |
| 3048 |
flags |= fcf_exact; |
| 3049 |
else if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Warn)) ) |
| 3050 |
flags |= fcf_warn_not_exact; |
| 3051 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_RefContourWarn)) ) |
| 3052 |
flags |= fcf_warn_not_ref_exact; |
| 3053 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Hinting)) ) |
| 3054 |
flags |= fcf_hinting; |
| 3055 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_HintMasks)) ) |
| 3056 |
flags |= fcf_hintmasks; |
| 3057 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_HintMasksWConflicts)) ) |
| 3058 |
flags |= fcf_hmonlywithconflicts|fcf_hintmasks; |
| 3059 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Bitmaps)) ) |
| 3060 |
flags |= fcf_bitmaps; |
| 3061 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_Names)) ) |
| 3062 |
flags |= fcf_names; |
| 3063 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_GPos)) ) |
| 3064 |
flags |= fcf_gpos; |
| 3065 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_GSub)) ) |
| 3066 |
flags |= fcf_gsub; |
| 3067 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_AddDiffs)) ) |
| 3068 |
flags |= fcf_adddiff2sf1; |
| 3069 |
if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_AddMissing)) ) |
| 3070 |
flags |= fcf_addmissing; |
| 3071 |
last_flags = flags; |
| 3072 |
|
| 3073 |
GDrawDestroyWindow(gw); |
| 3074 |
if ( fv==NULL ) |
| 3075 |
FCAskFilename(d->fv,flags); |
| 3076 |
else |
| 3077 |
FontCmpDlg(d->fv,fv,flags); |
| 3078 |
d->done = true; |
| 3079 |
} |
| 3080 |
return( true ); |
| 3081 |
} |
| 3082 |
|
| 3083 |
static int FC_Cancel(GGadget *g, GEvent *e) { |
| 3084 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 3085 |
GWindow gw = GGadgetGetWindow(g); |
| 3086 |
struct mf_data *d = GDrawGetUserData(gw); |
| 3087 |
d->done = true; |
| 3088 |
GDrawDestroyWindow(gw); |
| 3089 |
} |
| 3090 |
return( true ); |
| 3091 |
} |
| 3092 |
|
| 3093 |
static int fc_e_h(GWindow gw, GEvent *event) { |
| 3094 |
if ( event->type==et_close ) { |
| 3095 |
struct mf_data *d = GDrawGetUserData(gw); |
| 3096 |
d->done = true; |
| 3097 |
GDrawDestroyWindow(gw); |
| 3098 |
} else if ( event->type == et_char ) { |
| 3099 |
return( false ); |
| 3100 |
} |
| 3101 |
return( true ); |
| 3102 |
} |
| 3103 |
|
| 3104 |
void FontCompareDlg(FontView *fv) { |
| 3105 |
GRect pos; |
| 3106 |
GWindow gw; |
| 3107 |
GWindowAttrs wattrs; |
| 3108 |
GGadgetCreateData gcd[25]; |
| 3109 |
GTextInfo label[25]; |
| 3110 |
struct mf_data d; |
| 3111 |
char buffer[80]; |
| 3112 |
int k; |
| 3113 |
|
| 3114 |
memset(&wattrs,0,sizeof(wattrs)); |
| 3115 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_restrict|wam_isdlg; |
| 3116 |
wattrs.event_masks = ~(1<<et_charup); |
| 3117 |
wattrs.restrict_input_to_me = 1; |
| 3118 |
wattrs.is_dlg = 1; |
| 3119 |
wattrs.undercursor = 1; |
| 3120 |
wattrs.cursor = ct_pointer; |
| 3121 |
wattrs.utf8_window_title = _("Font Compare"); |
| 3122 |
pos.x = pos.y = 0; |
| 3123 |
pos.width = GGadgetScale(GDrawPointsToPixels(NULL,180)); |
| 3124 |
pos.height = GDrawPointsToPixels(NULL,88+15*14+2); |
| 3125 |
gw = GDrawCreateTopWindow(NULL,&pos,fc_e_h,&d,&wattrs); |
| 3126 |
|
| 3127 |
memset(&label,0,sizeof(label)); |
| 3128 |
memset(&gcd,0,sizeof(gcd)); |
| 3129 |
|
| 3130 |
k=0; |
| 3131 |
sprintf( buffer, _("Font to compare with %.20s"), fv->b.sf->fontname ); |
| 3132 |
label[k].text = (unichar_t *) buffer; |
| 3133 |
label[k].text_is_1byte = true; |
| 3134 |
gcd[k].gd.label = &label[k]; |
| 3135 |
gcd[k].gd.pos.x = 12; gcd[k].gd.pos.y = 6; |
| 3136 |
gcd[k].gd.flags = gg_visible | gg_enabled; |
| 3137 |
gcd[k++].creator = GLabelCreate; |
| 3138 |
|
| 3139 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = 21; |
| 3140 |
gcd[k].gd.pos.width = 145; |
| 3141 |
gcd[k].gd.flags = gg_visible | gg_enabled; |
| 3142 |
gcd[k].gd.u.list = BuildFontList(fv); |
| 3143 |
gcd[k].gd.label = &gcd[k].gd.u.list[0]; |
| 3144 |
gcd[k].gd.u.list[0].selected = true; |
| 3145 |
gcd[k++].creator = GListButtonCreate; |
| 3146 |
|
| 3147 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+24; |
| 3148 |
if ( fv->b.sf->onlybitmaps ) |
| 3149 |
gcd[k].gd.flags = gg_visible; |
| 3150 |
else |
| 3151 |
gcd[k].gd.flags = gg_visible | gg_enabled | ((last_flags&fcf_outlines)?gg_cb_on:0); |
| 3152 |
label[k].text = (unichar_t *) _("Compare _Outlines"); |
| 3153 |
label[k].text_is_1byte = true; |
| 3154 |
label[k].text_in_resource = true; |
| 3155 |
gcd[k].gd.label = &label[k]; |
| 3156 |
gcd[k].gd.cid = CID_Outlines; |
| 3157 |
gcd[k++].creator = GCheckBoxCreate; |
| 3158 |
|
| 3159 |
gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3160 |
if ( fv->b.sf->onlybitmaps ) |
| 3161 |
gcd[k].gd.flags = gg_visible; |
| 3162 |
else |
| 3163 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_exact)?gg_cb_on:0); |
| 3164 |
label[k].text = (unichar_t *) _("_Exact"); |
| 3165 |
label[k].text_is_1byte = true; |
| 3166 |
label[k].text_in_resource = true; |
| 3167 |
gcd[k].gd.label = &label[k]; |
| 3168 |
gcd[k].gd.cid = CID_Exact; |
| 3169 |
gcd[k].gd.popup_msg = _("Accept outlines which exactly match the original"); |
| 3170 |
gcd[k++].creator = GRadioCreate; |
| 3171 |
|
| 3172 |
gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3173 |
if ( fv->b.sf->onlybitmaps ) |
| 3174 |
gcd[k].gd.flags = gg_visible; |
| 3175 |
else |
| 3176 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_exact)?0:gg_cb_on); |
| 3177 |
label[k].text = (unichar_t *) _("_Accept inexact"); |
| 3178 |
label[k].text_is_1byte = true; |
| 3179 |
label[k].text_in_resource = true; |
| 3180 |
gcd[k].gd.label = &label[k]; |
| 3181 |
gcd[k].gd.cid = CID_Fuzzy; |
| 3182 |
gcd[k].gd.popup_msg = _("Accept an outline which is a close approximation to the original.\nIt may be off by an em-unit, or have a reference which matches a contour."); |
| 3183 |
gcd[k++].creator = GRadioCreate; |
| 3184 |
|
| 3185 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3186 |
if ( fv->b.sf->onlybitmaps ) |
| 3187 |
gcd[k].gd.flags = gg_visible; |
| 3188 |
else |
| 3189 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_warn_not_exact)?gg_cb_on:0); |
| 3190 |
label[k].text = (unichar_t *) _("_Warn if inexact"); |
| 3191 |
label[k].text_is_1byte = true; |
| 3192 |
label[k].text_in_resource = true; |
| 3193 |
gcd[k].gd.label = &label[k]; |
| 3194 |
gcd[k].gd.cid = CID_Warn; |
| 3195 |
gcd[k].gd.popup_msg = _("Warn if the outlines are close but not exactly the same"); |
| 3196 |
gcd[k++].creator = GCheckBoxCreate; |
| 3197 |
|
| 3198 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3199 |
if ( fv->b.sf->onlybitmaps ) |
| 3200 |
gcd[k].gd.flags = gg_visible; |
| 3201 |
else |
| 3202 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_warn_not_ref_exact)?gg_cb_on:0); |
| 3203 |
label[k].text = (unichar_t *) _("Warn if _unlinked references"); |
| 3204 |
label[k].text_is_1byte = true; |
| 3205 |
label[k].text_in_resource = true; |
| 3206 |
gcd[k].gd.label = &label[k]; |
| 3207 |
gcd[k].gd.cid = CID_RefContourWarn; |
| 3208 |
gcd[k].gd.popup_msg = _("Warn if one glyph contains an outline while the other contains a reference (but the reference describes the same outline)"); |
| 3209 |
gcd[k++].creator = GCheckBoxCreate; |
| 3210 |
|
| 3211 |
gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3212 |
if ( fv->b.sf->onlybitmaps ) |
| 3213 |
gcd[k].gd.flags = gg_visible; |
| 3214 |
else |
| 3215 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_hinting)?gg_cb_on:0); |
| 3216 |
label[k].text = (unichar_t *) _("Compare _Hints"); |
| 3217 |
label[k].text_is_1byte = true; |
| 3218 |
label[k].text_in_resource = true; |
| 3219 |
gcd[k].gd.label = &label[k]; |
| 3220 |
gcd[k].gd.cid = CID_Hinting; |
| 3221 |
gcd[k].gd.popup_msg = _("Compare postscript hints and hintmasks and truetype instructions"); |
| 3222 |
gcd[k++].creator = GCheckBoxCreate; |
| 3223 |
|
| 3224 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3225 |
if ( fv->b.sf->onlybitmaps ) |
| 3226 |
gcd[k].gd.flags = gg_visible; |
| 3227 |
else |
| 3228 |
gcd[k].gd.flags = gg_visible | gg_enabled| (((last_flags&fcf_hintmasks) && !(last_flags&fcf_hmonlywithconflicts))?gg_cb_on:0); |
| 3229 |
label[k].text = (unichar_t *) _("Compare Hint_Masks"); |
| 3230 |
label[k].text_is_1byte = true; |
| 3231 |
label[k].text_in_resource = true; |
| 3232 |
gcd[k].gd.label = &label[k]; |
| 3233 |
gcd[k].gd.cid = CID_HintMasks; |
| 3234 |
gcd[k].gd.popup_msg = _("Compare hintmasks"); |
| 3235 |
gcd[k++].creator = GRadioCreate; |
| 3236 |
|
| 3237 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3238 |
if ( fv->b.sf->onlybitmaps ) |
| 3239 |
gcd[k].gd.flags = gg_visible; |
| 3240 |
else |
| 3241 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_hmonlywithconflicts)?gg_cb_on:0); |
| 3242 |
label[k].text = (unichar_t *) _("HintMasks only if conflicts"); |
| 3243 |
label[k].text_is_1byte = true; |
| 3244 |
label[k].text_in_resource = true; |
| 3245 |
gcd[k].gd.label = &label[k]; |
| 3246 |
gcd[k].gd.cid = CID_HintMasksWConflicts; |
| 3247 |
gcd[k].gd.popup_msg = _("Don't compare hintmasks if the glyph has no hint conflicts"); |
| 3248 |
gcd[k++].creator = GRadioCreate; |
| 3249 |
|
| 3250 |
gcd[k].gd.pos.x = 15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3251 |
if ( fv->b.sf->onlybitmaps ) |
| 3252 |
gcd[k].gd.flags = gg_visible ; |
| 3253 |
else |
| 3254 |
gcd[k].gd.flags = gg_visible | gg_enabled | ((last_flags&fcf_hintmasks)?0:gg_cb_on); |
| 3255 |
label[k].text = (unichar_t *) _("Don't Compare HintMasks"); |
| 3256 |
label[k].text_is_1byte = true; |
| 3257 |
label[k].text_in_resource = true; |
| 3258 |
gcd[k].gd.label = &label[k]; |
| 3259 |
gcd[k].gd.cid = CID_NoHintMasks; |
| 3260 |
gcd[k++].creator = GRadioCreate; |
| 3261 |
|
| 3262 |
gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3263 |
if ( fv->b.sf->onlybitmaps ) |
| 3264 |
gcd[k].gd.flags = gg_visible; |
| 3265 |
else |
| 3266 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_adddiff2sf1)?gg_cb_on:0); |
| 3267 |
label[k].text = (unichar_t *) _("_Add Diff Outlines to Background"); |
| 3268 |
label[k].text_is_1byte = true; |
| 3269 |
label[k].text_in_resource = true; |
| 3270 |
gcd[k].gd.label = &label[k]; |
| 3271 |
gcd[k].gd.cid = CID_AddDiffs; |
| 3272 |
gcd[k].gd.popup_msg = _("If two glyphs differ, then add the outlines of the second glyph\nto the background layer of the first (So when opening the first\nthe differences will be visible)."); |
| 3273 |
gcd[k++].creator = GCheckBoxCreate; |
| 3274 |
|
| 3275 |
gcd[k].gd.pos.x = 10; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3276 |
if ( fv->b.sf->onlybitmaps ) |
| 3277 |
gcd[k].gd.flags = gg_visible; |
| 3278 |
else |
| 3279 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_addmissing)?gg_cb_on:0); |
| 3280 |
label[k].text = (unichar_t *) _("Add _Missing Glyphs"); |
| 3281 |
label[k].text_is_1byte = true; |
| 3282 |
label[k].text_in_resource = true; |
| 3283 |
gcd[k].gd.label = &label[k]; |
| 3284 |
gcd[k].gd.cid = CID_AddMissing; |
| 3285 |
gcd[k].gd.popup_msg = _("If a glyph in the second font is missing from the first, then\nadd it to the first with the outlines of the second font in\nthe background"); |
| 3286 |
gcd[k++].creator = GCheckBoxCreate; |
| 3287 |
|
| 3288 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+16; |
| 3289 |
if ( fv->b.sf->bitmaps==NULL ) |
| 3290 |
gcd[k].gd.flags = gg_visible; |
| 3291 |
else |
| 3292 |
gcd[k].gd.flags = gg_visible | gg_enabled | ((last_flags&fcf_bitmaps)?gg_cb_on:0); |
| 3293 |
label[k].text = (unichar_t *) _("Compare _Bitmaps"); |
| 3294 |
label[k].text_is_1byte = true; |
| 3295 |
label[k].text_in_resource = true; |
| 3296 |
gcd[k].gd.label = &label[k]; |
| 3297 |
gcd[k].gd.cid = CID_Bitmaps; |
| 3298 |
gcd[k++].creator = GCheckBoxCreate; |
| 3299 |
|
| 3300 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3301 |
gcd[k].gd.flags = gg_visible | gg_enabled | ((last_flags&fcf_names)?gg_cb_on:0); |
| 3302 |
label[k].text = (unichar_t *) _("Compare _Names"); |
| 3303 |
label[k].text_is_1byte = true; |
| 3304 |
label[k].text_in_resource = true; |
| 3305 |
gcd[k].gd.label = &label[k]; |
| 3306 |
gcd[k].gd.cid = CID_Names; |
| 3307 |
gcd[k++].creator = GCheckBoxCreate; |
| 3308 |
|
| 3309 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3310 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_gpos)?gg_cb_on:0); |
| 3311 |
label[k].text = (unichar_t *) _("Compare Glyph _Positioning"); |
| 3312 |
label[k].text_is_1byte = true; |
| 3313 |
label[k].text_in_resource = true; |
| 3314 |
gcd[k].gd.label = &label[k]; |
| 3315 |
gcd[k].gd.cid = CID_GPos; |
| 3316 |
gcd[k].gd.popup_msg = _("Kerning & such"); |
| 3317 |
gcd[k++].creator = GCheckBoxCreate; |
| 3318 |
|
| 3319 |
gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+14; |
| 3320 |
gcd[k].gd.flags = gg_visible | gg_enabled| ((last_flags&fcf_gsub)?gg_cb_on:0); |
| 3321 |
label[k].text = (unichar_t *) _("Compare Glyph _Substitution"); |
| 3322 |
label[k].text_is_1byte = true; |
| 3323 |
label[k].text_in_resource = true; |
| 3324 |
gcd[k].gd.label = &label[k]; |
| 3325 |
gcd[k].gd.cid = CID_GSub; |
| 3326 |
gcd[k].gd.popup_msg = _("Ligatures & such"); |
| 3327 |
gcd[k++].creator = GCheckBoxCreate; |
| 3328 |
|
| 3329 |
gcd[k].gd.pos.x = 15-3; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+23-3; |
| 3330 |
gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0; |
| 3331 |
gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_default; |
| 3332 |
label[k].text = (unichar_t *) _("_OK"); |
| 3333 |
label[k].text_is_1byte = true; |
| 3334 |
label[k].text_in_resource = true; |
| 3335 |
gcd[k].gd.label = &label[k]; |
| 3336 |
gcd[k].gd.handle_controlevent = FC_OK; |
| 3337 |
gcd[k++].creator = GButtonCreate; |
| 3338 |
|
| 3339 |
gcd[k].gd.pos.x = -15; gcd[k].gd.pos.y = gcd[k-1].gd.pos.y+3; |
| 3340 |
gcd[k].gd.pos.width = -1; gcd[k].gd.pos.height = 0; |
| 3341 |
gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel; |
| 3342 |
label[k].text = (unichar_t *) _("_Cancel"); |
| 3343 |
label[k].text_is_1byte = true; |
| 3344 |
label[k].text_in_resource = true; |
| 3345 |
gcd[k].gd.label = &label[k]; |
| 3346 |
gcd[k].gd.handle_controlevent = FC_Cancel; |
| 3347 |
gcd[k++].creator = GButtonCreate; |
| 3348 |
|
| 3349 |
gcd[k].gd.pos.x = 2; gcd[k].gd.pos.y = 2; |
| 3350 |
gcd[k].gd.pos.width = pos.width-4; gcd[k].gd.pos.height = pos.height-2; |
| 3351 |
gcd[k].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels; |
| 3352 |
gcd[k++].creator = GGroupCreate; |
| 3353 |
|
| 3354 |
GGadgetsCreate(gw,gcd); |
| 3355 |
|
| 3356 |
memset(&d,'\0',sizeof(d)); |
| 3357 |
d.other = gcd[1].ret; |
| 3358 |
d.fv = fv; |
| 3359 |
|
| 3360 |
GDrawSetVisible(gw,true); |
| 3361 |
while ( !d.done ) |
| 3362 |
GDrawProcessOneEvent(NULL); |
| 3363 |
TFFree(gcd[1].gd.u.list); |
| 3364 |
} |