13
31
#include "pfaedit.h"
14
32
#include "ustring.h"
34
static const char __svn_version[] =
35
"$Id: luafflib.c 3187 2009-11-22 22:29:05Z oneiros $ "
36
"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.50.0/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c $";
16
38
extern char **gww_errors;
17
39
extern int gww_error_count;
18
extern void gwwv_errors_free (void);
40
extern void gwwv_errors_free(void);
19
41
extern struct ui_interface luaui_interface;
21
extern int readbinfile(FILE *f, unsigned char **b, int *s);
43
extern int readbinfile(FILE * f, unsigned char **b, int *s);
23
45
#define FONT_METATABLE "fontloader.splinefont"
25
47
#define LUA_OTF_VERSION "0.3"
27
static char *possub_type_enum[] = {
28
"null", "position", "pair", "substitution",
29
"alternate", "multiple", "ligature", "lcaret",
30
"kerning", "vkerning", "anchors", "contextpos",
31
"contextsub", "chainpos", "chainsub","reversesub",
32
"max", "kernback", "vkernback", NULL };
49
static char *possub_type_enum[] = {
50
"null", "position", "pair", "substitution",
51
"alternate", "multiple", "ligature", "lcaret",
52
"kerning", "vkerning", "anchors", "contextpos",
53
"contextsub", "chainpos", "chainsub", "reversesub",
54
"max", "kernback", "vkernback", NULL
34
57
#define LAST_POSSUB_TYPE_ENUM 18
36
59
#define eight_nulls() NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
38
static char *asm_type_enum[] = {
39
"indic", "context", "lig", NULL, "simple", "insert", NULL, NULL,
43
static char *otf_lookup_type_enum[] = {
44
"gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate",
45
"gsub_ligature", "gsub_context", "gsub_contextchain", NULL,
46
"gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */
47
eight_nulls(),eight_nulls(),
48
eight_nulls(),eight_nulls(),
49
eight_nulls(),eight_nulls(),
50
eight_nulls(),eight_nulls(),
51
eight_nulls(),eight_nulls(),
52
eight_nulls(),eight_nulls(),
53
eight_nulls(),eight_nulls(),
54
eight_nulls(),eight_nulls(),
55
eight_nulls(),eight_nulls(),
56
eight_nulls(),eight_nulls(),
57
eight_nulls(),eight_nulls(),
58
eight_nulls(),eight_nulls(),
59
eight_nulls(),eight_nulls(),
60
eight_nulls(),eight_nulls(),
61
eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF*/
62
"gpos_start", "gpos_single", "gpos_pair", "gpos_cursive",
63
"gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context",
64
"gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */
65
eight_nulls(),eight_nulls(),
66
eight_nulls(),eight_nulls(),
67
eight_nulls(),eight_nulls(),
68
eight_nulls(),eight_nulls(),
69
eight_nulls(),eight_nulls(),
70
eight_nulls(),eight_nulls(),
71
eight_nulls(),eight_nulls(),
72
eight_nulls(),eight_nulls(),
73
eight_nulls(),eight_nulls(),
74
eight_nulls(),eight_nulls(),
75
eight_nulls(),eight_nulls(),
76
eight_nulls(),eight_nulls(),
77
eight_nulls(),eight_nulls(),
78
eight_nulls(),eight_nulls(),
79
eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF*/
83
static char *anchor_type_enum[] = {
84
"mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL };
61
static char *asm_type_enum[] = {
62
"indic", "context", "lig", NULL, "simple", "insert", NULL, NULL,
67
static char *otf_lookup_type_enum[] = {
68
"gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate",
69
"gsub_ligature", "gsub_context", "gsub_contextchain", NULL,
70
"gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */
71
eight_nulls(), eight_nulls(),
72
eight_nulls(), eight_nulls(),
73
eight_nulls(), eight_nulls(),
74
eight_nulls(), eight_nulls(),
75
eight_nulls(), eight_nulls(),
76
eight_nulls(), eight_nulls(),
77
eight_nulls(), eight_nulls(),
78
eight_nulls(), eight_nulls(),
79
eight_nulls(), eight_nulls(),
80
eight_nulls(), eight_nulls(),
81
eight_nulls(), eight_nulls(),
82
eight_nulls(), eight_nulls(),
83
eight_nulls(), eight_nulls(),
84
eight_nulls(), eight_nulls(),
85
eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF */
86
"gpos_start", "gpos_single", "gpos_pair", "gpos_cursive",
87
"gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context",
88
"gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */
89
eight_nulls(), eight_nulls(),
90
eight_nulls(), eight_nulls(),
91
eight_nulls(), eight_nulls(),
92
eight_nulls(), eight_nulls(),
93
eight_nulls(), eight_nulls(),
94
eight_nulls(), eight_nulls(),
95
eight_nulls(), eight_nulls(),
96
eight_nulls(), eight_nulls(),
97
eight_nulls(), eight_nulls(),
98
eight_nulls(), eight_nulls(),
99
eight_nulls(), eight_nulls(),
100
eight_nulls(), eight_nulls(),
101
eight_nulls(), eight_nulls(),
102
eight_nulls(), eight_nulls(),
103
eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF */
107
static char *anchor_type_enum[] = {
108
"mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL
86
111
#define MAX_ANCHOR_TYPE 7
88
static char *anchorclass_type_enum[] = {
89
"mark", "mkmk", "curs", "mklg", NULL };
91
static char *glyph_class_enum[] = {
92
"automatic", "none" ,"base", "ligature","mark", "component", NULL };
94
static char *ttfnames_enum[ttf_namemax] = {
113
static char *anchorclass_type_enum[] = {
114
"mark", "mkmk", "curs", "mklg", NULL
117
static char *glyph_class_enum[] = {
118
"automatic", "none", "base", "ligature", "mark", "component", NULL
121
static char *ttfnames_enum[ttf_namemax] = {
95
122
"copyright", "family", "subfamily", "uniqueid",
96
123
"fullname", "version", "postscriptname", "trademark",
97
124
"manufacturer", "designer", "descriptor", "venderurl",
98
125
"designerurl", "license", "licenseurl", "idontknow",
99
126
"preffamilyname", "prefmodifiers", "compatfull", "sampletext",
100
"cidfindfontname", "wwsfamily", "wwssubfamily" };
102
static char *fpossub_format_enum [] = {
103
"glyphs", "class","coverage","reversecoverage" , NULL};
105
static char *tex_type_enum[4] = { "unset", "text", "math", "mathext"};
127
"cidfindfontname", "wwsfamily", "wwssubfamily"
130
static char *fpossub_format_enum[] = {
131
"glyphs", "class", "coverage", "reversecoverage", NULL
134
static char *tex_type_enum[4] = { "unset", "text", "math", "mathext" };
107
136
/* has an offset of 1, ui_none = 0. */
108
137
static char *uni_interp_enum[9] = {
109
"unset", "none", "adobe", "greek", "japanese",
110
"trad_chinese", "simp_chinese", "korean", "ams" };
138
"unset", "none", "adobe", "greek", "japanese",
139
"trad_chinese", "simp_chinese", "korean", "ams"
112
142
#define check_isfont(L,b) (SplineFont **)luaL_checkudata(L,b,FONT_METATABLE)
114
void handle_generic_pst (lua_State *L, struct generic_pst *pst); /* forward */
115
void handle_generic_fpst (lua_State *L, struct generic_fpst *fpst); /* forward */
116
void handle_generic_asm (lua_State *L, struct generic_asm *sm) ;
117
void handle_kernclass (lua_State *L, struct kernclass *kerns);
118
void handle_anchorclass (lua_State *L, struct anchorclass *anchor);
119
void handle_splinefont(lua_State *L, struct splinefont *sf) ;
123
lua_ff_pushfont(lua_State *L, SplineFont *sf) {
128
a = lua_newuserdata(L,sizeof(SplineFont *));
130
luaL_getmetatable(L,FONT_METATABLE);
131
lua_setmetatable(L,-2);
138
ff_open (lua_State *L) {
140
const char *fontname;
146
fontname = luaL_checkstring(L,1);
147
/* test fontname for existance */
148
if ((l = fopen(fontname,"r"))) {
151
lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname);
154
args = lua_gettop(L);
155
if (args>=2 && lua_isstring(L,2)) {
156
if (*(fontname+strlen(fontname))!=')') {
157
/* possibly fails for embedded parens in the font name */
158
snprintf(s,511,"%s(%s)", fontname, lua_tolstring(L,2,&len));
160
snprintf(s,511,"%s", fontname);
164
snprintf(s,511,"%s", fontname);
168
sf = ReadSplineFont((char *)s,openflags);
170
lua_pushfstring(L,"font loading failed for %s\n", s);
171
if (gww_error_count>0) {
172
for (i=0;i<gww_error_count;i++) {
173
lua_pushstring(L,gww_errors[i]);
180
FVAppend(_FontViewCreate(sf));
181
lua_ff_pushfont(L,sf);
182
if (gww_error_count>0) {
184
for (i=0;i<gww_error_count;i++) {
185
lua_pushstring(L,gww_errors[i]);
186
lua_rawseti(L,-2,(i+1));
194
lua_pushfstring(L,"font loading failed: empty string given\n", fontname);
202
ff_close (lua_State *L) {
204
/*fputs("ff_close called",stderr);*/
205
sf = check_isfont(L,1);
214
ff_apply_featurefile (lua_State *L) {
217
sf = check_isfont(L,1);
218
fname = (char *)luaL_checkstring(L,2);
219
SFApplyFeatureFilename(*sf,fname);
224
ff_apply_afmfile (lua_State *L) {
227
sf = check_isfont(L,1);
228
fname = (char *)luaL_checkstring(L,2);
229
CheckAfmOfPostscript(*sf,fname,(*sf)->map);
237
dump_intfield (lua_State *L, char *name, long int field) {
239
lua_pushstring(L,name);
240
lua_pushnumber(L,field);
245
dump_realfield (lua_State *L, char *name, real field) {
247
lua_pushstring(L,name);
248
lua_pushnumber(L,field);
144
void handle_generic_pst(lua_State * L, struct generic_pst *pst); /* forward */
145
void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst); /* forward */
146
void handle_generic_asm(lua_State * L, struct generic_asm *sm);
147
void handle_kernclass(lua_State * L, struct kernclass *kerns);
148
void handle_anchorclass(lua_State * L, struct anchorclass *anchor);
149
void handle_splinefont(lua_State * L, struct splinefont *sf);
152
void lua_ff_pushfont(lua_State * L, SplineFont * sf)
158
a = lua_newuserdata(L, sizeof(SplineFont *));
160
luaL_getmetatable(L, FONT_METATABLE);
161
lua_setmetatable(L, -2);
167
static int ff_open(lua_State * L)
170
const char *fontname;
176
fontname = luaL_checkstring(L, 1);
177
/* test fontname for existance */
178
if ((l = fopen(fontname, "r"))) {
182
lua_pushfstring(L, "font loading failed for %s (read error)\n",
186
args = lua_gettop(L);
187
if (args >= 2 && lua_isstring(L, 2)) {
188
if (*(fontname + strlen(fontname)) != ')') {
189
/* possibly fails for embedded parens in the font name */
190
snprintf(s, 511, "%s(%s)", fontname, lua_tolstring(L, 2, &len));
192
snprintf(s, 511, "%s", fontname);
196
snprintf(s, 511, "%s", fontname);
200
sf = ReadSplineFont((char *) s, openflags);
203
lua_pushfstring(L, "font loading failed for %s\n", s);
204
if (gww_error_count > 0) {
205
for (i = 0; i < gww_error_count; i++) {
206
lua_pushstring(L, gww_errors[i]);
212
FVAppend(_FontViewCreate(sf));
213
lua_ff_pushfont(L, sf);
214
if (gww_error_count > 0) {
216
for (i = 0; i < gww_error_count; i++) {
217
lua_pushstring(L, gww_errors[i]);
218
lua_rawseti(L, -2, (i + 1));
227
lua_pushfstring(L, "font loading failed: empty string given\n",
234
static int ff_close(lua_State * L)
237
/*fputs("ff_close called",stderr); */
238
sf = check_isfont(L, 1);
246
static int ff_apply_featurefile(lua_State * L)
250
sf = check_isfont(L, 1);
251
fname = (char *) luaL_checkstring(L, 2);
252
SFApplyFeatureFilename(*sf, fname);
256
static int ff_apply_afmfile(lua_State * L)
260
sf = check_isfont(L, 1);
261
fname = (char *) luaL_checkstring(L, 2);
262
CheckAfmOfPostscript(*sf, fname, (*sf)->map);
269
static void dump_intfield(lua_State * L, char *name, long int field)
271
lua_checkstack(L, 2);
272
lua_pushstring(L, name);
273
lua_pushnumber(L, field);
277
static void dump_realfield(lua_State * L, char *name, real field)
279
lua_checkstack(L, 2);
280
lua_pushstring(L, name);
281
lua_pushnumber(L, field);
253
286
#define dump_cond_intfield(a,b,c) if ((c)!=0) { dump_intfield ((a),(b),(c)); }
257
dump_stringfield (lua_State *L, char *name, char *field) {
259
lua_pushstring(L,name);
260
lua_pushstring(L,field);
265
dump_char_ref (lua_State *L, struct splinechar *spchar) {
267
lua_pushstring(L,"char");
268
lua_pushstring(L,spchar->name);
274
dump_lstringfield (lua_State *L, char *name, char *field, int len) {
276
lua_pushstring(L,name);
277
lua_pushlstring(L,field,len);
282
dump_enumfield (lua_State *L, char *name, int fid, char **fields) {
284
lua_pushstring(L,name);
285
lua_pushstring(L,fields[fid]);
290
dump_floatfield (lua_State *L, char *name, double field) {
292
lua_pushstring(L,name);
293
lua_pushnumber(L,field);
297
static char tag_string [5] = {0};
299
static char *make_tag_string (unsigned int field) {
300
tag_string[0] = (field&0xFF000000) >> 24;
301
tag_string[1] = (field&0x00FF0000) >> 16;
302
tag_string[2] = (field&0x0000FF00) >> 8;
303
tag_string[3] = (field&0x000000FF);
304
return (char *)tag_string;
307
static char featbuf[32] = {0};
309
static char *make_mactag_string (unsigned int field) {
310
sprintf( featbuf, "<%d,%d>", field>>16, field&0xffff );
311
return (char *)featbuf;
316
dump_tag (lua_State *L, char *name, unsigned int field) {
318
lua_pushstring(L,name);
319
lua_pushlstring(L,make_tag_string(field),4);
324
dump_mactag (lua_State *L, char *name, unsigned int field) {
326
lua_pushstring(L,name);
327
lua_pushstring(L,make_mactag_string(field));
332
dump_subtable_name (lua_State *L, char *name, struct lookup_subtable *s) {
333
/* this is likely a backref */
337
if (s->next == NULL) {
338
dump_stringfield(L,name,s->subtable_name);
340
/* can this really happen ? */
344
lua_pushstring(L, s->subtable_name);
345
lua_rawseti(L, -2, ++i);
289
static void dump_stringfield(lua_State * L, char *name, char *field)
291
lua_checkstack(L, 2);
292
lua_pushstring(L, name);
293
lua_pushstring(L, field);
297
static void dump_char_ref(lua_State * L, struct splinechar *spchar)
299
lua_checkstack(L, 2);
300
lua_pushstring(L, "char");
301
lua_pushstring(L, spchar->name);
306
static void dump_lstringfield(lua_State * L, char *name, char *field, int len)
308
lua_checkstack(L, 2);
309
lua_pushstring(L, name);
310
lua_pushlstring(L, field, len);
314
static void dump_enumfield(lua_State * L, char *name, int fid, char **fields)
316
lua_checkstack(L, 2);
317
lua_pushstring(L, name);
318
lua_pushstring(L, fields[fid]);
322
static void dump_floatfield(lua_State * L, char *name, double field)
324
lua_checkstack(L, 2);
325
lua_pushstring(L, name);
326
lua_pushnumber(L, field);
330
static char tag_string[5] = { 0 };
332
static char *make_tag_string(unsigned int field)
334
tag_string[0] = (field & 0xFF000000) >> 24;
335
tag_string[1] = (field & 0x00FF0000) >> 16;
336
tag_string[2] = (field & 0x0000FF00) >> 8;
337
tag_string[3] = (field & 0x000000FF);
338
return (char *) tag_string;
341
static char featbuf[32] = { 0 };
343
static char *make_mactag_string(unsigned int field)
345
sprintf(featbuf, "<%d,%d>", field >> 16, field & 0xffff);
346
return (char *) featbuf;
350
static void dump_tag(lua_State * L, char *name, unsigned int field)
352
lua_checkstack(L, 2);
353
lua_pushstring(L, name);
354
lua_pushlstring(L, make_tag_string(field), 4);
358
static void dump_mactag(lua_State * L, char *name, unsigned int field)
360
lua_checkstack(L, 2);
361
lua_pushstring(L, name);
362
lua_pushstring(L, make_mactag_string(field));
366
void dump_subtable_name(lua_State * L, char *name, struct lookup_subtable *s)
368
/* this is likely a backref */
371
lua_checkstack(L, 2);
372
if (s->next == NULL) {
373
dump_stringfield(L, name, s->subtable_name);
375
/* can this really happen ? */
379
lua_pushstring(L, s->subtable_name);
380
lua_rawseti(L, -2, ++i);
383
lua_setfield(L, -2, name);
348
lua_setfield(L, -2, name);
363
398
next = next->next; \
367
do_handle_scriptlanglist (lua_State *L, struct scriptlanglist *sl) {
369
dump_tag(L,"script", sl->script);
373
for (k=0;k<MAX_LANG;k++) {
374
if (sl->langs[k] != 0) {
375
lua_pushnumber(L,(k+1));
376
lua_pushstring(L,make_tag_string(sl->langs[k]));
381
if (sl->lang_cnt>=MAX_LANG) {
382
for (k=MAX_LANG;k<sl->lang_cnt;k++) {
383
lua_pushnumber(L,(k+1));
384
lua_pushstring(L,make_tag_string(sl->morelangs[k-MAX_LANG]));
388
lua_setfield(L,-2,"langs");
392
handle_scriptlanglist (lua_State *L, struct scriptlanglist *sll) {
393
struct scriptlanglist *next;
394
NESTED_TABLE(do_handle_scriptlanglist,sll,4);
398
do_handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) {
399
if (features->ismac) {
400
dump_mactag (L,"tag",features->featuretag);
402
dump_tag (L,"tag",features->featuretag);
405
handle_scriptlanglist(L, features->scripts);
406
lua_setfield(L,-2,"scripts");
407
dump_cond_intfield (L,"ismac",features->ismac);
411
handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) {
412
struct featurescriptlanglist *next;
413
NESTED_TABLE(do_handle_featurescriptlanglist,features,3);
417
do_handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) {
419
dump_stringfield(L,"name", subtable->subtable_name);
420
dump_stringfield(L,"suffix", subtable->suffix);
422
/* struct otlookup *lookup; */ /* this is the parent */
424
/* dump_intfield (L,"unused", subtable->unused); */
425
/* The next one is true if there is no fpst, false otherwise */
427
dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern);
429
dump_cond_intfield (L,"anchor_classes", subtable->anchor_classes);
430
dump_cond_intfield (L,"vertical_kerning", subtable->vertical_kerning);
432
if (subtable->kc != NULL) {
434
handle_kernclass(L, subtable->kc);
435
lua_setfield(L,-2, "kernclass");
401
#define NESTED_TABLE_SF(a,b,c,d) { \
404
while (next != NULL) { \
405
lua_checkstack(L,2); \
406
lua_pushnumber(L,k); k++; \
407
lua_createtable(L,0,d); \
414
void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl)
417
dump_tag(L, "script", sl->script);
419
lua_checkstack(L, 3);
421
for (k = 0; k < MAX_LANG; k++) {
422
if (sl->langs[k] != 0) {
423
lua_pushnumber(L, (k + 1));
424
lua_pushstring(L, make_tag_string(sl->langs[k]));
429
if (sl->lang_cnt >= MAX_LANG) {
430
for (k = MAX_LANG; k < sl->lang_cnt; k++) {
431
lua_pushnumber(L, (k + 1));
432
lua_pushstring(L, make_tag_string(sl->morelangs[k - MAX_LANG]));
436
lua_setfield(L, -2, "langs");
439
void handle_scriptlanglist(lua_State * L, struct scriptlanglist *sll)
441
struct scriptlanglist *next;
442
NESTED_TABLE(do_handle_scriptlanglist, sll, 4);
446
do_handle_featurescriptlanglist(lua_State * L,
447
struct featurescriptlanglist *features)
449
if (features->ismac) {
450
dump_mactag(L, "tag", features->featuretag);
452
dump_tag(L, "tag", features->featuretag);
455
handle_scriptlanglist(L, features->scripts);
456
lua_setfield(L, -2, "scripts");
457
dump_cond_intfield(L, "ismac", features->ismac);
461
handle_featurescriptlanglist(lua_State * L,
462
struct featurescriptlanglist *features)
464
struct featurescriptlanglist *next;
465
NESTED_TABLE(do_handle_featurescriptlanglist, features, 3);
468
void do_handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable)
471
dump_stringfield(L, "name", subtable->subtable_name);
472
dump_stringfield(L, "suffix", subtable->suffix);
474
/* struct otlookup *lookup; *//* this is the parent */
476
/* dump_intfield (L,"unused", subtable->unused); */
477
/* The next one is true if there is no fpst, false otherwise */
479
dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern);
481
dump_cond_intfield(L, "anchor_classes", subtable->anchor_classes);
482
dump_cond_intfield(L, "vertical_kerning", subtable->vertical_kerning);
484
if (subtable->kc != NULL) {
486
handle_kernclass(L, subtable->kc);
487
lua_setfield(L, -2, "kernclass");
439
if (subtable->fpst != NULL) {
440
/* lua_newtable(L); */
441
handle_generic_fpst(L, subtable->fpst);
442
/* lua_setfield(L,-2, "fpst"); */
490
if (subtable->fpst != NULL) {
491
/* lua_newtable(L); */
492
handle_generic_fpst(L, subtable->fpst);
493
/* lua_setfield(L,-2, "fpst"); */
446
if (subtable->sm != NULL) {
448
handle_generic_asm(L, subtable->sm);
449
lua_setfield(L,-2, "sm");
451
/* int subtable_offset; */ /* used by OTF file generation */
452
/* int32 *extra_subtables; */ /* used by OTF file generation */
456
handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) {
457
struct lookup_subtable *next;
458
NESTED_TABLE(do_handle_lookup_subtable,subtable,2);
462
do_handle_lookup (lua_State *L, struct otlookup *lookup ) {
464
dump_enumfield (L,"type", lookup->lookup_type, otf_lookup_type_enum);
467
if (lookup->lookup_flags & pst_r2l) {
468
lua_pushstring(L,"r2l"); lua_pushboolean(L,1); lua_rawset(L,-3);
470
if (lookup->lookup_flags & pst_ignorebaseglyphs) {
471
lua_pushstring(L,"ignorebaseglyphs"); lua_pushboolean(L,1); lua_rawset(L,-3);
473
if (lookup->lookup_flags & pst_ignoreligatures) {
474
lua_pushstring(L,"ignoreligatures"); lua_pushboolean(L,1); lua_rawset(L,-3);
476
if (lookup->lookup_flags & pst_ignorecombiningmarks) {
477
lua_pushstring(L,"ignorecombiningmarks"); lua_pushboolean(L,1); lua_rawset(L,-3);
479
lua_setfield(L,-2,"flags");
482
dump_stringfield (L,"name", lookup->lookup_name);
484
if (lookup->features != NULL) {
486
handle_featurescriptlanglist(L,lookup->features);
487
lua_setfield(L,-2,"features");
490
if (lookup->subtables != NULL) {
492
handle_lookup_subtable(L,lookup->subtables);
493
lua_setfield(L,-2,"subtables");
496
/* dump_intfield (L,"unused", lookup->unused); */
497
/* dump_intfield (L,"empty", lookup->empty); */
498
/* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */
499
/* dump_intfield (L,"needs_extension", lookup->needs_extension); */
500
/* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */
501
/* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */
502
/* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */
503
/* dump_intfield (L,"ticked", lookup->ticked); */
504
/* dump_intfield (L,"subcnt", lookup->subcnt); */
505
/* dump_intfield (L,"lookup_index", lookup->lookup_index); */ /* identical to array index */
506
/* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */
507
/* dump_intfield (L,"lookup_length", lookup->lookup_length); */
508
/* dump_stringfield(L,"tempname", lookup->tempname); */
513
handle_lookup (lua_State *L, struct otlookup *lookup ) {
514
struct otlookup *next;
515
NESTED_TABLE(do_handle_lookup,lookup,18); /* 18 is a guess */
519
do_handle_kernpair (lua_State *L, struct kernpair *kp) {
522
dump_char_ref(L, kp->sc);
523
dump_intfield(L,"off", kp->off);
524
/* uint16 kcid; */ /* temporary value */
525
dump_subtable_name(L, "lookup", kp->subtable);
529
handle_kernpair (lua_State *L, struct kernpair *kp) {
530
struct kernpair *next;
531
NESTED_TABLE(do_handle_kernpair,kp,4);
535
handle_splinecharlist (lua_State *L, struct splinecharlist *scl) {
537
struct splinecharlist *next = scl;
539
lua_checkstack(L,10);
540
while( next != NULL) {
541
if (next->sc != NULL) {
542
lua_pushnumber(L,k); k++;
543
lua_pushstring(L,next->sc->name);
497
if (subtable->sm != NULL) {
499
handle_generic_asm(L, subtable->sm);
500
lua_setfield(L, -2, "sm");
502
/* int subtable_offset; *//* used by OTF file generation */
503
/* int32 *extra_subtables; *//* used by OTF file generation */
506
void handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable)
508
struct lookup_subtable *next;
509
NESTED_TABLE(do_handle_lookup_subtable, subtable, 2);
512
void do_handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf)
516
dump_enumfield(L, "type", lookup->lookup_type, otf_lookup_type_enum);
519
if (lookup->lookup_flags & pst_r2l) {
520
lua_pushstring(L, "r2l");
521
lua_pushboolean(L, 1);
524
if (lookup->lookup_flags & pst_ignorebaseglyphs) {
525
lua_pushstring(L, "ignorebaseglyphs");
526
lua_pushboolean(L, 1);
529
if (lookup->lookup_flags & pst_ignoreligatures) {
530
lua_pushstring(L, "ignoreligatures");
531
lua_pushboolean(L, 1);
534
if (lookup->lookup_flags & pst_ignorecombiningmarks) {
535
lua_pushstring(L, "ignorecombiningmarks");
536
lua_pushboolean(L, 1);
539
mc = (lookup->lookup_flags >> 8);
540
if (mc > 0 && mc < sf->mark_class_cnt && sf->mark_class_names[mc] != NULL) {
541
lua_pushstring(L, "mark_class");
542
lua_pushstring(L, sf->mark_class_names[mc]);
545
lua_setfield(L, -2, "flags");
549
dump_stringfield(L, "name", lookup->lookup_name);
551
if (lookup->features != NULL) {
553
handle_featurescriptlanglist(L, lookup->features);
554
lua_setfield(L, -2, "features");
557
if (lookup->subtables != NULL) {
559
handle_lookup_subtable(L, lookup->subtables);
560
lua_setfield(L, -2, "subtables");
563
/* dump_intfield (L,"unused", lookup->unused); */
564
/* dump_intfield (L,"empty", lookup->empty); */
565
/* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */
566
/* dump_intfield (L,"needs_extension", lookup->needs_extension); */
567
/* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */
568
/* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */
569
/* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */
570
/* dump_intfield (L,"ticked", lookup->ticked); */
571
/* dump_intfield (L,"subcnt", lookup->subcnt); */
572
/* dump_intfield (L,"lookup_index", lookup->lookup_index); *//* identical to array index */
573
/* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */
574
/* dump_intfield (L,"lookup_length", lookup->lookup_length); */
575
/* dump_stringfield(L,"tempname", lookup->tempname); */
579
void handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf)
581
struct otlookup *next;
582
NESTED_TABLE_SF(do_handle_lookup, lookup, sf, 18); /* 18 is a guess */
585
void do_handle_kernpair(lua_State * L, struct kernpair *kp)
589
dump_char_ref(L, kp->sc);
590
dump_intfield(L, "off", kp->off);
591
/* uint16 kcid; *//* temporary value */
592
dump_subtable_name(L, "lookup", kp->subtable);
595
void handle_kernpair(lua_State * L, struct kernpair *kp)
597
struct kernpair *next;
598
NESTED_TABLE(do_handle_kernpair, kp, 4);
601
void handle_splinecharlist(lua_State * L, struct splinecharlist *scl)
604
struct splinecharlist *next = scl;
606
lua_checkstack(L, 10);
607
while (next != NULL) {
608
if (next->sc != NULL) {
609
lua_pushnumber(L, k);
611
lua_pushstring(L, next->sc->name);
556
624
/* variant shape. The specifics depend on the selector and script */
557
625
/* fid is currently unused, but may, someday, be used to do ttcs */
558
626
/* NOTE: GlyphInfo displays vs==-1 as vs==0, and fixes things up */
560
handle_altuni (lua_State *L, struct altuni *au) {
561
struct altuni *next = au;
564
while( next != NULL) {
566
dump_intfield(L, "unicode", next->unienc);
568
dump_intfield(L, "variant", next->vs);
569
/* dump_intfield(L, "fid", next->fid); */
570
lua_rawseti(L, -2, k++);
627
void handle_altuni(lua_State * L, struct altuni *au)
629
struct altuni *next = au;
631
lua_checkstack(L, 3);
632
while (next != NULL) {
634
dump_intfield(L, "unicode", next->unienc);
636
dump_intfield(L, "variant", next->vs);
637
/* dump_intfield(L, "fid", next->fid); */
638
lua_rawseti(L, -2, k++);
577
645
#define interesting_vr(a) (((a)->xoff!=0) || ((a)->yoff!=0) || ((a)->h_adv_off!=0) || ((a)->v_adv_off!=0))
579
void handle_vr (lua_State *L, struct vr *pos) {
581
dump_cond_intfield(L,"x", pos->xoff);
582
dump_cond_intfield(L,"y", pos->yoff);
583
dump_cond_intfield(L,"h", pos->h_adv_off);
584
dump_cond_intfield(L,"v", pos->v_adv_off);
589
do_handle_generic_pst (lua_State *L, struct generic_pst *pst) {
591
if (pst->type>LAST_POSSUB_TYPE_ENUM) {
592
dump_tag(L,"type", pst->type);
594
dump_enumfield(L,"type", pst->type, possub_type_enum);
596
/* unsigned int ticked: 1;*/
597
/* unsigned int temporary: 1;*/ /* Used in afm ligature closure */
598
/* struct lookup_subtable *subtable; */ /* handled by caller */
601
lua_pushstring(L,"specification");
602
lua_createtable(L,0,4);
603
if (pst->type == pst_position) {
604
handle_vr (L, &pst->u.pos);
605
} else if (pst->type == pst_pair) {
606
dump_stringfield(L,"paired",pst->u.pair.paired);
607
if (pst->u.pair.vr != NULL) {
608
lua_pushstring(L,"offsets");
609
lua_createtable(L,2,0);
610
if (interesting_vr(pst->u.pair.vr)) {
611
lua_createtable(L,0,4);
612
handle_vr (L, pst->u.pair.vr);
615
if (interesting_vr(pst->u.pair.vr+1)) {
616
lua_createtable(L,0,4);
617
handle_vr (L, pst->u.pair.vr+1);
622
} else if (pst->type == pst_substitution) {
623
dump_stringfield(L,"variant",pst->u.subs.variant);
624
} else if (pst->type == pst_alternate) {
625
dump_stringfield(L,"components",pst->u.mult.components);
626
} else if (pst->type == pst_multiple) {
627
dump_stringfield(L,"components",pst->u.alt.components);
628
} else if (pst->type == pst_ligature) {
629
dump_stringfield(L,"components",pst->u.lig.components);
630
if (pst->u.lig.lig != NULL) {
631
dump_char_ref(L,pst->u.lig.lig);
633
} else if (pst->type == pst_lcaret) {
634
for (k=0;k<pst->u.lcaret.cnt;k++) {
635
lua_pushnumber(L,(k+1));
636
lua_pushnumber(L,pst->u.lcaret.carets[k]);
645
handle_generic_pst (lua_State *L, struct generic_pst *pst) {
646
struct generic_pst *next;
650
/* most likely everything arrives in proper order. But to prevent
651
* surprises, better do this is the proper way
653
while (next != NULL) {
654
if (next->subtable !=NULL &&
655
next->subtable->subtable_name !=NULL) {
656
lua_checkstack(L,3); /* just in case */
657
lua_getfield(L,-1,next->subtable->subtable_name);
658
if (!lua_istable(L,-1)) {
661
lua_setfield(L,-2,next->subtable->subtable_name);
662
lua_getfield(L,-1,next->subtable->subtable_name);
664
k = lua_objlen(L,-1) + 1;
666
lua_createtable(L,0,4);
667
do_handle_generic_pst(L, next);
670
lua_pop(L,1); /* pop the subtable */
672
/* Found a pst without subtable, or without subtable name */
673
lua_pushnumber(L,l); l++;
674
lua_createtable(L,0,4);
675
do_handle_generic_pst(L, next);
683
do_handle_liglist (lua_State *L, struct liglist *ligofme) {
685
if(ligofme->lig != NULL) {
686
lua_createtable(L,0,6);
687
handle_generic_pst (L,ligofme->lig);
688
lua_setfield(L,-2,"lig");
690
dump_char_ref(L,ligofme->first);
691
if (ligofme->components != NULL) {
693
handle_splinecharlist (L,ligofme->components);
694
lua_setfield(L,-2,"components");
696
dump_intfield(L,"ccnt",ligofme->ccnt);
700
handle_liglist (lua_State *L, struct liglist *ligofme) {
701
struct liglist *next;
702
NESTED_TABLE(do_handle_liglist,ligofme,3);
706
do_handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) {
708
if (anchor->anchor==NULL) {
711
if (anchor->type>=0 && anchor->type <= MAX_ANCHOR_TYPE ) {
712
lua_pushstring(L,anchor_type_enum[anchor->type]);
714
lua_pushstring(L,"Anchorpoint has an unknown type!");
717
/* unsigned int selected: 1; */
718
/* unsigned int ticked: 1; */
721
if (!lua_istable(L,-1)) {
722
/* create the table first */
724
lua_pushstring(L,anchor_type_enum[anchor->type]);
730
/* now the 'type' table is top of stack */
731
if (anchor->type==at_baselig) {
732
lua_pushstring(L,anchor->anchor->name);
734
if (!lua_istable(L,-1)) {
735
/* create the table first */
737
lua_pushstring(L,anchor->anchor->name);
744
dump_intfield(L,"x", anchor->me.x);
745
dump_intfield(L,"y", anchor->me.y);
746
if (anchor->has_ttf_pt)
747
dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index);
748
dump_intfield(L,"lig_index", anchor->lig_index);
749
lua_rawseti(L,-2,(anchor->lig_index+1));
752
lua_pushstring(L,anchor->anchor->name);
754
dump_intfield(L,"x", anchor->me.x);
755
dump_intfield(L,"y", anchor->me.y);
756
if (anchor->has_ttf_pt)
757
dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index);
758
dump_intfield(L,"lig_index", anchor->lig_index);
765
handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) {
766
struct anchorpoint *next;
768
while (next != NULL) {
769
do_handle_anchorpoint(L, next);
775
handle_glyphvariants (lua_State *L, struct glyphvariants *vars) {
777
dump_stringfield(L, "variants", vars->variants);
778
dump_intfield (L, "italic_correction", vars->italic_correction);
780
for (i=0; i< vars->part_cnt; i++) {
782
dump_stringfield(L, "component", vars->parts[i].component);
783
dump_intfield(L, "extender", vars->parts[i].is_extender);
784
dump_intfield(L, "start", vars->parts[i].startConnectorLength);
785
dump_intfield(L, "end", vars->parts[i].endConnectorLength);
786
dump_intfield(L, "advance", vars->parts[i].fullAdvance);
787
lua_rawseti(L,-2,(i+1));
789
lua_setfield(L, -2, "parts");
792
void handle_mathkernvertex (lua_State *L, struct mathkernvertex *mkv) {
794
for (i=0; i<mkv->cnt;i++) {
796
dump_intfield(L, "height", mkv->mkd[i].height );
797
dump_intfield(L, "kern", mkv->mkd[i].kern );
798
lua_rawseti(L,-2, (i+1));
802
void handle_mathkern (lua_State *L, struct mathkern *mk) {
804
handle_mathkernvertex(L, &(mk->top_right));
805
lua_setfield(L, -2, "top_right");
807
handle_mathkernvertex(L, &(mk->top_left));
808
lua_setfield(L, -2, "top_left");
810
handle_mathkernvertex(L, &(mk->bottom_right));
811
lua_setfield(L, -2, "bottom_right");
813
handle_mathkernvertex(L, &(mk->bottom_left));
814
lua_setfield(L, -2, "bottom_left");
820
handle_splinechar (lua_State *L,struct splinechar *glyph, int hasvmetrics) {
822
if (glyph->xmax==0 && glyph->ymax==0 && glyph->xmin==0 && glyph->ymin==0) {
823
SplineCharFindBounds(glyph,&bb);
824
glyph->xmin = bb.minx;
825
glyph->ymin = bb.miny;
826
glyph->xmax = bb.maxx;
827
glyph->ymax = bb.maxy;
829
dump_stringfield(L,"name", glyph->name);
830
dump_intfield(L,"unicode", glyph->unicodeenc);
831
lua_createtable(L,4,0);
832
lua_pushnumber(L,1); lua_pushnumber(L,glyph->xmin); lua_rawset(L,-3);
833
lua_pushnumber(L,2); lua_pushnumber(L,glyph->ymin); lua_rawset(L,-3);
834
lua_pushnumber(L,3); lua_pushnumber(L,glyph->xmax); lua_rawset(L,-3);
835
lua_pushnumber(L,4); lua_pushnumber(L,glyph->ymax); lua_rawset(L,-3);
836
lua_setfield(L,-2,"boundingbox");
837
/*dump_intfield(L,"orig_pos", glyph->orig_pos);*/
839
dump_intfield(L,"vwidth", glyph->vwidth);
840
dump_intfield(L,"width", glyph->width);
842
if (glyph->lsidebearing != glyph->xmin) {
843
dump_cond_intfield(L,"lsidebearing", glyph->lsidebearing);
845
/* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */
847
/* Layer layers[2]; */ /* TH Not used */
848
/* int layer_cnt; */ /* TH Not used */
849
/* StemInfo *hstem; */ /* TH Not used */
850
/* StemInfo *vstem; */ /* TH Not used */
851
/* DStemInfo *dstem; */ /* TH Not used */
853
/* MinimumDistance *md; */ /* TH Not used */
854
/* struct charviewbase *views; */ /* TH Not used */
855
/* struct charinfo *charinfo; */ /* TH ? (charinfo.c) */
856
/* struct splinefont *parent; */ /* TH Not used */
858
if (glyph->glyph_class>0) {
859
dump_enumfield(L,"class", glyph->glyph_class, glyph_class_enum);
861
/* TH: internal fontforge stuff
862
dump_intfield(L,"changed", glyph->changed);
863
dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted);
864
dump_intfield(L,"manualhints", glyph->manualhints);
865
dump_intfield(L,"ticked", glyph->ticked);
866
dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave);
867
dump_intfield(L,"widthset", glyph->widthset);
868
dump_intfield(L,"vconflicts", glyph->vconflicts);
869
dump_intfield(L,"hconflicts", glyph->hconflicts);
870
dump_intfield(L,"searcherdummy", glyph->searcherdummy);
871
dump_intfield(L,"changed_since_search", glyph->changed_since_search);
872
dump_intfield(L,"wasopen", glyph->wasopen);
873
dump_intfield(L,"namechanged", glyph->namechanged);
874
dump_intfield(L,"blended", glyph->blended);
875
dump_intfield(L,"ticked2", glyph->ticked2);
876
dump_intfield(L,"unused_so_far", glyph->unused_so_far);
877
dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards);
878
dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date);
879
dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums);
880
unsigned int vs_open: 1;
881
unsigned int unlink_rm_ovrlp_save_undo: 1;
882
unsigned int inspiro: 1;
883
unsigned int lig_caret_cnt_fixed: 1;
887
int16 ttf_instrs_len;
888
int16 countermask_cnt;
889
HintMask *countermasks;
892
if (glyph->kerns != NULL) {
894
handle_kernpair(L,glyph->kerns);
895
lua_setfield(L,-2,"kerns");
897
if (glyph->vkerns != NULL) {
899
handle_kernpair(L,glyph->vkerns);
900
lua_setfield(L,-2,"vkerns");
903
if (glyph->dependents != NULL) {
905
handle_splinecharlist(L,glyph->dependents);
906
lua_setfield(L,-2,"dependents");
909
if (glyph->possub != NULL) {
911
handle_generic_pst(L,glyph->possub);
912
lua_setfield(L,-2,"lookups");
915
if (glyph->ligofme != NULL) {
917
handle_liglist(L,glyph->ligofme);
918
lua_setfield(L,-2,"ligatures");
921
if (glyph->comment != NULL)
922
dump_stringfield(L,"comment", glyph->comment);
924
/* Color color; */ /* dont care */
926
if (glyph->anchor != NULL) {
928
handle_anchorpoint(L,glyph->anchor);
929
lua_setfield(L,-2,"anchors");
932
if (glyph->altuni != NULL) {
934
handle_altuni(L, glyph->altuni);
935
lua_setfield(L,-2,"altuni");
938
if (glyph->tex_height != TEX_UNDEF)
939
dump_intfield(L,"tex_height", glyph->tex_height);
940
if (glyph->tex_depth != TEX_UNDEF)
941
dump_intfield(L,"tex_depth", glyph->tex_depth);
943
dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape);
944
if (glyph->italic_correction != TEX_UNDEF)
945
dump_intfield(L, "italic_correction", glyph->italic_correction);
946
if (glyph->top_accent_horiz != TEX_UNDEF)
947
dump_intfield(L, "top_accent", glyph->top_accent_horiz);
949
if (glyph->vert_variants != NULL) {
951
handle_glyphvariants(L, glyph->vert_variants);
952
lua_setfield(L,-2,"vert_variants");
954
if (glyph->horiz_variants != NULL) {
956
handle_glyphvariants(L, glyph->horiz_variants);
957
lua_setfield(L,-2,"horiz_variants");
959
if (glyph->mathkern != NULL) {
961
handle_mathkern(L, glyph->mathkern);
962
lua_setfield(L,-2,"mathkern");
966
char *panose_values_0[] = { "Any", "No Fit", "Text and Display", "Script", "Decorative", "Pictorial" };
968
char *panose_values_1[] = { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove", "Obtuse Square Cove",
969
"Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans",
970
"Obtuse Sans", "Perp Sans", "Flared", "Rounded" } ;
972
char *panose_values_2[] = { "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
973
"Medium", "Demi", "Bold", "Heavy", "Black", "Nord" } ;
975
char *panose_values_3[] = { "Any", "No Fit", "Old Style", "Modern", "Even Width",
976
"Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced" };
978
char *panose_values_4[] = { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
979
"Medium", "Medium High", "High", "Very High" };
981
char *panose_values_5[] = { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional","Gradual/Vertical",
982
"Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal", "Instant/Vertical" };
984
char *panose_values_6[] = {"Any","No Fit","Straight Arms/Horizontal","Straight Arms/Wedge","Straight Arms/Vertical",
985
"Straight Arms/Single Serif","Straight Arms/Double Serif","Non-Straight Arms/Horizontal",
986
"Non-Straight Arms/Wedge","Non-Straight Arms/Vertical","Non-Straight Arms/Single Serif",
987
"Non-Straight Arms/Double Serif" };
989
char *panose_values_7[] = { "Any", "No Fit","Normal/Contact","Normal/Weighted","Normal/Boxed","Normal/Flattened",
990
"Normal/Rounded","Normal/Off Center","Normal/Square","Oblique/Contact","Oblique/Weighted",
991
"Oblique/Boxed","Oblique/Flattened","Oblique/Rounded","Oblique/Off Center","Oblique/Square" };
993
char *panose_values_8[] = { "Any","No Fit","Standard/Trimmed","Standard/Pointed","Standard/Serifed","High/Trimmed",
994
"High/Pointed","High/Serifed","Constant/Trimmed","Constant/Pointed","Constant/Serifed",
995
"Low/Trimmed","Low/Pointed","Low/Serifed"};
997
char *panose_values_9[] = { "Any","No Fit", "Constant/Small", "Constant/Standard",
998
"Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large" };
1002
handle_pfminfo (lua_State *L, struct pfminfo pfm) {
1004
dump_intfield (L, "pfmset", pfm.pfmset);
1005
dump_intfield (L, "winascent_add", pfm.winascent_add);
1006
dump_intfield (L, "windescent_add", pfm.windescent_add);
1007
dump_intfield (L, "hheadascent_add", pfm.hheadascent_add);
1008
dump_intfield (L, "hheaddescent_add", pfm.hheaddescent_add);
1009
dump_intfield (L, "typoascent_add", pfm.typoascent_add);
1010
dump_intfield (L, "typodescent_add", pfm.typodescent_add);
1011
dump_intfield (L, "subsuper_set", pfm.subsuper_set);
1012
dump_intfield (L, "panose_set", pfm.panose_set);
1013
dump_intfield (L, "hheadset", pfm.hheadset);
1014
dump_intfield (L, "vheadset", pfm.vheadset);
1015
dump_intfield (L, "pfmfamily", pfm.pfmfamily);
1016
dump_intfield (L, "weight", pfm.weight);
1017
dump_intfield (L, "width", pfm.width);
1018
dump_intfield (L, "avgwidth", pfm.avgwidth);
1019
dump_intfield (L, "firstchar", pfm.firstchar);
1020
dump_intfield (L, "lastchar", pfm.lastchar);
1021
lua_createtable(L,0,10);
1022
dump_enumfield(L,"familytype", pfm.panose[0], panose_values_0);
1023
dump_enumfield(L,"serifstyle", pfm.panose[1], panose_values_1);
1024
dump_enumfield(L,"weight", pfm.panose[2], panose_values_2);
1025
dump_enumfield(L,"proportion", pfm.panose[3], panose_values_3);
1026
dump_enumfield(L,"contrast", pfm.panose[4], panose_values_4);
1027
dump_enumfield(L,"strokevariation", pfm.panose[5], panose_values_5);
1028
dump_enumfield(L,"armstyle", pfm.panose[6], panose_values_6);
1029
dump_enumfield(L,"letterform", pfm.panose[7], panose_values_7);
1030
dump_enumfield(L,"midline", pfm.panose[8], panose_values_8);
1031
dump_enumfield(L,"xheight", pfm.panose[9], panose_values_9);
1032
lua_setfield (L,-2,"panose");
1034
dump_intfield (L, "fstype", pfm.fstype);
1035
dump_intfield (L, "linegap", pfm.linegap);
1036
dump_intfield (L, "vlinegap", pfm.vlinegap);
1037
dump_intfield (L, "hhead_ascent", pfm.hhead_ascent);
1038
dump_intfield (L, "hhead_descent", pfm.hhead_descent);
1039
dump_intfield (L, "hhead_descent", pfm.hhead_descent);
1040
dump_intfield (L, "os2_typoascent", pfm.os2_typoascent );
1041
dump_intfield (L, "os2_typodescent", pfm.os2_typodescent );
1042
dump_intfield (L, "os2_typolinegap", pfm.os2_typolinegap );
1043
dump_intfield (L, "os2_winascent", pfm.os2_winascent );
1044
dump_intfield (L, "os2_windescent", pfm.os2_windescent );
1045
dump_intfield (L, "os2_subxsize", pfm.os2_subxsize );
1046
dump_intfield (L, "os2_subysize", pfm.os2_subysize );
1047
dump_intfield (L, "os2_subxoff", pfm.os2_subxoff );
1048
dump_intfield (L, "os2_subyoff", pfm.os2_subyoff );
1049
dump_intfield (L, "os2_supxsize", pfm.os2_supxsize );
1050
dump_intfield (L, "os2_supysize", pfm.os2_supysize );
1051
dump_intfield (L, "os2_supxoff", pfm.os2_supxoff );
1052
dump_intfield (L, "os2_supyoff", pfm.os2_supyoff );
1053
dump_intfield (L, "os2_strikeysize", pfm.os2_strikeysize );
1054
dump_intfield (L, "os2_strikeypos", pfm.os2_strikeypos );
1055
dump_lstringfield (L, "os2_vendor", pfm.os2_vendor, 4);
1056
dump_intfield (L, "os2_family_class", pfm.os2_family_class);
1057
dump_intfield (L, "os2_xheight", pfm.os2_xheight);
1058
dump_intfield (L, "os2_capheight", pfm.os2_capheight);
1059
dump_intfield (L, "os2_defaultchar", pfm.os2_defaultchar);
1060
dump_intfield (L, "os2_breakchar", pfm.os2_breakchar);
1061
if (pfm.hascodepages) {
1063
lua_pushnumber(L, pfm.codepages[0]); lua_rawseti(L,-2,1);
1064
lua_pushnumber(L, pfm.codepages[1]); lua_rawseti(L,-2,2);
1065
lua_setfield(L,-2,"codepages");
1067
if (pfm.hasunicoderanges) {
1069
lua_pushnumber(L, pfm.unicoderanges[0]); lua_rawseti(L,-2,1);
1070
lua_pushnumber(L, pfm.unicoderanges[1]); lua_rawseti(L,-2,2);
1071
lua_pushnumber(L, pfm.unicoderanges[2]); lua_rawseti(L,-2,3);
1072
lua_pushnumber(L, pfm.unicoderanges[3]); lua_rawseti(L,-2,4);
1073
lua_setfield(L,-2,"unicoderanges");
1079
do_handle_enc (lua_State *L, struct enc *enc) {
1082
dump_stringfield(L,"enc_name", enc->enc_name);
1083
dump_intfield (L,"char_cnt", enc->char_cnt);
1085
lua_checkstack(L,4);
1086
if (enc->char_cnt && enc->unicode != NULL) {
1087
lua_createtable(L,enc->char_cnt,1);
1088
for (i=0;i<enc->char_cnt;i++) {
1089
lua_pushnumber(L,i);
1090
lua_pushnumber(L,enc->unicode[i]);
1093
lua_setfield(L,-2,"unicode");
1096
if (enc->char_cnt && enc->psnames != NULL) {
1097
lua_createtable(L,enc->char_cnt,1);
1098
for (i=0;i<enc->char_cnt;i++) {
1099
lua_pushnumber(L,i);
1100
lua_pushstring(L,enc->psnames[i]);
1103
lua_setfield(L,-2,"psnames");
1105
dump_intfield (L,"builtin", enc->builtin );
1106
dump_intfield (L,"hidden", enc->hidden );
1107
dump_intfield (L,"only_1byte", enc->only_1byte );
1108
dump_intfield (L,"has_1byte", enc->has_1byte );
1109
dump_intfield (L,"has_2byte", enc->has_2byte );
1110
dump_cond_intfield (L,"is_unicodebmp", enc->is_unicodebmp );
1111
dump_cond_intfield (L,"is_unicodefull", enc->is_unicodefull );
1112
dump_cond_intfield (L,"is_custom", enc->is_custom );
1113
dump_cond_intfield (L,"is_original", enc->is_original );
1114
dump_cond_intfield (L,"is_compact", enc->is_compact );
1115
dump_cond_intfield (L,"is_japanese", enc->is_japanese );
1116
dump_cond_intfield (L,"is_korean", enc->is_korean );
1117
dump_cond_intfield (L,"is_tradchinese", enc->is_tradchinese );
1118
dump_cond_intfield (L,"is_simplechinese", enc->is_simplechinese);
1120
if (enc->iso_2022_escape_len > 0) {
1121
dump_lstringfield (L,"iso_2022_escape", enc->iso_2022_escape, enc->iso_2022_escape_len);
1123
dump_intfield (L,"low_page", enc->low_page);
1124
dump_intfield(L,"high_page", enc->high_page);
1126
dump_stringfield(L,"iconv_name", enc->iconv_name);
1128
dump_intfield (L,"char_max", enc->char_max);
1132
handle_enc (lua_State *L, struct enc *enc) {
1134
NESTED_TABLE(do_handle_enc,enc,24);
1138
handle_encmap (lua_State *L, struct encmap *map, int notdef_loc) {
1140
dump_intfield(L,"enccount", map->enccount) ;
1141
dump_intfield(L,"encmax", map->encmax) ;
1142
dump_intfield(L,"backmax", map->backmax) ;
1143
/*dump_intfield(L,"ticked", map->ticked) ;*/
1144
if (map->remap != NULL) {
1146
dump_intfield(L,"firstenc", map->remap->firstenc) ;
1147
dump_intfield(L,"lastenc", map->remap->lastenc) ;
1148
dump_intfield(L,"infont", map->remap->infont) ;
1149
lua_setfield(L,-2,"remap");
1151
lua_checkstack(L,4);
1152
if (map->encmax > 0 && map->map != NULL) {
1153
lua_createtable(L,map->encmax,1);
1154
for (i=0;i<map->encmax;i++) {
1155
if (map->map[i]!=-1) {
1156
int l = map->map[i];
1157
lua_pushnumber(L,i);
1159
lua_pushnumber(L,(l+1));
1161
lua_pushnumber(L,l);
1165
lua_setfield(L,-2,"map");
1168
if (map->backmax > 0 && map->backmap != NULL) {
1170
for (i=0;i<map->backmax;i++) {
1171
if (map->backmap[i]!=-1) { /* TODO: check this, because valgrind sometimes says
1172
"Conditional jump or move depends on uninitialised value(s)"
1176
lua_pushnumber(L,(i+1));
1178
lua_pushnumber(L,i);
1179
lua_pushnumber(L,map->backmap[i]);
1183
lua_setfield(L,-2,"backmap");
1186
if (map->enc != NULL) {
1188
handle_enc(L,map->enc);
1189
lua_setfield(L,-2,"enc");
1194
handle_psdict (lua_State *L, struct psdict *private) {
1196
if (private->keys != NULL && private->values != NULL) {
1197
for (k=0;k<private->next;k++) {
1198
lua_pushstring(L,private->keys[k]);
1199
lua_pushstring(L,private->values[k]);
1206
do_handle_ttflangname (lua_State *L, struct ttflangname *names) {
1208
dump_stringfield(L,"lang", (char *)MSLangString(names->lang)) ;
1209
lua_checkstack(L,4);
1210
lua_createtable(L,0,ttf_namemax);
1211
for (k=0;k<ttf_namemax;k++) {
1212
lua_pushstring(L,ttfnames_enum[k]);
1213
lua_pushstring(L,names->names[k]);
1216
lua_setfield(L, -2 , "names");
1221
handle_ttflangname (lua_State *L, struct ttflangname *names) {
1222
struct ttflangname *next;
1223
NESTED_TABLE(do_handle_ttflangname,names,2);
1228
do_handle_anchorclass (lua_State *L, struct anchorclass *anchor) {
1230
dump_stringfield(L,"name", anchor->name);
1231
dump_subtable_name (L, "lookup", anchor->subtable);
1232
dump_enumfield(L,"type", anchor->type, anchorclass_type_enum);
1233
/* uint8 has_base; */
1234
/* uint8 processed, has_mark, matches, ac_num; */
1239
handle_anchorclass (lua_State *L, struct anchorclass *anchor) {
1240
struct anchorclass *next;
1241
NESTED_TABLE(do_handle_anchorclass,anchor,10);
1245
do_handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) {
1247
dump_tag(L,"tag", ttf_tab->tag);
1248
dump_intfield(L,"len", ttf_tab->len);
1249
dump_intfield(L,"maxlen", ttf_tab->maxlen);
1250
dump_lstringfield(L,"data", (char *)ttf_tab->data, ttf_tab->len);
1254
handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) {
1255
struct ttf_table *next;
1256
NESTED_TABLE(do_handle_ttf_table,ttf_tab,4);
1260
do_handle_kernclass (lua_State *L, struct kernclass *kerns) {
1264
* dump_intfield(L,"first_cnt", kerns->first_cnt);
1265
* dump_intfield(L,"second_cnt", kerns->second_cnt);
1267
lua_checkstack(L,4);
1268
lua_createtable(L,kerns->first_cnt,1);
1269
for (k=0;k<kerns->first_cnt;k++) {
1270
lua_pushnumber(L,(k+1));
1271
lua_pushstring(L,kerns->firsts[k]);
1274
lua_setfield(L,-2,"firsts");
1276
lua_createtable(L,kerns->second_cnt,1);
1277
for (k=0;k<kerns->second_cnt;k++) {
1278
lua_pushnumber(L,(k+1));
1279
lua_pushstring(L,kerns->seconds[k]);
1282
lua_setfield(L,-2,"seconds");
1284
dump_subtable_name(L, "lookup", kerns->subtable);
1285
/*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */
1287
lua_createtable(L,kerns->second_cnt*kerns->first_cnt,1);
1288
for (k=0;k<(kerns->second_cnt*kerns->first_cnt);k++) {
1289
if (kerns->offsets[k]!=0) {
1290
lua_pushnumber(L,(k+1));
1291
lua_pushnumber(L,kerns->offsets[k]);
1295
lua_setfield(L,-2,"offsets");
1300
handle_kernclass (lua_State *L, struct kernclass *kerns) {
1301
struct kernclass *next;
1302
NESTED_TABLE(do_handle_kernclass,kerns,8);
647
void handle_vr(lua_State * L, struct vr *pos)
650
dump_cond_intfield(L, "x", pos->xoff);
651
dump_cond_intfield(L, "y", pos->yoff);
652
dump_cond_intfield(L, "h", pos->h_adv_off);
653
dump_cond_intfield(L, "v", pos->v_adv_off);
657
void do_handle_generic_pst(lua_State * L, struct generic_pst *pst)
660
if (pst->type > LAST_POSSUB_TYPE_ENUM) {
661
dump_tag(L, "type", pst->type);
663
dump_enumfield(L, "type", pst->type, possub_type_enum);
665
/* unsigned int ticked: 1; */
666
/* unsigned int temporary: 1; *//* Used in afm ligature closure */
667
/* struct lookup_subtable *subtable; *//* handled by caller */
669
lua_checkstack(L, 4);
670
lua_pushstring(L, "specification");
671
lua_createtable(L, 0, 4);
672
if (pst->type == pst_position) {
673
handle_vr(L, &pst->u.pos);
674
} else if (pst->type == pst_pair) {
675
dump_stringfield(L, "paired", pst->u.pair.paired);
676
if (pst->u.pair.vr != NULL) {
677
lua_pushstring(L, "offsets");
678
lua_createtable(L, 2, 0);
679
if (interesting_vr(pst->u.pair.vr)) {
680
lua_createtable(L, 0, 4);
681
handle_vr(L, pst->u.pair.vr);
682
lua_rawseti(L, -2, 1);
684
if (interesting_vr(pst->u.pair.vr + 1)) {
685
lua_createtable(L, 0, 4);
686
handle_vr(L, pst->u.pair.vr + 1);
687
lua_rawseti(L, -2, 2);
691
} else if (pst->type == pst_substitution) {
692
dump_stringfield(L, "variant", pst->u.subs.variant);
693
} else if (pst->type == pst_alternate) {
694
dump_stringfield(L, "components", pst->u.mult.components);
695
} else if (pst->type == pst_multiple) {
696
dump_stringfield(L, "components", pst->u.alt.components);
697
} else if (pst->type == pst_ligature) {
698
dump_stringfield(L, "components", pst->u.lig.components);
699
if (pst->u.lig.lig != NULL) {
700
dump_char_ref(L, pst->u.lig.lig);
702
} else if (pst->type == pst_lcaret) {
703
for (k = 0; k < pst->u.lcaret.cnt; k++) {
704
lua_pushnumber(L, (k + 1));
705
lua_pushnumber(L, pst->u.lcaret.carets[k]);
713
void handle_generic_pst(lua_State * L, struct generic_pst *pst)
715
struct generic_pst *next;
719
/* most likely everything arrives in proper order. But to prevent
720
* surprises, better do this is the proper way
722
while (next != NULL) {
723
if (next->subtable != NULL && next->subtable->subtable_name != NULL) {
724
lua_checkstack(L, 3); /* just in case */
725
lua_getfield(L, -1, next->subtable->subtable_name);
726
if (!lua_istable(L, -1)) {
729
lua_setfield(L, -2, next->subtable->subtable_name);
730
lua_getfield(L, -1, next->subtable->subtable_name);
732
k = lua_objlen(L, -1) + 1;
733
lua_pushnumber(L, k);
734
lua_createtable(L, 0, 4);
735
do_handle_generic_pst(L, next);
738
lua_pop(L, 1); /* pop the subtable */
740
/* Found a pst without subtable, or without subtable name */
741
lua_pushnumber(L, l);
743
lua_createtable(L, 0, 4);
744
do_handle_generic_pst(L, next);
751
void do_handle_liglist(lua_State * L, struct liglist *ligofme)
753
lua_checkstack(L, 2);
754
if (ligofme->lig != NULL) {
755
lua_createtable(L, 0, 6);
756
handle_generic_pst(L, ligofme->lig);
757
lua_setfield(L, -2, "lig");
759
dump_char_ref(L, ligofme->first);
760
if (ligofme->components != NULL) {
762
handle_splinecharlist(L, ligofme->components);
763
lua_setfield(L, -2, "components");
765
dump_intfield(L, "ccnt", ligofme->ccnt);
768
void handle_liglist(lua_State * L, struct liglist *ligofme)
770
struct liglist *next;
771
NESTED_TABLE(do_handle_liglist, ligofme, 3);
774
void do_handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
777
if (anchor->anchor == NULL) {
780
if (anchor->type >= 0 && anchor->type <= MAX_ANCHOR_TYPE) {
781
lua_pushstring(L, anchor_type_enum[anchor->type]);
783
lua_pushstring(L, "Anchorpoint has an unknown type!");
786
/* unsigned int selected: 1; */
787
/* unsigned int ticked: 1; */
790
if (!lua_istable(L, -1)) {
791
/* create the table first */
793
lua_pushstring(L, anchor_type_enum[anchor->type]);
794
lua_pushvalue(L, -1);
799
/* now the 'type' table is top of stack */
800
if (anchor->type == at_baselig) {
801
lua_pushstring(L, anchor->anchor->name);
803
if (!lua_istable(L, -1)) {
804
/* create the table first */
806
lua_pushstring(L, anchor->anchor->name);
807
lua_pushvalue(L, -1);
813
dump_intfield(L, "x", anchor->me.x);
814
dump_intfield(L, "y", anchor->me.y);
815
if (anchor->has_ttf_pt)
816
dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index);
817
dump_intfield(L, "lig_index", anchor->lig_index);
818
lua_rawseti(L, -2, (anchor->lig_index + 1));
821
lua_pushstring(L, anchor->anchor->name);
823
dump_intfield(L, "x", anchor->me.x);
824
dump_intfield(L, "y", anchor->me.y);
825
if (anchor->has_ttf_pt)
826
dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index);
827
dump_intfield(L, "lig_index", anchor->lig_index);
833
void handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
835
struct anchorpoint *next;
837
while (next != NULL) {
838
do_handle_anchorpoint(L, next);
843
void handle_glyphvariants(lua_State * L, struct glyphvariants *vars)
846
dump_stringfield(L, "variants", vars->variants);
847
dump_intfield(L, "italic_correction", vars->italic_correction);
849
for (i = 0; i < vars->part_cnt; i++) {
851
dump_stringfield(L, "component", vars->parts[i].component);
852
dump_intfield(L, "extender", vars->parts[i].is_extender);
853
dump_intfield(L, "start", vars->parts[i].startConnectorLength);
854
dump_intfield(L, "end", vars->parts[i].endConnectorLength);
855
dump_intfield(L, "advance", vars->parts[i].fullAdvance);
856
lua_rawseti(L, -2, (i + 1));
858
lua_setfield(L, -2, "parts");
861
void handle_mathkernvertex(lua_State * L, struct mathkernvertex *mkv)
864
for (i = 0; i < mkv->cnt; i++) {
866
dump_intfield(L, "height", mkv->mkd[i].height);
867
dump_intfield(L, "kern", mkv->mkd[i].kern);
868
lua_rawseti(L, -2, (i + 1));
872
void handle_mathkern(lua_State * L, struct mathkern *mk)
875
handle_mathkernvertex(L, &(mk->top_right));
876
lua_setfield(L, -2, "top_right");
878
handle_mathkernvertex(L, &(mk->top_left));
879
lua_setfield(L, -2, "top_left");
881
handle_mathkernvertex(L, &(mk->bottom_right));
882
lua_setfield(L, -2, "bottom_right");
884
handle_mathkernvertex(L, &(mk->bottom_left));
885
lua_setfield(L, -2, "bottom_left");
890
void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics)
893
if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0
894
&& glyph->ymin == 0) {
895
SplineCharFindBounds(glyph, &bb);
896
glyph->xmin = bb.minx;
897
glyph->ymin = bb.miny;
898
glyph->xmax = bb.maxx;
899
glyph->ymax = bb.maxy;
901
dump_stringfield(L, "name", glyph->name);
902
dump_intfield(L, "unicode", glyph->unicodeenc);
903
lua_createtable(L, 4, 0);
904
lua_pushnumber(L, 1);
905
lua_pushnumber(L, glyph->xmin);
907
lua_pushnumber(L, 2);
908
lua_pushnumber(L, glyph->ymin);
910
lua_pushnumber(L, 3);
911
lua_pushnumber(L, glyph->xmax);
913
lua_pushnumber(L, 4);
914
lua_pushnumber(L, glyph->ymax);
916
lua_setfield(L, -2, "boundingbox");
917
/*dump_intfield(L,"orig_pos", glyph->orig_pos); */
919
dump_intfield(L, "vwidth", glyph->vwidth);
920
dump_intfield(L, "width", glyph->width);
922
if (glyph->lsidebearing != glyph->xmin) {
923
dump_cond_intfield(L, "lsidebearing", glyph->lsidebearing);
925
/* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */
927
/* Layer layers[2]; *//* TH Not used */
928
/* int layer_cnt; *//* TH Not used */
929
/* StemInfo *hstem; *//* TH Not used */
930
/* StemInfo *vstem; *//* TH Not used */
931
/* DStemInfo *dstem; *//* TH Not used */
933
/* MinimumDistance *md; *//* TH Not used */
934
/* struct charviewbase *views; *//* TH Not used */
935
/* struct charinfo *charinfo; *//* TH ? (charinfo.c) */
936
/* struct splinefont *parent; *//* TH Not used */
938
if (glyph->glyph_class > 0) {
939
dump_enumfield(L, "class", glyph->glyph_class, glyph_class_enum);
941
/* TH: internal fontforge stuff
942
dump_intfield(L,"changed", glyph->changed);
943
dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted);
944
dump_intfield(L,"manualhints", glyph->manualhints);
945
dump_intfield(L,"ticked", glyph->ticked);
946
dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave);
947
dump_intfield(L,"widthset", glyph->widthset);
948
dump_intfield(L,"vconflicts", glyph->vconflicts);
949
dump_intfield(L,"hconflicts", glyph->hconflicts);
950
dump_intfield(L,"searcherdummy", glyph->searcherdummy);
951
dump_intfield(L,"changed_since_search", glyph->changed_since_search);
952
dump_intfield(L,"wasopen", glyph->wasopen);
953
dump_intfield(L,"namechanged", glyph->namechanged);
954
dump_intfield(L,"blended", glyph->blended);
955
dump_intfield(L,"ticked2", glyph->ticked2);
956
dump_intfield(L,"unused_so_far", glyph->unused_so_far);
957
dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards);
958
dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date);
959
dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums);
960
unsigned int vs_open: 1;
961
unsigned int unlink_rm_ovrlp_save_undo: 1;
962
unsigned int inspiro: 1;
963
unsigned int lig_caret_cnt_fixed: 1;
967
int16 ttf_instrs_len;
968
int16 countermask_cnt;
969
HintMask *countermasks;
972
if (glyph->kerns != NULL) {
974
handle_kernpair(L, glyph->kerns);
975
lua_setfield(L, -2, "kerns");
977
if (glyph->vkerns != NULL) {
979
handle_kernpair(L, glyph->vkerns);
980
lua_setfield(L, -2, "vkerns");
983
if (glyph->dependents != NULL) {
985
handle_splinecharlist(L, glyph->dependents);
986
lua_setfield(L, -2, "dependents");
989
if (glyph->possub != NULL) {
991
handle_generic_pst(L, glyph->possub);
992
lua_setfield(L, -2, "lookups");
995
if (glyph->ligofme != NULL) {
997
handle_liglist(L, glyph->ligofme);
998
lua_setfield(L, -2, "ligatures");
1001
if (glyph->comment != NULL)
1002
dump_stringfield(L, "comment", glyph->comment);
1004
/* Color color; *//* dont care */
1006
if (glyph->anchor != NULL) {
1008
handle_anchorpoint(L, glyph->anchor);
1009
lua_setfield(L, -2, "anchors");
1012
if (glyph->altuni != NULL) {
1014
handle_altuni(L, glyph->altuni);
1015
lua_setfield(L, -2, "altuni");
1018
if (glyph->tex_height != TEX_UNDEF)
1019
dump_intfield(L, "tex_height", glyph->tex_height);
1020
if (glyph->tex_depth != TEX_UNDEF)
1021
dump_intfield(L, "tex_depth", glyph->tex_depth);
1023
dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape);
1024
if (glyph->italic_correction != TEX_UNDEF)
1025
dump_intfield(L, "italic_correction", glyph->italic_correction);
1026
if (glyph->top_accent_horiz != TEX_UNDEF)
1027
dump_intfield(L, "top_accent", glyph->top_accent_horiz);
1029
if (glyph->vert_variants != NULL) {
1031
handle_glyphvariants(L, glyph->vert_variants);
1032
lua_setfield(L, -2, "vert_variants");
1034
if (glyph->horiz_variants != NULL) {
1036
handle_glyphvariants(L, glyph->horiz_variants);
1037
lua_setfield(L, -2, "horiz_variants");
1039
if (glyph->mathkern != NULL) {
1041
handle_mathkern(L, glyph->mathkern);
1042
lua_setfield(L, -2, "mathkern");
1046
char *panose_values_0[] =
1047
{ "Any", "No Fit", "Text and Display", "Script", "Decorative",
1051
char *panose_values_1[] =
1052
{ "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove",
1053
"Obtuse Square Cove",
1054
"Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans",
1055
"Obtuse Sans", "Perp Sans", "Flared", "Rounded"
1058
char *panose_values_2[] =
1059
{ "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
1060
"Medium", "Demi", "Bold", "Heavy", "Black", "Nord"
1063
char *panose_values_3[] =
1064
{ "Any", "No Fit", "Old Style", "Modern", "Even Width",
1065
"Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced"
1068
char *panose_values_4[] =
1069
{ "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
1070
"Medium", "Medium High", "High", "Very High"
1073
char *panose_values_5[] =
1074
{ "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional",
1076
"Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal",
1080
char *panose_values_6[] =
1081
{ "Any", "No Fit", "Straight Arms/Horizontal", "Straight Arms/Wedge",
1082
"Straight Arms/Vertical",
1083
"Straight Arms/Single Serif", "Straight Arms/Double Serif",
1084
"Non-Straight Arms/Horizontal",
1085
"Non-Straight Arms/Wedge", "Non-Straight Arms/Vertical",
1086
"Non-Straight Arms/Single Serif",
1087
"Non-Straight Arms/Double Serif"
1090
char *panose_values_7[] =
1091
{ "Any", "No Fit", "Normal/Contact", "Normal/Weighted", "Normal/Boxed",
1093
"Normal/Rounded", "Normal/Off Center", "Normal/Square", "Oblique/Contact",
1095
"Oblique/Boxed", "Oblique/Flattened", "Oblique/Rounded",
1096
"Oblique/Off Center", "Oblique/Square"
1099
char *panose_values_8[] =
1100
{ "Any", "No Fit", "Standard/Trimmed", "Standard/Pointed",
1101
"Standard/Serifed", "High/Trimmed",
1102
"High/Pointed", "High/Serifed", "Constant/Trimmed", "Constant/Pointed",
1104
"Low/Trimmed", "Low/Pointed", "Low/Serifed"
1107
char *panose_values_9[] =
1108
{ "Any", "No Fit", "Constant/Small", "Constant/Standard",
1109
"Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large"
1113
void handle_pfminfo(lua_State * L, struct pfminfo pfm)
1116
dump_intfield(L, "pfmset", pfm.pfmset);
1117
dump_intfield(L, "winascent_add", pfm.winascent_add);
1118
dump_intfield(L, "windescent_add", pfm.windescent_add);
1119
dump_intfield(L, "hheadascent_add", pfm.hheadascent_add);
1120
dump_intfield(L, "hheaddescent_add", pfm.hheaddescent_add);
1121
dump_intfield(L, "typoascent_add", pfm.typoascent_add);
1122
dump_intfield(L, "typodescent_add", pfm.typodescent_add);
1123
dump_intfield(L, "subsuper_set", pfm.subsuper_set);
1124
dump_intfield(L, "panose_set", pfm.panose_set);
1125
dump_intfield(L, "hheadset", pfm.hheadset);
1126
dump_intfield(L, "vheadset", pfm.vheadset);
1127
dump_intfield(L, "pfmfamily", pfm.pfmfamily);
1128
dump_intfield(L, "weight", pfm.weight);
1129
dump_intfield(L, "width", pfm.width);
1130
dump_intfield(L, "avgwidth", pfm.avgwidth);
1131
dump_intfield(L, "firstchar", pfm.firstchar);
1132
dump_intfield(L, "lastchar", pfm.lastchar);
1133
lua_createtable(L, 0, 10);
1134
dump_enumfield(L, "familytype", pfm.panose[0], panose_values_0);
1135
dump_enumfield(L, "serifstyle", pfm.panose[1], panose_values_1);
1136
dump_enumfield(L, "weight", pfm.panose[2], panose_values_2);
1137
dump_enumfield(L, "proportion", pfm.panose[3], panose_values_3);
1138
dump_enumfield(L, "contrast", pfm.panose[4], panose_values_4);
1139
dump_enumfield(L, "strokevariation", pfm.panose[5], panose_values_5);
1140
dump_enumfield(L, "armstyle", pfm.panose[6], panose_values_6);
1141
dump_enumfield(L, "letterform", pfm.panose[7], panose_values_7);
1142
dump_enumfield(L, "midline", pfm.panose[8], panose_values_8);
1143
dump_enumfield(L, "xheight", pfm.panose[9], panose_values_9);
1144
lua_setfield(L, -2, "panose");
1146
dump_intfield(L, "fstype", pfm.fstype);
1147
dump_intfield(L, "linegap", pfm.linegap);
1148
dump_intfield(L, "vlinegap", pfm.vlinegap);
1149
dump_intfield(L, "hhead_ascent", pfm.hhead_ascent);
1150
dump_intfield(L, "hhead_descent", pfm.hhead_descent);
1151
dump_intfield(L, "hhead_descent", pfm.hhead_descent);
1152
dump_intfield(L, "os2_typoascent", pfm.os2_typoascent);
1153
dump_intfield(L, "os2_typodescent", pfm.os2_typodescent);
1154
dump_intfield(L, "os2_typolinegap", pfm.os2_typolinegap);
1155
dump_intfield(L, "os2_winascent", pfm.os2_winascent);
1156
dump_intfield(L, "os2_windescent", pfm.os2_windescent);
1157
dump_intfield(L, "os2_subxsize", pfm.os2_subxsize);
1158
dump_intfield(L, "os2_subysize", pfm.os2_subysize);
1159
dump_intfield(L, "os2_subxoff", pfm.os2_subxoff);
1160
dump_intfield(L, "os2_subyoff", pfm.os2_subyoff);
1161
dump_intfield(L, "os2_supxsize", pfm.os2_supxsize);
1162
dump_intfield(L, "os2_supysize", pfm.os2_supysize);
1163
dump_intfield(L, "os2_supxoff", pfm.os2_supxoff);
1164
dump_intfield(L, "os2_supyoff", pfm.os2_supyoff);
1165
dump_intfield(L, "os2_strikeysize", pfm.os2_strikeysize);
1166
dump_intfield(L, "os2_strikeypos", pfm.os2_strikeypos);
1167
dump_lstringfield(L, "os2_vendor", pfm.os2_vendor, 4);
1168
dump_intfield(L, "os2_family_class", pfm.os2_family_class);
1169
dump_intfield(L, "os2_xheight", pfm.os2_xheight);
1170
dump_intfield(L, "os2_capheight", pfm.os2_capheight);
1171
dump_intfield(L, "os2_defaultchar", pfm.os2_defaultchar);
1172
dump_intfield(L, "os2_breakchar", pfm.os2_breakchar);
1173
if (pfm.hascodepages) {
1175
lua_pushnumber(L, pfm.codepages[0]);
1176
lua_rawseti(L, -2, 1);
1177
lua_pushnumber(L, pfm.codepages[1]);
1178
lua_rawseti(L, -2, 2);
1179
lua_setfield(L, -2, "codepages");
1181
if (pfm.hasunicoderanges) {
1183
lua_pushnumber(L, pfm.unicoderanges[0]);
1184
lua_rawseti(L, -2, 1);
1185
lua_pushnumber(L, pfm.unicoderanges[1]);
1186
lua_rawseti(L, -2, 2);
1187
lua_pushnumber(L, pfm.unicoderanges[2]);
1188
lua_rawseti(L, -2, 3);
1189
lua_pushnumber(L, pfm.unicoderanges[3]);
1190
lua_rawseti(L, -2, 4);
1191
lua_setfield(L, -2, "unicoderanges");
1196
void do_handle_enc(lua_State * L, struct enc *enc)
1200
dump_stringfield(L, "enc_name", enc->enc_name);
1201
dump_intfield(L, "char_cnt", enc->char_cnt);
1203
lua_checkstack(L, 4);
1204
if (enc->char_cnt && enc->unicode != NULL) {
1205
lua_createtable(L, enc->char_cnt, 1);
1206
for (i = 0; i < enc->char_cnt; i++) {
1207
lua_pushnumber(L, i);
1208
lua_pushnumber(L, enc->unicode[i]);
1211
lua_setfield(L, -2, "unicode");
1214
if (enc->char_cnt && enc->psnames != NULL) {
1215
lua_createtable(L, enc->char_cnt, 1);
1216
for (i = 0; i < enc->char_cnt; i++) {
1217
lua_pushnumber(L, i);
1218
lua_pushstring(L, enc->psnames[i]);
1221
lua_setfield(L, -2, "psnames");
1223
dump_intfield(L, "builtin", enc->builtin);
1224
dump_intfield(L, "hidden", enc->hidden);
1225
dump_intfield(L, "only_1byte", enc->only_1byte);
1226
dump_intfield(L, "has_1byte", enc->has_1byte);
1227
dump_intfield(L, "has_2byte", enc->has_2byte);
1228
dump_cond_intfield(L, "is_unicodebmp", enc->is_unicodebmp);
1229
dump_cond_intfield(L, "is_unicodefull", enc->is_unicodefull);
1230
dump_cond_intfield(L, "is_custom", enc->is_custom);
1231
dump_cond_intfield(L, "is_original", enc->is_original);
1232
dump_cond_intfield(L, "is_compact", enc->is_compact);
1233
dump_cond_intfield(L, "is_japanese", enc->is_japanese);
1234
dump_cond_intfield(L, "is_korean", enc->is_korean);
1235
dump_cond_intfield(L, "is_tradchinese", enc->is_tradchinese);
1236
dump_cond_intfield(L, "is_simplechinese", enc->is_simplechinese);
1238
if (enc->iso_2022_escape_len > 0) {
1239
dump_lstringfield(L, "iso_2022_escape", enc->iso_2022_escape,
1240
enc->iso_2022_escape_len);
1242
dump_intfield(L, "low_page", enc->low_page);
1243
dump_intfield(L, "high_page", enc->high_page);
1245
dump_stringfield(L, "iconv_name", enc->iconv_name);
1247
dump_intfield(L, "char_max", enc->char_max);
1250
void handle_enc(lua_State * L, struct enc *enc)
1253
NESTED_TABLE(do_handle_enc, enc, 24);
1256
void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
1259
dump_intfield(L, "enccount", map->enccount);
1260
dump_intfield(L, "encmax", map->encmax);
1261
dump_intfield(L, "backmax", map->backmax);
1262
/*dump_intfield(L,"ticked", map->ticked) ; */
1263
if (map->remap != NULL) {
1265
dump_intfield(L, "firstenc", map->remap->firstenc);
1266
dump_intfield(L, "lastenc", map->remap->lastenc);
1267
dump_intfield(L, "infont", map->remap->infont);
1268
lua_setfield(L, -2, "remap");
1270
lua_checkstack(L, 4);
1271
if (map->encmax > 0 && map->map != NULL) {
1272
lua_createtable(L, map->encmax, 1);
1273
for (i = 0; i < map->encmax; i++) {
1274
if (map->map[i] != -1) {
1275
int l = map->map[i];
1276
lua_pushnumber(L, i);
1278
lua_pushnumber(L, (l + 1));
1280
lua_pushnumber(L, l);
1284
lua_setfield(L, -2, "map");
1287
if (map->backmax > 0 && map->backmap != NULL) {
1289
for (i = 0; i < map->backmax; i++) {
1290
if (map->backmap[i] != -1) { /* TODO: check this, because valgrind sometimes says
1291
"Conditional jump or move depends on uninitialised value(s)"
1295
lua_pushnumber(L, (i + 1));
1297
lua_pushnumber(L, i);
1298
lua_pushnumber(L, map->backmap[i]);
1302
lua_setfield(L, -2, "backmap");
1305
if (map->enc != NULL) {
1307
handle_enc(L, map->enc);
1308
lua_setfield(L, -2, "enc");
1312
static void handle_psdict(lua_State * L, struct psdict *private)
1315
if (private->keys != NULL && private->values != NULL) {
1316
for (k = 0; k < private->next; k++) {
1317
lua_pushstring(L, private->keys[k]);
1318
lua_pushstring(L, private->values[k]);
1324
void do_handle_ttflangname(lua_State * L, struct ttflangname *names)
1327
dump_stringfield(L, "lang", (char *) MSLangString(names->lang));
1328
lua_checkstack(L, 4);
1329
lua_createtable(L, 0, ttf_namemax);
1330
for (k = 0; k < ttf_namemax; k++) {
1331
lua_pushstring(L, ttfnames_enum[k]);
1332
lua_pushstring(L, names->names[k]);
1335
lua_setfield(L, -2, "names");
1339
void handle_ttflangname(lua_State * L, struct ttflangname *names)
1341
struct ttflangname *next;
1342
NESTED_TABLE(do_handle_ttflangname, names, 2);
1346
void do_handle_anchorclass(lua_State * L, struct anchorclass *anchor)
1349
dump_stringfield(L, "name", anchor->name);
1350
dump_subtable_name(L, "lookup", anchor->subtable);
1351
dump_enumfield(L, "type", anchor->type, anchorclass_type_enum);
1352
/* uint8 has_base; */
1353
/* uint8 processed, has_mark, matches, ac_num; */
1357
void handle_anchorclass(lua_State * L, struct anchorclass *anchor)
1359
struct anchorclass *next;
1360
NESTED_TABLE(do_handle_anchorclass, anchor, 10);
1363
void do_handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab)
1366
dump_tag(L, "tag", ttf_tab->tag);
1367
dump_intfield(L, "len", ttf_tab->len);
1368
dump_intfield(L, "maxlen", ttf_tab->maxlen);
1369
dump_lstringfield(L, "data", (char *) ttf_tab->data, ttf_tab->len);
1372
void handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab)
1374
struct ttf_table *next;
1375
NESTED_TABLE(do_handle_ttf_table, ttf_tab, 4);
1378
void do_handle_kernclass(lua_State * L, struct kernclass *kerns)
1383
* dump_intfield(L,"first_cnt", kerns->first_cnt);
1384
* dump_intfield(L,"second_cnt", kerns->second_cnt);
1386
lua_checkstack(L, 4);
1387
lua_createtable(L, kerns->first_cnt, 1);
1388
for (k = 0; k < kerns->first_cnt; k++) {
1389
lua_pushnumber(L, (k + 1));
1390
lua_pushstring(L, kerns->firsts[k]);
1393
lua_setfield(L, -2, "firsts");
1395
lua_createtable(L, kerns->second_cnt, 1);
1396
for (k = 0; k < kerns->second_cnt; k++) {
1397
lua_pushnumber(L, (k + 1));
1398
lua_pushstring(L, kerns->seconds[k]);
1401
lua_setfield(L, -2, "seconds");
1403
dump_subtable_name(L, "lookup", kerns->subtable);
1404
/*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */
1406
lua_createtable(L, kerns->second_cnt * kerns->first_cnt, 1);
1407
for (k = 0; k < (kerns->second_cnt * kerns->first_cnt); k++) {
1408
if (kerns->offsets[k] != 0) {
1409
lua_pushnumber(L, (k + 1));
1410
lua_pushnumber(L, kerns->offsets[k]);
1414
lua_setfield(L, -2, "offsets");
1418
void handle_kernclass(lua_State * L, struct kernclass *kerns)
1420
struct kernclass *next;
1421
NESTED_TABLE(do_handle_kernclass, kerns, 8);
1335
1454
lua_setfield(L,-2,s); } }
1338
void handle_fpst_rule (lua_State *L, struct fpst_rule *rule, int format) {
1342
if (format == pst_glyphs) {
1345
dump_stringfield(L,"names",rule->u.glyph.names);
1346
dump_stringfield(L,"back",rule->u.glyph.back);
1347
dump_stringfield(L,"fore",rule->u.glyph.fore);
1348
lua_setfield(L,-2,fpossub_format_enum[format]);
1350
} else if (format == pst_class) {
1353
DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt,rule->u.class.nclasses);
1354
DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt,rule->u.class.bclasses);
1355
DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt,rule->u.class.fclasses);
1457
void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format)
1462
if (format == pst_glyphs) {
1465
dump_stringfield(L, "names", rule->u.glyph.names);
1466
dump_stringfield(L, "back", rule->u.glyph.back);
1467
dump_stringfield(L, "fore", rule->u.glyph.fore);
1468
lua_setfield(L, -2, fpossub_format_enum[format]);
1470
} else if (format == pst_class) {
1473
DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt,
1474
rule->u.class.nclasses);
1475
DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt, rule->u.class.bclasses);
1476
DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt, rule->u.class.fclasses);
1357
DUMP_NUMBER_ARRAY("allclasses", 0,rule->u.class.allclasses);
1478
DUMP_NUMBER_ARRAY("allclasses", 0, rule->u.class.allclasses);
1359
lua_setfield(L,-2,fpossub_format_enum[format]);
1361
} else if (format == pst_coverage) {
1364
DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt,rule->u.coverage.ncovers);
1365
DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt,rule->u.coverage.bcovers);
1366
DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt,rule->u.coverage.fcovers);
1367
lua_setfield(L,-2,fpossub_format_enum[format]);
1369
} else if (format == pst_reversecoverage) {
1372
DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1,rule->u.rcoverage.ncovers);
1373
DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt,rule->u.rcoverage.bcovers);
1374
DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt,rule->u.rcoverage.fcovers);
1375
dump_stringfield(L,"replacements", rule->u.rcoverage.replacements);
1376
lua_setfield(L,-2,fpossub_format_enum[format]);
1378
fprintf(stderr,"handle_fpst_rule(): Unknown rule format: %d\n",format);
1381
if (rule->lookup_cnt>0) {
1383
for (k=0;k<rule->lookup_cnt;k++) {
1384
lua_pushnumber(L,(rule->lookups[k].seq+1));
1385
if (rule->lookups[k].lookup!=NULL) {
1386
lua_pushstring(L,rule->lookups[k].lookup->lookup_name);
1392
lua_setfield(L,-2,"lookups");
1394
/*fprintf(stderr,"handle_fpst_rule(): No lookups?\n");*/
1399
do_handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) {
1402
if (fpst->type>LAST_POSSUB_TYPE_ENUM) {
1403
dump_intfield(L,"type", fpst->type);
1405
dump_enumfield(L,"type", fpst->type, possub_type_enum);
1407
dump_enumfield(L,"format", fpst->format, fpossub_format_enum);
1409
if (fpst->format==pst_class) {
1410
DUMP_EXACT_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass);
1411
DUMP_EXACT_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass);
1412
DUMP_EXACT_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass);
1414
DUMP_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass);
1415
DUMP_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass);
1416
DUMP_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass);
1419
lua_checkstack(L,4);
1420
if (fpst->rule_cnt>0) {
1421
lua_createtable(L,fpst->rule_cnt,1);
1422
for (k=0;k<fpst->rule_cnt;k++) {
1423
lua_pushnumber(L,(k+1));
1425
handle_fpst_rule(L,&(fpst->rules[k]),fpst->format);
1428
lua_setfield(L,-2,"rules");
1430
/*dump_intfield (L,"ticked", fpst->ticked);*/
1434
handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) {
1435
struct generic_fpst *next;
1437
lua_checkstack(L,3);
1438
if (fpst->subtable != NULL &&
1439
fpst->subtable->subtable_name != NULL) {
1440
lua_pushstring(L,fpst->subtable->subtable_name);
1442
lua_pushnumber(L,k); k++;
1444
lua_createtable(L,0,10);
1445
do_handle_generic_fpst(L,fpst);
1448
while (next != NULL) {
1449
lua_checkstack(L,3);
1450
if (next->subtable != NULL &&
1451
next->subtable->subtable_name != NULL) {
1452
lua_pushstring(L,next->subtable->subtable_name);
1454
lua_pushnumber(L,k); k++;
1456
lua_createtable(L,0,10);
1457
do_handle_generic_fpst(L, next);
1464
do_handle_otfname (lua_State *L, struct otfname *oname) {
1465
dump_intfield(L,"lang", oname->lang);
1466
dump_stringfield(L,"name", oname->name);
1470
handle_otfname (lua_State *L, struct otfname *oname) {
1471
struct otfname *next;
1472
NESTED_TABLE(do_handle_otfname,oname,2);
1476
do_handle_macname (lua_State *L, struct macname *featname) {
1477
dump_intfield(L,"enc", featname->enc);
1478
dump_intfield(L,"lang", featname->lang);
1479
dump_stringfield(L,"name", featname->name);
1483
handle_macname (lua_State *L, struct macname *featname) {
1484
struct macname *next;
1485
NESTED_TABLE(do_handle_macname,featname,3);
1489
do_handle_macsetting (lua_State *L, struct macsetting *settings) {
1490
dump_intfield(L,"setting", settings->setting);
1491
dump_intfield(L,"strid", settings->strid);
1492
dump_intfield(L,"initially_enabled", settings->initially_enabled);
1493
if (settings->setname != NULL) {
1495
handle_macname(L,settings->setname);
1496
lua_setfield(L,-2,"setname");
1501
handle_macsetting (lua_State *L, struct macsetting *settings) {
1502
struct macsetting *next;
1503
NESTED_TABLE(do_handle_macsetting,settings,4);
1508
do_handle_macfeat (lua_State *L, struct macfeat *features) {
1510
dump_intfield(L,"feature", features->feature);
1511
dump_intfield(L,"ismutex", features->ismutex);
1512
dump_intfield(L,"default_setting", features->default_setting);
1513
dump_intfield(L,"strid", features->strid);
1515
if (features->featname != NULL) {
1517
handle_macname(L,features->featname);
1518
lua_setfield(L,-2,"featname");
1521
if (features->settings != NULL) {
1523
handle_macsetting(L,features->settings);
1524
lua_setfield(L,-2,"settings");
1529
handle_macfeat (lua_State *L, struct macfeat *features) {
1530
struct macfeat *next;
1531
NESTED_TABLE(do_handle_macfeat,features,6);
1480
lua_setfield(L, -2, fpossub_format_enum[format]);
1482
} else if (format == pst_coverage) {
1485
DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt,
1486
rule->u.coverage.ncovers);
1487
DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt,
1488
rule->u.coverage.bcovers);
1489
DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt,
1490
rule->u.coverage.fcovers);
1491
lua_setfield(L, -2, fpossub_format_enum[format]);
1493
} else if (format == pst_reversecoverage) {
1496
DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1,
1497
rule->u.rcoverage.ncovers);
1498
DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt,
1499
rule->u.rcoverage.bcovers);
1500
DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt,
1501
rule->u.rcoverage.fcovers);
1502
dump_stringfield(L, "replacements", rule->u.rcoverage.replacements);
1503
lua_setfield(L, -2, fpossub_format_enum[format]);
1505
fprintf(stderr, "handle_fpst_rule(): Unknown rule format: %d\n",
1509
if (rule->lookup_cnt > 0) {
1511
for (k = 0; k < rule->lookup_cnt; k++) {
1512
lua_pushnumber(L, (rule->lookups[k].seq + 1));
1513
if (rule->lookups[k].lookup != NULL) {
1514
lua_pushstring(L, rule->lookups[k].lookup->lookup_name);
1520
lua_setfield(L, -2, "lookups");
1522
/*fprintf(stderr,"handle_fpst_rule(): No lookups?\n"); */
1526
void do_handle_generic_fpst(lua_State * L, struct generic_fpst *fpst)
1530
if (fpst->type > LAST_POSSUB_TYPE_ENUM) {
1531
dump_intfield(L, "type", fpst->type);
1533
dump_enumfield(L, "type", fpst->type, possub_type_enum);
1535
dump_enumfield(L, "format", fpst->format, fpossub_format_enum);
1537
if (fpst->format == pst_class) {
1538
DUMP_EXACT_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass);
1539
DUMP_EXACT_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass);
1540
DUMP_EXACT_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass);
1542
DUMP_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass);
1543
DUMP_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass);
1544
DUMP_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass);
1547
lua_checkstack(L, 4);
1548
if (fpst->rule_cnt > 0) {
1549
lua_createtable(L, fpst->rule_cnt, 1);
1550
for (k = 0; k < fpst->rule_cnt; k++) {
1551
lua_pushnumber(L, (k + 1));
1553
handle_fpst_rule(L, &(fpst->rules[k]), fpst->format);
1556
lua_setfield(L, -2, "rules");
1558
/*dump_intfield (L,"ticked", fpst->ticked); */
1561
void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst)
1563
struct generic_fpst *next;
1565
lua_checkstack(L, 3);
1566
if (fpst->subtable != NULL && fpst->subtable->subtable_name != NULL) {
1567
lua_pushstring(L, fpst->subtable->subtable_name);
1569
lua_pushnumber(L, k);
1572
lua_createtable(L, 0, 10);
1573
do_handle_generic_fpst(L, fpst);
1576
while (next != NULL) {
1577
lua_checkstack(L, 3);
1578
if (next->subtable != NULL && next->subtable->subtable_name != NULL) {
1579
lua_pushstring(L, next->subtable->subtable_name);
1581
lua_pushnumber(L, k);
1584
lua_createtable(L, 0, 10);
1585
do_handle_generic_fpst(L, next);
1591
void do_handle_otfname(lua_State * L, struct otfname *oname)
1593
dump_intfield(L, "lang", oname->lang);
1594
dump_stringfield(L, "name", oname->name);
1597
void handle_otfname(lua_State * L, struct otfname *oname)
1599
struct otfname *next;
1600
NESTED_TABLE(do_handle_otfname, oname, 2);
1603
void do_handle_macname(lua_State * L, struct macname *featname)
1605
dump_intfield(L, "enc", featname->enc);
1606
dump_intfield(L, "lang", featname->lang);
1607
dump_stringfield(L, "name", featname->name);
1610
void handle_macname(lua_State * L, struct macname *featname)
1612
struct macname *next;
1613
NESTED_TABLE(do_handle_macname, featname, 3);
1616
void do_handle_macsetting(lua_State * L, struct macsetting *settings)
1618
dump_intfield(L, "setting", settings->setting);
1619
dump_intfield(L, "strid", settings->strid);
1620
dump_intfield(L, "initially_enabled", settings->initially_enabled);
1621
if (settings->setname != NULL) {
1623
handle_macname(L, settings->setname);
1624
lua_setfield(L, -2, "setname");
1628
void handle_macsetting(lua_State * L, struct macsetting *settings)
1630
struct macsetting *next;
1631
NESTED_TABLE(do_handle_macsetting, settings, 4);
1635
void do_handle_macfeat(lua_State * L, struct macfeat *features)
1638
dump_intfield(L, "feature", features->feature);
1639
dump_intfield(L, "ismutex", features->ismutex);
1640
dump_intfield(L, "default_setting", features->default_setting);
1641
dump_intfield(L, "strid", features->strid);
1643
if (features->featname != NULL) {
1645
handle_macname(L, features->featname);
1646
lua_setfield(L, -2, "featname");
1649
if (features->settings != NULL) {
1651
handle_macsetting(L, features->settings);
1652
lua_setfield(L, -2, "settings");
1656
void handle_macfeat(lua_State * L, struct macfeat *features)
1658
struct macfeat *next;
1659
NESTED_TABLE(do_handle_macfeat, features, 6);
1564
1692
0x3fff value offset
1566
1694
/* to be tested */
1568
do_handle_generic_asm (lua_State *L, struct generic_asm *sm) {
1571
dump_enumfield (L,"type", sm->type, asm_type_enum);
1573
dump_subtable_name(L, "lookup", sm->subtable);
1576
if (sm->flags & asm_vert) {
1577
lua_pushstring(L,"vert"); lua_pushboolean(L,1); lua_rawset(L,-3);
1579
if (sm->flags & asm_descending) {
1580
lua_pushstring(L,"descending"); lua_pushboolean(L,1); lua_rawset(L,-3);
1582
if (sm->flags & asm_always) {
1583
lua_pushstring(L,"always"); lua_pushboolean(L,1); lua_rawset(L,-3);
1585
lua_setfield(L,-2,"flags");
1587
if (sm->class_cnt >0) {
1589
for (i=0; i<sm->class_cnt; i++) {
1590
if (sm->classes[i]!=NULL) {
1591
lua_pushstring(L,sm->classes[i]);
1592
lua_rawseti(L,-2,(i+1));
1595
lua_setfield(L,-2,"classes");
1597
if (sm->state_cnt >0) {
1599
for (i=0; i<(sm->class_cnt * sm->state_cnt); i++) {
1600
struct asm_state as = sm->state[i];
1601
dump_intfield(L,"next", as.next_state);
1602
dump_intfield(L,"flags", as.flags);
1603
if (sm->type==asm_context) {
1605
if (as.u.context.mark_lookup!=NULL)
1606
dump_stringfield(L,"mark", as.u.context.mark_lookup->lookup_name); /* backref */
1607
if (as.u.context.cur_lookup!=NULL)
1608
dump_stringfield(L,"cur", as.u.context.cur_lookup->lookup_name); /* backref */
1609
lua_setfield(L,-2,"context");
1610
} else if (sm->type==asm_insert) {
1612
lua_pushstring(L, as.u.insert.mark_ins);
1613
lua_setfield(L, -2, "mark");
1614
lua_pushstring(L, as.u.insert.cur_ins);
1615
lua_setfield(L, -2, "cur");
1616
lua_setfield(L,-2,"insert");
1617
} else if (sm->type==asm_kern) {
1619
for (k=0;k<as.u.kern.kcnt;k++) {
1620
lua_pushnumber(L,as.u.kern.kerns[k]);
1621
lua_rawseti(L,-2, (k+1));
1623
lua_setfield(L,-2,"kerns");
1626
lua_setfield(L,-2,"states");
1631
handle_generic_asm (lua_State *L, struct generic_asm *sm) {
1632
struct generic_asm *next;
1633
NESTED_TABLE(do_handle_generic_asm,sm,6);
1639
void handle_MATH (lua_State *L, struct MATH *MATH) {
1640
dump_intfield(L,"ScriptPercentScaleDown",MATH->ScriptPercentScaleDown);
1641
dump_intfield(L,"ScriptScriptPercentScaleDown",MATH->ScriptScriptPercentScaleDown);
1642
dump_intfield(L,"DelimitedSubFormulaMinHeight",MATH->DelimitedSubFormulaMinHeight);
1643
dump_intfield(L,"DisplayOperatorMinHeight",MATH->DisplayOperatorMinHeight);
1644
dump_intfield(L,"MathLeading",MATH->MathLeading);
1645
dump_intfield(L,"AxisHeight",MATH->AxisHeight);
1646
dump_intfield(L,"AccentBaseHeight",MATH->AccentBaseHeight);
1647
dump_intfield(L,"FlattenedAccentBaseHeight",MATH->FlattenedAccentBaseHeight);
1648
dump_intfield(L,"SubscriptShiftDown",MATH->SubscriptShiftDown);
1649
dump_intfield(L,"SubscriptTopMax",MATH->SubscriptTopMax);
1650
dump_intfield(L,"SubscriptBaselineDropMin",MATH->SubscriptBaselineDropMin);
1651
dump_intfield(L,"SuperscriptShiftUp",MATH->SuperscriptShiftUp);
1652
dump_intfield(L,"SuperscriptShiftUpCramped",MATH->SuperscriptShiftUpCramped);
1653
dump_intfield(L,"SuperscriptBottomMin",MATH->SuperscriptBottomMin);
1654
dump_intfield(L,"SuperscriptBaselineDropMax",MATH->SuperscriptBaselineDropMax);
1655
dump_intfield(L,"SubSuperscriptGapMin",MATH->SubSuperscriptGapMin);
1656
dump_intfield(L,"SuperscriptBottomMaxWithSubscript",MATH->SuperscriptBottomMaxWithSubscript);
1657
dump_intfield(L,"SpaceAfterScript",MATH->SpaceAfterScript);
1658
dump_intfield(L,"UpperLimitGapMin",MATH->UpperLimitGapMin);
1659
dump_intfield(L,"UpperLimitBaselineRiseMin",MATH->UpperLimitBaselineRiseMin);
1660
dump_intfield(L,"LowerLimitGapMin",MATH->LowerLimitGapMin);
1661
dump_intfield(L,"LowerLimitBaselineDropMin",MATH->LowerLimitBaselineDropMin);
1662
dump_intfield(L,"StackTopShiftUp",MATH->StackTopShiftUp);
1663
dump_intfield(L,"StackTopDisplayStyleShiftUp",MATH->StackTopDisplayStyleShiftUp);
1664
dump_intfield(L,"StackBottomShiftDown",MATH->StackBottomShiftDown);
1665
dump_intfield(L,"StackBottomDisplayStyleShiftDown",MATH->StackBottomDisplayStyleShiftDown);
1666
dump_intfield(L,"StackGapMin",MATH->StackGapMin);
1667
dump_intfield(L,"StackDisplayStyleGapMin",MATH->StackDisplayStyleGapMin);
1668
dump_intfield(L,"StretchStackTopShiftUp",MATH->StretchStackTopShiftUp);
1669
dump_intfield(L,"StretchStackBottomShiftDown",MATH->StretchStackBottomShiftDown);
1670
dump_intfield(L,"StretchStackGapAboveMin",MATH->StretchStackGapAboveMin);
1671
dump_intfield(L,"StretchStackGapBelowMin",MATH->StretchStackGapBelowMin);
1672
dump_intfield(L,"FractionNumeratorShiftUp",MATH->FractionNumeratorShiftUp);
1673
dump_intfield(L,"FractionNumeratorDisplayStyleShiftUp",MATH->FractionNumeratorDisplayStyleShiftUp);
1674
dump_intfield(L,"FractionDenominatorShiftDown",MATH->FractionDenominatorShiftDown);
1675
dump_intfield(L,"FractionDenominatorDisplayStyleShiftDown",MATH->FractionDenominatorDisplayStyleShiftDown);
1676
dump_intfield(L,"FractionNumeratorGapMin",MATH->FractionNumeratorGapMin);
1677
dump_intfield(L,"FractionNumeratorDisplayStyleGapMin",MATH->FractionNumeratorDisplayStyleGapMin);
1678
dump_intfield(L,"FractionRuleThickness",MATH->FractionRuleThickness);
1679
dump_intfield(L,"FractionDenominatorGapMin",MATH->FractionDenominatorGapMin);
1680
dump_intfield(L,"FractionDenominatorDisplayStyleGapMin",MATH->FractionDenominatorDisplayStyleGapMin);
1681
dump_intfield(L,"SkewedFractionHorizontalGap",MATH->SkewedFractionHorizontalGap);
1682
dump_intfield(L,"SkewedFractionVerticalGap",MATH->SkewedFractionVerticalGap);
1683
dump_intfield(L,"OverbarVerticalGap",MATH->OverbarVerticalGap);
1684
dump_intfield(L,"OverbarRuleThickness",MATH->OverbarRuleThickness);
1685
dump_intfield(L,"OverbarExtraAscender",MATH->OverbarExtraAscender);
1686
dump_intfield(L,"UnderbarVerticalGap",MATH->UnderbarVerticalGap);
1687
dump_intfield(L,"UnderbarRuleThickness",MATH->UnderbarRuleThickness);
1688
dump_intfield(L,"UnderbarExtraDescender",MATH->UnderbarExtraDescender);
1689
dump_intfield(L,"RadicalVerticalGap",MATH->RadicalVerticalGap);
1690
dump_intfield(L,"RadicalDisplayStyleVerticalGap",MATH->RadicalDisplayStyleVerticalGap);
1691
dump_intfield(L,"RadicalRuleThickness",MATH->RadicalRuleThickness);
1692
dump_intfield(L,"RadicalExtraAscender",MATH->RadicalExtraAscender);
1693
dump_intfield(L,"RadicalKernBeforeDegree",MATH->RadicalKernBeforeDegree);
1694
dump_intfield(L,"RadicalKernAfterDegree",MATH->RadicalKernAfterDegree);
1695
dump_intfield(L,"RadicalDegreeBottomRaisePercent",MATH->RadicalDegreeBottomRaisePercent);
1696
dump_intfield(L,"MinConnectorOverlap",MATH->MinConnectorOverlap);
1695
void do_handle_generic_asm(lua_State * L, struct generic_asm *sm)
1699
dump_enumfield(L, "type", sm->type, asm_type_enum);
1701
dump_subtable_name(L, "lookup", sm->subtable);
1704
if (sm->flags & asm_vert) {
1705
lua_pushstring(L, "vert");
1706
lua_pushboolean(L, 1);
1709
if (sm->flags & asm_descending) {
1710
lua_pushstring(L, "descending");
1711
lua_pushboolean(L, 1);
1714
if (sm->flags & asm_always) {
1715
lua_pushstring(L, "always");
1716
lua_pushboolean(L, 1);
1719
lua_setfield(L, -2, "flags");
1721
if (sm->class_cnt > 0) {
1723
for (i = 0; i < sm->class_cnt; i++) {
1724
if (sm->classes[i] != NULL) {
1725
lua_pushstring(L, sm->classes[i]);
1726
lua_rawseti(L, -2, (i + 1));
1729
lua_setfield(L, -2, "classes");
1731
if (sm->state_cnt > 0) {
1733
for (i = 0; i < (sm->class_cnt * sm->state_cnt); i++) {
1734
struct asm_state as = sm->state[i];
1735
dump_intfield(L, "next", as.next_state);
1736
dump_intfield(L, "flags", as.flags);
1737
if (sm->type == asm_context) {
1739
if (as.u.context.mark_lookup != NULL)
1740
dump_stringfield(L, "mark", as.u.context.mark_lookup->lookup_name); /* backref */
1741
if (as.u.context.cur_lookup != NULL)
1742
dump_stringfield(L, "cur", as.u.context.cur_lookup->lookup_name); /* backref */
1743
lua_setfield(L, -2, "context");
1744
} else if (sm->type == asm_insert) {
1746
lua_pushstring(L, as.u.insert.mark_ins);
1747
lua_setfield(L, -2, "mark");
1748
lua_pushstring(L, as.u.insert.cur_ins);
1749
lua_setfield(L, -2, "cur");
1750
lua_setfield(L, -2, "insert");
1751
} else if (sm->type == asm_kern) {
1753
for (k = 0; k < as.u.kern.kcnt; k++) {
1754
lua_pushnumber(L, as.u.kern.kerns[k]);
1755
lua_rawseti(L, -2, (k + 1));
1757
lua_setfield(L, -2, "kerns");
1760
lua_setfield(L, -2, "states");
1764
void handle_generic_asm(lua_State * L, struct generic_asm *sm)
1766
struct generic_asm *next;
1767
NESTED_TABLE(do_handle_generic_asm, sm, 6);
1773
void handle_MATH(lua_State * L, struct MATH *MATH)
1775
dump_intfield(L, "ScriptPercentScaleDown", MATH->ScriptPercentScaleDown);
1776
dump_intfield(L, "ScriptScriptPercentScaleDown",
1777
MATH->ScriptScriptPercentScaleDown);
1778
dump_intfield(L, "DelimitedSubFormulaMinHeight",
1779
MATH->DelimitedSubFormulaMinHeight);
1780
dump_intfield(L, "DisplayOperatorMinHeight",
1781
MATH->DisplayOperatorMinHeight);
1782
dump_intfield(L, "MathLeading", MATH->MathLeading);
1783
dump_intfield(L, "AxisHeight", MATH->AxisHeight);
1784
dump_intfield(L, "AccentBaseHeight", MATH->AccentBaseHeight);
1785
dump_intfield(L, "FlattenedAccentBaseHeight",
1786
MATH->FlattenedAccentBaseHeight);
1787
dump_intfield(L, "SubscriptShiftDown", MATH->SubscriptShiftDown);
1788
dump_intfield(L, "SubscriptTopMax", MATH->SubscriptTopMax);
1789
dump_intfield(L, "SubscriptBaselineDropMin",
1790
MATH->SubscriptBaselineDropMin);
1791
dump_intfield(L, "SuperscriptShiftUp", MATH->SuperscriptShiftUp);
1792
dump_intfield(L, "SuperscriptShiftUpCramped",
1793
MATH->SuperscriptShiftUpCramped);
1794
dump_intfield(L, "SuperscriptBottomMin", MATH->SuperscriptBottomMin);
1795
dump_intfield(L, "SuperscriptBaselineDropMax",
1796
MATH->SuperscriptBaselineDropMax);
1797
dump_intfield(L, "SubSuperscriptGapMin", MATH->SubSuperscriptGapMin);
1798
dump_intfield(L, "SuperscriptBottomMaxWithSubscript",
1799
MATH->SuperscriptBottomMaxWithSubscript);
1800
dump_intfield(L, "SpaceAfterScript", MATH->SpaceAfterScript);
1801
dump_intfield(L, "UpperLimitGapMin", MATH->UpperLimitGapMin);
1802
dump_intfield(L, "UpperLimitBaselineRiseMin",
1803
MATH->UpperLimitBaselineRiseMin);
1804
dump_intfield(L, "LowerLimitGapMin", MATH->LowerLimitGapMin);
1805
dump_intfield(L, "LowerLimitBaselineDropMin",
1806
MATH->LowerLimitBaselineDropMin);
1807
dump_intfield(L, "StackTopShiftUp", MATH->StackTopShiftUp);
1808
dump_intfield(L, "StackTopDisplayStyleShiftUp",
1809
MATH->StackTopDisplayStyleShiftUp);
1810
dump_intfield(L, "StackBottomShiftDown", MATH->StackBottomShiftDown);
1811
dump_intfield(L, "StackBottomDisplayStyleShiftDown",
1812
MATH->StackBottomDisplayStyleShiftDown);
1813
dump_intfield(L, "StackGapMin", MATH->StackGapMin);
1814
dump_intfield(L, "StackDisplayStyleGapMin", MATH->StackDisplayStyleGapMin);
1815
dump_intfield(L, "StretchStackTopShiftUp", MATH->StretchStackTopShiftUp);
1816
dump_intfield(L, "StretchStackBottomShiftDown",
1817
MATH->StretchStackBottomShiftDown);
1818
dump_intfield(L, "StretchStackGapAboveMin", MATH->StretchStackGapAboveMin);
1819
dump_intfield(L, "StretchStackGapBelowMin", MATH->StretchStackGapBelowMin);
1820
dump_intfield(L, "FractionNumeratorShiftUp",
1821
MATH->FractionNumeratorShiftUp);
1822
dump_intfield(L, "FractionNumeratorDisplayStyleShiftUp",
1823
MATH->FractionNumeratorDisplayStyleShiftUp);
1824
dump_intfield(L, "FractionDenominatorShiftDown",
1825
MATH->FractionDenominatorShiftDown);
1826
dump_intfield(L, "FractionDenominatorDisplayStyleShiftDown",
1827
MATH->FractionDenominatorDisplayStyleShiftDown);
1828
dump_intfield(L, "FractionNumeratorGapMin", MATH->FractionNumeratorGapMin);
1829
dump_intfield(L, "FractionNumeratorDisplayStyleGapMin",
1830
MATH->FractionNumeratorDisplayStyleGapMin);
1831
dump_intfield(L, "FractionRuleThickness", MATH->FractionRuleThickness);
1832
dump_intfield(L, "FractionDenominatorGapMin",
1833
MATH->FractionDenominatorGapMin);
1834
dump_intfield(L, "FractionDenominatorDisplayStyleGapMin",
1835
MATH->FractionDenominatorDisplayStyleGapMin);
1836
dump_intfield(L, "SkewedFractionHorizontalGap",
1837
MATH->SkewedFractionHorizontalGap);
1838
dump_intfield(L, "SkewedFractionVerticalGap",
1839
MATH->SkewedFractionVerticalGap);
1840
dump_intfield(L, "OverbarVerticalGap", MATH->OverbarVerticalGap);
1841
dump_intfield(L, "OverbarRuleThickness", MATH->OverbarRuleThickness);
1842
dump_intfield(L, "OverbarExtraAscender", MATH->OverbarExtraAscender);
1843
dump_intfield(L, "UnderbarVerticalGap", MATH->UnderbarVerticalGap);
1844
dump_intfield(L, "UnderbarRuleThickness", MATH->UnderbarRuleThickness);
1845
dump_intfield(L, "UnderbarExtraDescender", MATH->UnderbarExtraDescender);
1846
dump_intfield(L, "RadicalVerticalGap", MATH->RadicalVerticalGap);
1847
dump_intfield(L, "RadicalDisplayStyleVerticalGap",
1848
MATH->RadicalDisplayStyleVerticalGap);
1849
dump_intfield(L, "RadicalRuleThickness", MATH->RadicalRuleThickness);
1850
dump_intfield(L, "RadicalExtraAscender", MATH->RadicalExtraAscender);
1851
dump_intfield(L, "RadicalKernBeforeDegree", MATH->RadicalKernBeforeDegree);
1852
dump_intfield(L, "RadicalKernAfterDegree", MATH->RadicalKernAfterDegree);
1853
dump_intfield(L, "RadicalDegreeBottomRaisePercent",
1854
MATH->RadicalDegreeBottomRaisePercent);
1855
dump_intfield(L, "MinConnectorOverlap", MATH->MinConnectorOverlap);
1699
1858
/* the handling of BASE is untested, no font */
1700
void handle_baselangextent (lua_State *L, struct baselangextent *ble);
1703
do_handle_baselangextent (lua_State *L, struct baselangextent *ble) {
1704
dump_tag(L,"tag",ble->lang);
1705
dump_intfield(L,"ascent",ble->ascent);
1706
dump_intfield(L,"descent",ble->descent);
1708
handle_baselangextent(L, ble->features);
1709
lua_setfield(L,-2,"features");
1713
void handle_baselangextent (lua_State *L, struct baselangextent *ble) {
1714
struct baselangextent *next;
1715
NESTED_TABLE(do_handle_baselangextent,ble,4);
1719
void handle_base (lua_State *L, struct Base *Base) {
1721
struct basescript *next = Base->scripts;
1723
for ( i=0; i<Base->baseline_cnt; i++ ) {
1724
lua_pushstring(L,make_tag_string(Base->baseline_tags[i]));
1725
lua_rawseti(L,-2,(i+1));
1727
lua_setfield(L,-2,"tags");
1730
while (next != NULL) {
1731
lua_pushstring(L,make_tag_string(next->script));
1733
dump_intfield(L, "default_baseline", (next->def_baseline+1)) ;
1735
for ( i=0; i<Base->baseline_cnt; i++ ) {
1736
lua_pushnumber(L, next->baseline_pos[i]) ;
1737
lua_rawseti(L,-2, (i+1));
1739
lua_setfield(L, -2, "baseline");
1741
handle_baselangextent(L, next->langs);
1742
lua_setfield(L, -2, "lang");
1746
lua_setfield(L,-2,"scripts");
1752
handle_axismap (lua_State *L, struct axismap *am) {
1754
lua_checkstack(L,3);
1756
for (i=0;i<am->points;i++) {
1757
lua_pushnumber(L, am->blends[i] ) ;
1758
lua_rawseti(L,-2, (i+1));
1760
lua_setfield(L,-2,"blends");
1762
for (i=0;i<am->points;i++) {
1763
lua_pushnumber(L, am->designs[i] ) ;
1764
lua_rawseti(L,-2, (i+1));
1766
lua_setfield(L,-2,"designs");
1767
dump_realfield(L, "min", am->min) ;
1768
dump_realfield(L, "def", am->def) ;
1769
dump_realfield(L, "max", am->max) ;
1770
if (am->axisnames != NULL ){
1772
handle_macname(L, am->axisnames);
1773
lua_setfield(L,-2,"axisnames");
1779
handle_mmset (lua_State *L, struct mmset *mm) {
1782
for (i=0;i<mm->axis_count;i++) {
1783
lua_pushstring(L, mm->axes[i]) ;
1784
lua_rawseti(L,-2, (i+1));
1786
lua_setfield(L,-2,"axes");
1788
dump_intfield(L,"instance_count",mm->instance_count);
1789
/* SplineFont *normal; */ /* this is the parent */
1790
if (mm->instance_count>0) {
1792
for (i=0;i<mm->instance_count*mm->axis_count;i++) {
1793
lua_pushnumber(L, mm->positions[i]) ;
1794
lua_rawseti(L,-2, (i+1));
1796
lua_setfield(L,-2,"positions");
1798
/* better not to do this */
1859
void handle_baselangextent(lua_State * L, struct baselangextent *ble);
1861
void do_handle_baselangextent(lua_State * L, struct baselangextent *ble)
1863
dump_tag(L, "tag", ble->lang);
1864
dump_intfield(L, "ascent", ble->ascent);
1865
dump_intfield(L, "descent", ble->descent);
1867
handle_baselangextent(L, ble->features);
1868
lua_setfield(L, -2, "features");
1872
void handle_baselangextent(lua_State * L, struct baselangextent *ble)
1874
struct baselangextent *next;
1875
NESTED_TABLE(do_handle_baselangextent, ble, 4);
1879
void handle_base(lua_State * L, struct Base *Base)
1882
struct basescript *next = Base->scripts;
1884
for (i = 0; i < Base->baseline_cnt; i++) {
1885
lua_pushstring(L, make_tag_string(Base->baseline_tags[i]));
1886
lua_rawseti(L, -2, (i + 1));
1888
lua_setfield(L, -2, "tags");
1891
while (next != NULL) {
1892
lua_pushstring(L, make_tag_string(next->script));
1894
dump_intfield(L, "default_baseline", (next->def_baseline + 1));
1896
for (i = 0; i < Base->baseline_cnt; i++) {
1897
if (next->baseline_pos != NULL) /* default omitted */
1898
lua_pushnumber(L, next->baseline_pos[i]);
1900
lua_pushnumber(L, 0);
1901
lua_rawseti(L, -2, (i + 1));
1903
lua_setfield(L, -2, "baseline");
1905
handle_baselangextent(L, next->langs);
1906
lua_setfield(L, -2, "lang");
1910
lua_setfield(L, -2, "scripts");
1915
void handle_axismap(lua_State * L, struct axismap *am)
1918
lua_checkstack(L, 3);
1920
for (i = 0; i < am->points; i++) {
1921
lua_pushnumber(L, am->blends[i]);
1922
lua_rawseti(L, -2, (i + 1));
1924
lua_setfield(L, -2, "blends");
1926
for (i = 0; i < am->points; i++) {
1927
lua_pushnumber(L, am->designs[i]);
1928
lua_rawseti(L, -2, (i + 1));
1930
lua_setfield(L, -2, "designs");
1931
dump_realfield(L, "min", am->min);
1932
dump_realfield(L, "def", am->def);
1933
dump_realfield(L, "max", am->max);
1934
if (am->axisnames != NULL) {
1936
handle_macname(L, am->axisnames);
1937
lua_setfield(L, -2, "axisnames");
1942
void handle_mmset(lua_State * L, struct mmset *mm)
1946
for (i = 0; i < mm->axis_count; i++) {
1947
lua_pushstring(L, mm->axes[i]);
1948
lua_rawseti(L, -2, (i + 1));
1950
lua_setfield(L, -2, "axes");
1952
dump_intfield(L, "instance_count", mm->instance_count);
1953
/* SplineFont *normal; *//* this is the parent */
1954
if (mm->instance_count > 0) {
1956
for (i = 0; i < mm->instance_count * mm->axis_count; i++) {
1957
lua_pushnumber(L, mm->positions[i]);
1958
lua_rawseti(L, -2, (i + 1));
1960
lua_setfield(L, -2, "positions");
1962
/* better not to do this */
1801
struct mmset *mmsave ;
1803
for (i=0;i<mm->instance_count;i++) {
1804
lua_checkstack(L,20);
1805
lua_createtable(L,0,60);
1806
mmsave = mm->instances[i]->mm;
1807
mm->instances[i]->mm = NULL;
1808
handle_splinefont(L, mm->instances[i]);
1809
mm->instances[i]->mm = mmsave;
1810
lua_rawseti(L,-2, (i+1));
1812
lua_setfield(L,-2,"instances");
1965
struct mmset *mmsave;
1967
for (i = 0; i < mm->instance_count; i++) {
1968
lua_checkstack(L, 20);
1969
lua_createtable(L, 0, 60);
1970
mmsave = mm->instances[i]->mm;
1971
mm->instances[i]->mm = NULL;
1972
handle_splinefont(L, mm->instances[i]);
1973
mm->instances[i]->mm = mmsave;
1974
lua_rawseti(L, -2, (i + 1));
1976
lua_setfield(L, -2, "instances");
1817
for (i=0;i<mm->instance_count;i++) {
1818
lua_pushnumber(L, mm->defweights[i]) ;
1819
lua_rawseti(L,-2, (i+1));
1821
lua_setfield(L,-2,"defweights");
1824
if (mm->axismaps != NULL) {
1826
for (i=0;i<mm->axis_count;i++) {
1828
handle_axismap(L, &(mm->axismaps[i]));
1829
lua_rawseti(L, -2, (i+1));
1831
lua_setfield(L,-2,"axismaps");
1833
dump_stringfield(L,"cdv",mm->cdv);
1834
dump_stringfield(L,"ndv",mm->ndv);
1835
dump_intfield(L,"named_instance_count",mm->named_instance_count);
1837
if (mm->named_instance_count>0) {
1839
for (i=0; i<mm->named_instance_count;i++) {
1840
struct named_instance *ni = &(mm->named_instances[i]);
1844
for (k=0;k<=mm->axis_count;k++) {
1845
lua_pushnumber(L,ni->coords[k]);
1846
lua_rawseti(L,-2,(k+1));
1848
lua_setfield(L,-2,"coords");
1851
handle_macname(L, ni->names);
1852
lua_setfield(L,-2,"names");
1854
lua_rawseti(L,-2,(i+1));
1856
lua_setfield(L,-2,"named_instances");
1858
/* unsigned int changed: 1; */
1859
dump_intfield(L,"apple",mm->apple);
1865
handle_splinefont(lua_State *L, struct splinefont *sf) {
1870
dump_stringfield(L,"table_version", LUA_OTF_VERSION);
1871
dump_stringfield(L,"fontname", sf->fontname);
1872
dump_stringfield(L,"fullname", sf->fullname);
1873
dump_stringfield(L,"familyname", sf->familyname);
1874
dump_stringfield(L,"weight", sf->weight);
1875
dump_stringfield(L,"copyright", sf->copyright);
1876
dump_stringfield(L,"filename", sf->filename);
1877
/* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */
1878
dump_stringfield(L,"version", sf->version);
1879
dump_floatfield (L,"italicangle", sf->italicangle);
1880
dump_floatfield (L,"upos", sf->upos);
1881
dump_floatfield (L,"uwidth", sf->uwidth);
1882
dump_intfield (L,"ascent", sf->ascent);
1883
dump_intfield (L,"descent", sf->descent);
1884
dump_intfield (L,"uniqueid", sf->uniqueid);
1885
dump_intfield (L,"glyphcnt", sf->glyphcnt);
1886
dump_intfield (L,"glyphmax", sf->glyphmax);
1887
dump_intfield (L,"units_per_em", sf->units_per_em);
1889
if (sf->possub != NULL) {
1891
handle_generic_fpst(L,sf->possub);
1892
lua_setfield(L,-2,"lookups");
1895
lua_checkstack(L,4);
1896
lua_createtable(L,sf->glyphcnt,0);
1898
/* This after-the-fact type discovery is not brilliant,
1899
I should really add a 'format' key in the structure */
1900
if ((sf->origname != NULL) &&
1901
(strmatch(sf->origname+strlen(sf->origname)-4, ".pfa")==0 ||
1902
strmatch(sf->origname+strlen(sf->origname)-4, ".pfb")==0)) {
1907
/* some code to ensure that the .notdef ends up in slot 0
1908
(this will actually be enforced by the CFF writer) */
1909
for (k=0;k<sf->glyphcnt;k++) {
1910
if (sf->glyphs[k]) {
1911
if (strcmp(sf->glyphs[k]->name,".notdef") == 0) {
1916
if (l==-1) { /* fake a .notdef at the end */
1920
lua_pushnumber(L,(k+1));
1921
lua_createtable(L,0,12);
1922
if (sf->glyphs[k]) {
1923
handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics);
1927
if (sf->glyphs != NULL && l<sf->glyphcnt) {
1928
lua_pushnumber(L,0);
1929
lua_createtable(L,0,12);
1930
if (sf->glyphs[l]) {
1931
handle_splinechar(L,sf->glyphs[l], sf->hasvmetrics);
1936
if ((l+1)<sf->glyphcnt) {
1937
for (k=(l+1);k<sf->glyphcnt;k++) {
1938
lua_pushnumber(L,k);
1939
lua_createtable(L,0,12);
1940
if (sf->glyphs[k]) {
1941
handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics);
1946
lua_setfield(L,-2,"glyphs");
1948
/* dump_intfield(L,"changed", sf->changed); */
1949
dump_intfield(L,"hasvmetrics", sf->hasvmetrics);
1950
dump_intfield(L,"onlybitmaps", sf->onlybitmaps);
1951
dump_intfield(L,"serifcheck", sf->serifcheck);
1952
dump_intfield(L,"isserif", sf->isserif);
1953
dump_intfield(L,"issans", sf->issans);
1954
dump_intfield(L,"encodingchanged", sf->encodingchanged);
1955
dump_intfield(L,"strokedfont", sf->strokedfont);
1956
dump_intfield(L,"use_typo_metrics", sf->use_typo_metrics);
1957
dump_intfield(L,"weight_width_slope_only", sf->weight_width_slope_only);
1958
dump_intfield(L,"head_optimized_for_cleartype",sf->head_optimized_for_cleartype);
1960
dump_enumfield(L,"uni_interp", (sf->uni_interp+1), uni_interp_enum);
1962
if (sf->map != NULL ) {
1964
handle_encmap(L,sf->map, l);
1965
lua_setfield(L,-2,"map");
1968
dump_stringfield(L,"origname", sf->origname); /* new */
1970
if (sf->private != NULL) {
1972
handle_psdict(L, sf->private);
1973
lua_setfield(L,-2,"private");
1976
dump_stringfield(L,"xuid", sf->xuid);
1978
lua_createtable(L,0,40);
1979
handle_pfminfo(L,sf->pfminfo);
1980
lua_setfield(L,-2,"pfminfo");
1982
if (sf->names != NULL) {
1984
handle_ttflangname(L,sf->names);
1985
lua_setfield(L,-2,"names");
1988
lua_createtable(L,0,4);
1989
dump_stringfield(L,"registry", sf->cidregistry);
1990
dump_stringfield(L,"ordering", sf->ordering);
1991
dump_intfield (L,"version", sf->cidversion);
1992
dump_intfield (L,"supplement", sf->supplement);
1993
lua_setfield(L,-2,"cidinfo");
1995
/* SplineFont *cidmaster */ /* parent in a subfont */
1996
if (sf->subfontcnt>0) {
1997
lua_createtable(L,sf->subfontcnt,0);
1998
for (k=0;k<sf->subfontcnt;k++) {
1999
lua_checkstack(L,10);
2001
handle_splinefont(L,sf->subfonts[k]);
2002
lua_rawseti(L,-2,(k+1));
2004
lua_setfield(L,-2,"subfonts");
2007
dump_stringfield(L,"comments", sf->comments);
2008
dump_stringfield(L,"fontlog", sf->fontlog);
2010
if (sf->cvt_names != NULL) {
2012
for (k=0; sf->cvt_names[k]!=END_CVT_NAMES; ++k) {
2013
lua_pushstring(L, sf->cvt_names[k]);
2014
lua_rawseti(L,-2,(k+1));
2016
lua_setfield(L,-2,"cvt_names");
2019
if (sf->ttf_tables != NULL) {
2021
handle_ttf_table(L,sf->ttf_tables);
2022
lua_setfield(L,-2,"ttf_tables");
2025
if (sf->ttf_tab_saved != NULL) {
2027
handle_ttf_table(L,sf->ttf_tab_saved);
2028
lua_setfield(L,-2,"ttf_tab_saved");
2031
if (sf->texdata.type != tex_unset) {
2033
dump_enumfield(L,"type", sf->texdata.type, tex_type_enum);
2035
for (k=0;k<22;k++) {
2036
lua_pushnumber(L,k);
2037
lua_pushnumber(L,sf->texdata.params[k]);
2040
lua_setfield(L,-2,"params");
2041
lua_setfield(L,-2,"texdata");
2043
if (sf->anchor != NULL) {
2045
handle_anchorclass(L,sf->anchor);
2046
lua_setfield(L,-2,"anchor_classes");
2048
if (sf->kerns != NULL) {
2050
handle_kernclass(L,sf->kerns);
2051
lua_setfield(L,-2,"kerns");
2053
if (sf->vkerns != NULL) {
2055
handle_kernclass(L,sf->vkerns);
2056
lua_setfield(L,-2,"vkerns");
2058
if (sf->gsub_lookups != NULL) {
2060
handle_lookup(L,sf->gsub_lookups);
2061
lua_setfield(L,-2,"gsub");
2063
if (sf->gpos_lookups != NULL) {
2065
handle_lookup(L,sf->gpos_lookups);
2066
lua_setfield(L,-2,"gpos");
2069
if (sf->sm != NULL) {
2071
handle_generic_asm(L,sf->sm);
2072
lua_setfield(L,-2,"sm");
2074
if (sf->features != NULL) {
2076
handle_macfeat(L,sf->features);
2077
lua_setfield(L,-2,"features");
2079
if (sf->mm != NULL) {
2081
handle_mmset (L,sf->mm);
2082
lua_setfield(L,-2,"mm");
2084
dump_stringfield(L,"chosenname", sf->chosenname);
2086
dump_intfield(L,"macstyle", sf->macstyle);
2087
dump_stringfield(L,"fondname", sf->fondname);
2089
dump_intfield(L,"design_size", sf->design_size);
2090
dump_intfield(L,"fontstyle_id", sf->fontstyle_id);
2092
if (sf->fontstyle_name != NULL) {
2094
handle_otfname(L,sf->fontstyle_name);
2095
lua_setfield(L,-2,"fontstyle_name");
2098
dump_intfield(L,"design_range_bottom",sf->design_range_bottom);
2099
dump_intfield(L,"design_range_top", sf->design_range_top);
2100
dump_floatfield(L,"strokewidth", sf->strokewidth);
2102
if (sf->mark_class_cnt>0) {
2104
for ( k=0; k<sf->mark_class_cnt; ++k ) {
2105
lua_pushnumber(L,(k+1));
2106
lua_pushstring(L,sf->mark_classes[k]);
2109
lua_setfield(L,-1,"mark_classes");
2112
for ( k=0; k<sf->mark_class_cnt; ++k ) {
2113
lua_pushnumber(L,(k+1));
2114
lua_pushstring(L,sf->mark_class_names[k]);
2117
lua_setfield(L,-1,"mark_class_names");
2120
dump_intfield(L,"creationtime", sf->creationtime);
2121
dump_intfield(L,"modificationtime", sf->modificationtime);
2123
dump_intfield(L,"os2_version", sf->os2_version);
2124
dump_intfield(L,"sfd_version", sf->sfd_version);
2126
if (sf->MATH != NULL) {
2128
handle_MATH(L, sf->MATH);
2129
lua_setfield(L,-2,"math");
2132
if (sf->loadvalidation_state != 0) {
2136
st = sf->loadvalidation_state;
2137
if (st & lvs_bad_ps_fontname) {
2138
lua_pushliteral(L, "bad_ps_fontname"); lua_rawseti(L,-2,val++);
2140
if (st & lvs_bad_glyph_table) {
2141
lua_pushliteral(L, "bad_glyph_table"); lua_rawseti(L,-2,val++);
2143
if (st & lvs_bad_cff_table) {
2144
lua_pushliteral(L, "bad_cff_table"); lua_rawseti(L,-2,val++);
2146
if (st & lvs_bad_metrics_table) {
2147
lua_pushliteral(L, "bad_metrics_table"); lua_rawseti(L,-2,val++);
2149
if (st & lvs_bad_cmap_table) {
2150
lua_pushliteral(L, "bad_cmap_table"); lua_rawseti(L,-2,val++);
2152
if (st & lvs_bad_bitmaps_table) {
2153
lua_pushliteral(L, "bad_bitmaps_table"); lua_rawseti(L,-2,val++);
2155
if (st & lvs_bad_gx_table) {
2156
lua_pushliteral(L, "bad_gx_table"); lua_rawseti(L,-2,val++);
2158
if (st & lvs_bad_ot_table) {
2159
lua_pushliteral(L, "bad_ot_table"); lua_rawseti(L,-2,val++);
2161
if (st & lvs_bad_os2_version) {
2162
lua_pushliteral(L, "bad_os2_version"); lua_rawseti(L,-2,val++);
2164
if (st & lvs_bad_sfnt_header) {
2165
lua_pushliteral(L, "bad_sfnt_header"); lua_rawseti(L,-2,val++);
2167
lua_setfield(L,-2,"validation_state");
2170
if (sf->horiz_base != NULL) {
2172
handle_base(L, sf->horiz_base);
2173
lua_setfield(L,-2,"horiz_base");
2175
if (sf->vert_base != NULL) {
2177
handle_base(L, sf->vert_base);
2178
lua_setfield(L,-2,"vert_base");
2180
dump_intfield(L,"extrema_bound", sf->extrema_bound);
2184
ff_make_table (lua_State *L) {
2186
sf = *(check_isfont(L,1));
2188
lua_pushboolean(L,0);
2190
lua_createtable(L,0,60);
2191
handle_splinefont(L,sf);
2196
void do_ff_info (lua_State *L, SplineFont *sf) {
2198
dump_stringfield(L,"familyname", sf->familyname);
2199
dump_stringfield(L,"fontname", sf->fontname);
2200
dump_stringfield(L,"fullname", sf->fullname);
2201
dump_intfield (L,"italicangle", sf->italicangle);
2202
dump_stringfield(L,"version", sf->version);
2203
dump_stringfield(L,"weight", sf->weight);
2208
ff_info (lua_State *L) {
2212
const char *fontname;
2214
fontname = luaL_checkstring(L,1);
2215
if (!strlen(fontname)) {
2216
lua_pushfstring(L,"font loading failed: empty string given\n", fontname);
2220
/* test fontname for existance */
2221
if ((l = fopen(fontname,"r"))) {
2224
lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname);
2227
sf = ReadSplineFontInfo((char *)fontname,openflags);
2229
lua_pushfstring(L,"font loading failed for %s\n", fontname);
2232
if (sf->next != NULL) {
2233
SplineFont *sf_next;
2238
lua_rawseti(L,-2,i);
2252
static void ff_do_cff (SplineFont *sf, char *filename, unsigned char **buf, int *bufsiz) {
2254
int32 *bsizes = NULL;
2255
int flags = ps_flag_nocffsugar + ps_flag_nohints;
2258
map = EncMap1to1(sf->glyphcnt);
2260
if(WriteTTFFont(filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) {
2262
f = fopen(filename,"rb");
2263
readbinfile(f , buf, bufsiz);
2264
/*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz);*/
2269
fprintf(stdout,"\n%s => CFF, failed\n", sf->filename);
1981
for (i = 0; i < mm->instance_count; i++) {
1982
lua_pushnumber(L, mm->defweights[i]);
1983
lua_rawseti(L, -2, (i + 1));
1985
lua_setfield(L, -2, "defweights");
1988
if (mm->axismaps != NULL) {
1990
for (i = 0; i < mm->axis_count; i++) {
1992
handle_axismap(L, &(mm->axismaps[i]));
1993
lua_rawseti(L, -2, (i + 1));
1995
lua_setfield(L, -2, "axismaps");
1997
dump_stringfield(L, "cdv", mm->cdv);
1998
dump_stringfield(L, "ndv", mm->ndv);
1999
dump_intfield(L, "named_instance_count", mm->named_instance_count);
2001
if (mm->named_instance_count > 0) {
2003
for (i = 0; i < mm->named_instance_count; i++) {
2004
struct named_instance *ni = &(mm->named_instances[i]);
2008
for (k = 0; k <= mm->axis_count; k++) {
2009
lua_pushnumber(L, ni->coords[k]);
2010
lua_rawseti(L, -2, (k + 1));
2012
lua_setfield(L, -2, "coords");
2015
handle_macname(L, ni->names);
2016
lua_setfield(L, -2, "names");
2018
lua_rawseti(L, -2, (i + 1));
2020
lua_setfield(L, -2, "named_instances");
2022
/* unsigned int changed: 1; */
2023
dump_intfield(L, "apple", mm->apple);
2028
void handle_splinefont(lua_State * L, struct splinefont *sf)
2034
dump_stringfield(L, "table_version", LUA_OTF_VERSION);
2035
dump_stringfield(L, "fontname", sf->fontname);
2036
dump_stringfield(L, "fullname", sf->fullname);
2037
dump_stringfield(L, "familyname", sf->familyname);
2038
dump_stringfield(L, "weight", sf->weight);
2039
dump_stringfield(L, "copyright", sf->copyright);
2040
dump_stringfield(L, "filename", sf->filename);
2041
/* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */
2042
dump_stringfield(L, "version", sf->version);
2043
dump_floatfield(L, "italicangle", sf->italicangle);
2044
dump_floatfield(L, "upos", sf->upos);
2045
dump_floatfield(L, "uwidth", sf->uwidth);
2046
dump_intfield(L, "ascent", sf->ascent);
2047
dump_intfield(L, "descent", sf->descent);
2048
dump_intfield(L, "uniqueid", sf->uniqueid);
2049
dump_intfield(L, "glyphcnt", sf->glyphcnt);
2050
dump_intfield(L, "glyphmax", sf->glyphmax);
2051
dump_intfield(L, "units_per_em", sf->units_per_em);
2053
if (sf->possub != NULL) {
2055
handle_generic_fpst(L, sf->possub);
2056
lua_setfield(L, -2, "lookups");
2059
lua_checkstack(L, 4);
2060
lua_createtable(L, sf->glyphcnt, 0);
2062
/* This after-the-fact type discovery is not brilliant,
2063
I should really add a 'format' key in the structure */
2064
if ((sf->origname != NULL) &&
2065
(strmatch(sf->origname + strlen(sf->origname) - 4, ".pfa") == 0 ||
2066
strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) {
2071
/* some code to ensure that the .notdef ends up in slot 0
2072
(this will actually be enforced by the CFF writer) */
2073
for (k = 0; k < sf->glyphcnt; k++) {
2074
if (sf->glyphs[k]) {
2075
if (strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
2080
if (l == -1) { /* fake a .notdef at the end */
2083
for (k = 0; k < l; k++) {
2084
if (sf->glyphs[k]) {
2085
lua_pushnumber(L, (k + 1));
2086
lua_createtable(L, 0, 12);
2087
handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics);
2091
if (sf->glyphs != NULL && l < sf->glyphcnt) {
2092
lua_pushnumber(L, 0);
2093
if (sf->glyphs[l]) {
2094
lua_createtable(L, 0, 12);
2095
handle_splinechar(L, sf->glyphs[l], sf->hasvmetrics);
2097
lua_createtable(L, 0, 0);
2102
if ((l + 1) < sf->glyphcnt) {
2103
for (k = (l + 1); k < sf->glyphcnt; k++) {
2104
if (sf->glyphs[k]) {
2105
lua_pushnumber(L, k);
2106
lua_createtable(L, 0, 12);
2107
handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics);
2112
lua_setfield(L, -2, "glyphs");
2114
/* dump_intfield(L,"changed", sf->changed); */
2115
dump_intfield(L, "hasvmetrics", sf->hasvmetrics);
2116
dump_intfield(L, "onlybitmaps", sf->onlybitmaps);
2117
dump_intfield(L, "serifcheck", sf->serifcheck);
2118
dump_intfield(L, "isserif", sf->isserif);
2119
dump_intfield(L, "issans", sf->issans);
2120
dump_intfield(L, "encodingchanged", sf->encodingchanged);
2121
dump_intfield(L, "strokedfont", sf->strokedfont);
2122
dump_intfield(L, "use_typo_metrics", sf->use_typo_metrics);
2123
dump_intfield(L, "weight_width_slope_only", sf->weight_width_slope_only);
2124
dump_intfield(L, "head_optimized_for_cleartype",
2125
sf->head_optimized_for_cleartype);
2127
dump_enumfield(L, "uni_interp", (sf->uni_interp + 1), uni_interp_enum);
2129
if (sf->map != NULL) {
2131
handle_encmap(L, sf->map, l);
2132
lua_setfield(L, -2, "map");
2135
dump_stringfield(L, "origname", sf->origname); /* new */
2137
if (sf->private != NULL) {
2139
handle_psdict(L, sf->private);
2140
lua_setfield(L, -2, "private");
2143
dump_stringfield(L, "xuid", sf->xuid);
2145
lua_createtable(L, 0, 40);
2146
handle_pfminfo(L, sf->pfminfo);
2147
lua_setfield(L, -2, "pfminfo");
2149
if (sf->names != NULL) {
2151
handle_ttflangname(L, sf->names);
2152
lua_setfield(L, -2, "names");
2155
lua_createtable(L, 0, 4);
2156
dump_stringfield(L, "registry", sf->cidregistry);
2157
dump_stringfield(L, "ordering", sf->ordering);
2158
dump_intfield(L, "version", sf->cidversion);
2159
dump_intfield(L, "supplement", sf->supplement);
2160
lua_setfield(L, -2, "cidinfo");
2162
/* SplineFont *cidmaster *//* parent in a subfont */
2163
if (sf->subfontcnt > 0) {
2164
lua_createtable(L, sf->subfontcnt, 0);
2165
for (k = 0; k < sf->subfontcnt; k++) {
2166
lua_checkstack(L, 10);
2168
handle_splinefont(L, sf->subfonts[k]);
2169
lua_rawseti(L, -2, (k + 1));
2171
lua_setfield(L, -2, "subfonts");
2174
dump_stringfield(L, "comments", sf->comments);
2175
dump_stringfield(L, "fontlog", sf->fontlog);
2177
if (sf->cvt_names != NULL) {
2179
for (k = 0; sf->cvt_names[k] != END_CVT_NAMES; ++k) {
2180
lua_pushstring(L, sf->cvt_names[k]);
2181
lua_rawseti(L, -2, (k + 1));
2183
lua_setfield(L, -2, "cvt_names");
2186
if (sf->ttf_tables != NULL) {
2188
handle_ttf_table(L, sf->ttf_tables);
2189
lua_setfield(L, -2, "ttf_tables");
2192
if (sf->ttf_tab_saved != NULL) {
2194
handle_ttf_table(L, sf->ttf_tab_saved);
2195
lua_setfield(L, -2, "ttf_tab_saved");
2198
if (sf->texdata.type != tex_unset) {
2200
dump_enumfield(L, "type", sf->texdata.type, tex_type_enum);
2202
for (k = 0; k < 22; k++) {
2203
lua_pushnumber(L, k);
2204
lua_pushnumber(L, sf->texdata.params[k]);
2207
lua_setfield(L, -2, "params");
2208
lua_setfield(L, -2, "texdata");
2210
if (sf->anchor != NULL) {
2212
handle_anchorclass(L, sf->anchor);
2213
lua_setfield(L, -2, "anchor_classes");
2215
if (sf->kerns != NULL) {
2217
handle_kernclass(L, sf->kerns);
2218
lua_setfield(L, -2, "kerns");
2220
if (sf->vkerns != NULL) {
2222
handle_kernclass(L, sf->vkerns);
2223
lua_setfield(L, -2, "vkerns");
2225
if (sf->gsub_lookups != NULL) {
2227
handle_lookup(L, sf->gsub_lookups, sf);
2228
lua_setfield(L, -2, "gsub");
2230
if (sf->gpos_lookups != NULL) {
2232
handle_lookup(L, sf->gpos_lookups, sf);
2233
lua_setfield(L, -2, "gpos");
2236
if (sf->sm != NULL) {
2238
handle_generic_asm(L, sf->sm);
2239
lua_setfield(L, -2, "sm");
2241
if (sf->features != NULL) {
2243
handle_macfeat(L, sf->features);
2244
lua_setfield(L, -2, "features");
2246
if (sf->mm != NULL) {
2248
handle_mmset(L, sf->mm);
2249
lua_setfield(L, -2, "mm");
2251
dump_stringfield(L, "chosenname", sf->chosenname);
2253
dump_intfield(L, "macstyle", sf->macstyle);
2254
dump_stringfield(L, "fondname", sf->fondname);
2256
dump_intfield(L, "design_size", sf->design_size);
2257
dump_intfield(L, "fontstyle_id", sf->fontstyle_id);
2259
if (sf->fontstyle_name != NULL) {
2261
handle_otfname(L, sf->fontstyle_name);
2262
lua_setfield(L, -2, "fontstyle_name");
2265
dump_intfield(L, "design_range_bottom", sf->design_range_bottom);
2266
dump_intfield(L, "design_range_top", sf->design_range_top);
2267
dump_floatfield(L, "strokewidth", sf->strokewidth);
2269
if (sf->mark_class_cnt > 0) {
2271
for (k = 0; k < sf->mark_class_cnt; k++) {
2272
if (sf->mark_class_names[k] != NULL) {
2273
lua_pushstring(L, sf->mark_class_names[k]);
2274
lua_pushstring(L, sf->mark_classes[k]);
2278
lua_setfield(L, -2, "mark_classes");
2281
dump_intfield(L, "creationtime", sf->creationtime);
2282
dump_intfield(L, "modificationtime", sf->modificationtime);
2284
dump_intfield(L, "os2_version", sf->os2_version);
2285
dump_intfield(L, "sfd_version", sf->sfd_version);
2287
if (sf->MATH != NULL) {
2289
handle_MATH(L, sf->MATH);
2290
lua_setfield(L, -2, "math");
2293
if (sf->loadvalidation_state != 0) {
2297
st = sf->loadvalidation_state;
2298
if (st & lvs_bad_ps_fontname) {
2299
lua_pushliteral(L, "bad_ps_fontname");
2300
lua_rawseti(L, -2, val++);
2302
if (st & lvs_bad_glyph_table) {
2303
lua_pushliteral(L, "bad_glyph_table");
2304
lua_rawseti(L, -2, val++);
2306
if (st & lvs_bad_cff_table) {
2307
lua_pushliteral(L, "bad_cff_table");
2308
lua_rawseti(L, -2, val++);
2310
if (st & lvs_bad_metrics_table) {
2311
lua_pushliteral(L, "bad_metrics_table");
2312
lua_rawseti(L, -2, val++);
2314
if (st & lvs_bad_cmap_table) {
2315
lua_pushliteral(L, "bad_cmap_table");
2316
lua_rawseti(L, -2, val++);
2318
if (st & lvs_bad_bitmaps_table) {
2319
lua_pushliteral(L, "bad_bitmaps_table");
2320
lua_rawseti(L, -2, val++);
2322
if (st & lvs_bad_gx_table) {
2323
lua_pushliteral(L, "bad_gx_table");
2324
lua_rawseti(L, -2, val++);
2326
if (st & lvs_bad_ot_table) {
2327
lua_pushliteral(L, "bad_ot_table");
2328
lua_rawseti(L, -2, val++);
2330
if (st & lvs_bad_os2_version) {
2331
lua_pushliteral(L, "bad_os2_version");
2332
lua_rawseti(L, -2, val++);
2334
if (st & lvs_bad_sfnt_header) {
2335
lua_pushliteral(L, "bad_sfnt_header");
2336
lua_rawseti(L, -2, val++);
2338
lua_setfield(L, -2, "validation_state");
2341
if (sf->horiz_base != NULL) {
2343
handle_base(L, sf->horiz_base);
2344
lua_setfield(L, -2, "horiz_base");
2346
if (sf->vert_base != NULL) {
2348
handle_base(L, sf->vert_base);
2349
lua_setfield(L, -2, "vert_base");
2351
dump_intfield(L, "extrema_bound", sf->extrema_bound);
2354
int ff_make_table(lua_State * L)
2357
sf = *(check_isfont(L, 1));
2359
lua_pushboolean(L, 0);
2361
lua_createtable(L, 0, 60);
2362
handle_splinefont(L, sf);
2367
void do_ff_info(lua_State * L, SplineFont * sf)
2370
dump_stringfield(L, "familyname", sf->familyname);
2371
dump_stringfield(L, "fontname", sf->fontname);
2372
dump_stringfield(L, "fullname", sf->fullname);
2373
dump_intfield(L, "italicangle", sf->italicangle);
2374
dump_stringfield(L, "version", sf->version);
2375
dump_stringfield(L, "weight", sf->weight);
2379
static int ff_info(lua_State * L)
2384
const char *fontname;
2386
fontname = luaL_checkstring(L, 1);
2387
if (!strlen(fontname)) {
2389
lua_pushfstring(L, "font loading failed: empty string given\n",
2393
/* test fontname for existance */
2394
if ((l = fopen(fontname, "r"))) {
2398
lua_pushfstring(L, "font loading failed for %s (read error)\n",
2402
sf = ReadSplineFontInfo((char *) fontname, openflags);
2405
lua_pushfstring(L, "font loading failed for %s\n", fontname);
2408
if (sf->next != NULL) {
2409
SplineFont *sf_next;
2414
lua_rawseti(L, -2, i);
2428
static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf,
2432
int32 *bsizes = NULL;
2433
int flags = ps_flag_nocffsugar + ps_flag_nohints;
2436
map = EncMap1to1(sf->glyphcnt);
2439
(filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) {
2441
f = fopen(filename, "rb");
2442
readbinfile(f, buf, bufsiz);
2443
/*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz); */
2448
fprintf(stdout, "\n%s => CFF, failed\n", sf->filename);
2273
2452
/* exported for writecff.c */
2275
int ff_createcff (char *file, unsigned char **buf, int *bufsiz) {
2278
char s[] = "tempfile.cff";
2281
sf = ReadSplineFont(file,openflags);
2283
/* this is not the best way. nicer to have no temp file at all */
2284
ff_do_cff(sf, s, buf,bufsiz);
2285
for (k=0;k<sf->glyphcnt;k++) {
2286
if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name,".notdef")==0) {
2454
int ff_createcff(char *file, unsigned char **buf, int *bufsiz)
2458
char s[] = "tempfile.cff";
2461
sf = ReadSplineFont(file, openflags);
2463
/* this is not the best way. nicer to have no temp file at all */
2464
ff_do_cff(sf, s, buf, bufsiz);
2465
for (k = 0; k < sf->glyphcnt; k++) {
2466
if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
2297
int ff_get_ttc_index(char *ffname, char*psname) {
2477
int ff_get_ttc_index(char *ffname, char *psname)
2303
sf = ReadSplineFontInfo((char *)ffname,openflags);
2305
perror("font loading failed unexpectedly\n");
2308
while (sf != NULL) {
2309
if (strcmp(sf->fontname,psname)==0) {
2484
sf = ReadSplineFontInfo((char *) ffname, openflags);
2486
perror("font loading failed unexpectedly\n");
2489
while (sf != NULL) {
2490
if (strcmp(sf->fontname, psname) == 0) {
2319
2500
static int warning_given = 0;
2322
ffold_info (lua_State *L) {
2323
if (warning_given<5) {
2324
fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
2325
fprintf (stderr, " Please update your source file(s) accordingly.\n");
2502
static int ffold_info(lua_State * L)
2504
if (warning_given < 5) {
2506
"Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
2507
fprintf(stderr, " Please update your source file(s) accordingly.\n");
2328
2510
return ff_info(L);
2332
ffold_open (lua_State *L) {
2333
fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
2334
fprintf (stderr, " Please update your source file(s) accordingly.\n");
2513
static int ffold_open(lua_State * L)
2516
"Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
2517
fprintf(stderr, " Please update your source file(s) accordingly.\n");
2335
2518
return ff_open(L);
2339
2522
static struct luaL_reg fflib[] = {
2340
{"open", ffold_open},
2341
{"info", ffold_info},
2342
{"close", ff_close},
2343
{"apply_afmfile", ff_apply_afmfile},
2344
{"apply_featurefile", ff_apply_featurefile},
2345
{"to_table", ff_make_table},
2523
{"open", ffold_open},
2524
{"info", ffold_info},
2525
{"close", ff_close},
2526
{"apply_afmfile", ff_apply_afmfile},
2527
{"apply_featurefile", ff_apply_featurefile},
2528
{"to_table", ff_make_table},
2349
2532
static struct luaL_reg fllib[] = {
2352
{"close", ff_close},
2353
{"apply_afmfile", ff_apply_afmfile},
2354
{"apply_featurefile", ff_apply_featurefile},
2355
{"to_table", ff_make_table},
2535
{"close", ff_close},
2536
{"apply_afmfile", ff_apply_afmfile},
2537
{"apply_featurefile", ff_apply_featurefile},
2538
{"to_table", ff_make_table},
2359
static const struct luaL_reg fflib_m [] = {
2360
{"__gc", ff_close }, /* doesnt work yet! */
2361
{NULL, NULL} /* sentinel */
2542
static const struct luaL_reg fflib_m[] = {
2543
{"__gc", ff_close}, /* doesnt work yet! */
2544
{NULL, NULL} /* sentinel */
2364
2547
extern char *SaveTablesPref;
2365
extern char *coord_sep ;
2548
extern char *coord_sep;
2367
int luaopen_ff (lua_State *L) {
2369
setlocale(LC_ALL,"C"); /* undo whatever InitSimpleStuff has caused */
2371
FF_SetUiInterface(&luaui_interface);
2372
default_encoding = FindOrMakeEncoding("ISO8859-1");
2373
SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO";
2374
luaL_newmetatable(L,FONT_METATABLE);
2375
luaL_register(L, NULL, fflib_m);
2376
luaL_openlib(L, "fontforge", fflib, 0);
2377
luaL_openlib(L, "fontloader", fllib, 0);
2550
int luaopen_ff(lua_State * L)
2553
setlocale(LC_ALL, "C"); /* undo whatever InitSimpleStuff has caused */
2555
FF_SetUiInterface(&luaui_interface);
2556
default_encoding = FindOrMakeEncoding("ISO8859-1");
2557
SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO";
2558
luaL_newmetatable(L, FONT_METATABLE);
2559
luaL_register(L, NULL, fflib_m);
2560
luaL_openlib(L, "fontforge", fflib, 0);
2561
luaL_openlib(L, "fontloader", fllib, 0);