summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luafontloader
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
commitf372862c42d234710b6057449b46818e63181c90 (patch)
treea9ebec66dd31ac37aed442502ebd1b9fe76245ec /Build/source/texk/web2c/luatexdir/luafontloader
parent2dad291ab056f30816e0aea61970f38033c2f6a5 (diff)
import luatex 0.60.0 (with small local changes, see luatexdir/ChangeLog)
and do an autoreconf git-svn-id: svn://tug.org/texlive/trunk@17680 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luafontloader')
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in2
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c30
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c175
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c276
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/autohint.c8
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c13
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c1946
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c166
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c5
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/psread.c701
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c13
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c324
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c4196
19 files changed, 4380 insertions, 3500 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in
index ea21c43be1d..7cb2bc9acfe 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/Makefile.in
@@ -14,7 +14,7 @@ GU_AGE=0
LIBTOOL = @LIBTOOL@
CC = @CC@
-libgunicode_OBJECTS = ArabicForms.lo alphabet.lo backtrns.lo char.lo \
+libgunicode_OBJECTS = ArabicForms.lo alphabet.lo char.lo \
cjk.lo memory.lo ucharmap.lo unialt.lo ustring.lo utype.lo \
gwwiconv.lo
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c
index a2f01f3131a..412947d5b70 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/cjk.c
@@ -1,7 +1,10 @@
#include <chardata.h>
+#ifdef TO_CJK_ICONV
const unsigned short u_allzeros[256] = { 0 };
+#endif
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_jis208[] = {
0x2003, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a, 0xff1b,
0xff1f, 0xff01, 0x309b, 0x309c, 0x00b4, 0xff40, 0x00a8, 0xff3e,
@@ -2219,7 +2222,9 @@ const unichar_t unicode_from_jis212[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x2003, 0x3001, 0x3002, 0xff0c,
0xff0e, 0x30fb, 0xff1a, 0xff1b, 0xff1f, 0xff01, 0x309b, 0x309c
};
+#endif
+#ifdef TO_CJK_ICONV
static const unsigned short jis_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -5806,6 +5811,9 @@ static const unsigned short * const jis_from_unicode_[] = {
struct charmap2 jis_from_unicode = { 0, 255, (unsigned short **) jis_from_unicode_, (unichar_t *) unicode_from_jis212 };
+#endif
+
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_big5[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -8881,7 +8889,9 @@ const unichar_t unicode_from_big5[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0xfe4f, 0xffffffff, 0x00ff, 0x0000, 0x0100, 0x0002, 0x6000, 0x804f240
};
+#endif
+#ifdef TO_CJK_ICONV
static const unsigned short big5_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -12712,7 +12722,9 @@ static const unsigned short * const big5_from_unicode_[] = {
};
struct charmap2 big5_from_unicode = { 0, 255, (unsigned short **) big5_from_unicode_, (unichar_t *) unicode_from_big5 };
+#endif
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_big5hkscs[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -16812,7 +16824,9 @@ const unichar_t unicode_from_big5hkscs[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x79d4, 0xfefe, 0x00ff, 0x0000, 0x0100, 0x0005, 0x8000, 0x804f240
};
+#endif
+#ifdef TO_CJK_ICONV
static const unsigned short big5hkscs_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -22534,6 +22548,9 @@ static const unsigned short * const big5hkscs_from_unicode_[] = {
struct charmap2 big5hkscs_from_unicode = { 0, 255, (unsigned short **) big5hkscs_from_unicode_, (unichar_t *) unicode_from_big5hkscs };
+#endif
+
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_ksc5601[] = {
0x3164, 0x3001, 0x3002, 0x30fb, 0x2025, 0x22ef, 0x00a8, 0x3003,
0x2013, 0x2014, 0x2016, 0xff3c, 0xff5e, 0x2018, 0x2019, 0x201c,
@@ -23642,7 +23659,9 @@ const unichar_t unicode_from_ksc5601[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xffffffff,
0xffffffff, 0xffffffff, 0x0000, 0x0000, 0x79d4, 0x0004, 0x2288, 0x804f240
};
+#endif
+#ifdef TO_CJK_ICONV
static unsigned short ksc5601_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -28909,6 +28928,9 @@ static const unsigned short * const ksc5601_from_unicode_[] = {
struct charmap2 ksc5601_from_unicode = { 0, 255, (unsigned short **) ksc5601_from_unicode_, (unichar_t *) unicode_from_ksc5601 };
+#endif
+
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_johab[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -32880,7 +32902,9 @@ const unichar_t unicode_from_johab[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x3164, 0x3001, 0x3002, 0x30fb, 0x2025, 0x22ef, 0x00a8, 0x3003
};
+#endif
+#ifdef TO_CJK_ICONV
static unsigned short johab_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -38147,6 +38171,9 @@ static const unsigned short * const johab_from_unicode_[] = {
struct charmap2 johab_from_unicode = { 0, 255, (unsigned short **) johab_from_unicode_, (unichar_t *) unicode_from_johab };
+#endif
+
+#ifdef FROM_CJK_ICONV
const unichar_t unicode_from_gb2312[] = {
0x3000, 0x3001, 0x3002, 0x00b7, 0x02c9, 0x02c7, 0x00a8, 0x3003,
0x3005, 0x2014, 0xff5e, 0x2016, 0x2026, 0x2018, 0x2019, 0x201c,
@@ -39255,7 +39282,9 @@ const unichar_t unicode_from_gb2312[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x9f44, 0xffffffff, 0x00ff, 0x0000,
0x0100, 0x0003, 0x2288, 0x804f240, 0x0100, 0x0005, 0x00f8, 0x42130a14
};
+#endif
+#ifdef TO_CJK_ICONV
static unsigned short gb2312_from_unicode_0[] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -43017,3 +43046,4 @@ static const unsigned short * const gb2312_from_unicode_[] = {
struct charmap2 gb2312_from_unicode = { 0, 255, (unsigned short **) gb2312_from_unicode_, (unichar_t *) unicode_from_gb2312 };
+#endif
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c
index 5576de5c18e..70f9e064dc3 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/gwwiconv.c
@@ -114,16 +114,14 @@ static enum encoding name_to_enc(const char *encname) {
{ "mac", e_mac },
{ "Macintosh", e_mac },
{ "MS-ANSI", e_win },
+#ifdef FROM_CJK_ICONV
{ "EUC-KR", e_wansung },
{ "johab", e_johab },
- { "ISO-2022-KR", e_jiskorean },
- { "ISO-2022-CN", e_jisgb },
{ "EUC-CN", e_jisgbpk },
{ "big5", e_big5 },
{ "big5hkscs", e_big5hkscs },
- { "ISO-2022-JP", e_jis },
- { "ISO-2022-JP-2", e_jis2 },
{ "Sjis", e_sjis },
+#endif
{ "UTF-8", e_utf8 },
{ "UTF8", e_utf8 },
{ NULL }};
@@ -242,6 +240,7 @@ return( (size_t) -1 ); /* Incomplete multi-byte sequence */
} else
return( (size_t) -1 );
}
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_johab || cd->to==e_big5 || cd->to==e_big5hkscs ) {
struct charmap2 *table = cd->to==e_johab ? &johab_from_unicode :
cd->to==e_big5 ? &big5_from_unicode :
@@ -274,6 +273,8 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
+#endif
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_wansung || cd->to==e_jisgbpk ) {
struct charmap2 *table = cd->to==e_wansung ? &ksc5601_from_unicode :
&gb2312_from_unicode;
@@ -305,6 +306,8 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
+#endif
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_sjis ) {
unsigned char *plane1;
unsigned short *plane;
@@ -341,39 +344,7 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
- } else if ( cd->to==e_jis || cd->to==e_jis2 ||
- cd->to==e_jiskorean || cd->to==e_jisgb ) {
- struct charmap2 *table = cd->to==e_jisgb ? &gb2312_from_unicode :
- cd->to==e_jiskorean ? &ksc5601_from_unicode :
- &jis_from_unicode;
- unsigned short *plane;
- while ( *inlen>1 && *outlen>1 ) {
- int highch, lowch;
- if ( endian == end_little ) {
- highch = ((unsigned char *) *inbuf)[1], lowch = *(unsigned char *) *inbuf;
- } else {
- highch = *(unsigned char *) *inbuf, lowch = ((unsigned char *) *inbuf)[1];
- }
- if ( highch>=table->first && highch<=table->last &&
- (plane = table->table[highch])!=NULL &&
- (ch=plane[lowch])!=0 ) {
- if ( ch>=0x8000 ) {
- if ( cd->to!=e_jis2 )
-return( (size_t) -1 );
- ch -= 0x8000;
- } else {
- if ( cd->to==e_jis2 )
-return( (size_t) -1 );
- }
- *((*outbuf)++) = (ch>>8);
- *((*outbuf)++) = (ch&0xff);
- *outlen -= 2;
- *inlen -= 2;
- *inbuf += 2;
- ++char_cnt;
- } else
-return( (size_t) -1 );
- }
+#endif
} else if ( cd->to==e_utf8 ) {
while ( *inlen>1 && *outlen>0 ) {
unichar_t uch;
@@ -450,6 +421,7 @@ return( (size_t) -1 ); /* Incomplete multi-byte sequence */
} else
return( (size_t) -1 );
}
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_johab || cd->to==e_big5 || cd->to==e_big5hkscs ) {
struct charmap2 *table = cd->to==e_johab ? &johab_from_unicode :
cd->to==e_big5 ? &big5_from_unicode :
@@ -482,6 +454,8 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
+#endif
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_wansung || cd->to==e_jisgbpk ) {
struct charmap2 *table = cd->to==e_wansung ? &ksc5601_from_unicode :
&gb2312_from_unicode;
@@ -513,6 +487,8 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
+#endif
+#ifdef TO_CJK_ICONV
} else if ( cd->to==e_sjis ) {
unsigned char *plane1;
unsigned short *plane;
@@ -549,39 +525,7 @@ return( (size_t) -1 );
} else
return( (size_t) -1 );
}
- } else if ( cd->to==e_jis || cd->to==e_jis2 ||
- cd->to==e_jiskorean || cd->to==e_jisgb ) {
- struct charmap2 *table = cd->to==e_jisgb ? &gb2312_from_unicode :
- cd->to==e_jiskorean ? &ksc5601_from_unicode :
- &jis_from_unicode;
- unsigned short *plane;
- while ( *inlen>1 && *outlen>1 ) {
- int highch, lowch;
- if ( endian == end_little ) {
- highch = ((unsigned char *) *inbuf)[1], lowch = *(unsigned char *) *inbuf;
- } else {
- highch = ((unsigned char *) *inbuf)[2], lowch = ((unsigned char *) *inbuf)[3];
- }
- if ( highch>=table->first && highch<=table->last &&
- (plane = table->table[highch])!=NULL &&
- (ch=plane[lowch])!=0 ) {
- if ( ch>=0x8000 ) {
- if ( cd->to!=e_jis2 )
-return( (size_t) -1 );
- ch -= 0x8000;
- } else {
- if ( cd->to==e_jis2 )
-return( (size_t) -1 );
- }
- *((*outbuf)++) = (ch>>8);
- *((*outbuf)++) = (ch&0xff);
- *outlen -= 2;
- *inlen -= 4;
- *inbuf += 4;
- ++char_cnt;
- } else
-return( (size_t) -1 );
- }
+#endif
} else if ( cd->to==e_utf8 ) {
while ( *inlen>1 && *outlen>0 ) {
int uch;
@@ -648,62 +592,7 @@ return( (size_t) -1 );
*outlen -= sizeof(unichar_t);
++char_cnt;
}
- } else if ( cd->from==e_jis || cd->from==e_jis2 ||
- cd->from==e_jiskorean || cd->from==e_jisgb ) {
- table = cd->from==e_jisgb ? unicode_from_gb2312 :
- cd->from==e_jiskorean ? unicode_from_ksc5601 :
- cd->from==e_jis ? unicode_from_jis208 :
- unicode_from_jis212;
- while ( *inlen>1 && *outlen>1 ) {
- unsigned char *ipt = (unsigned char *) *inbuf;
- int ch;
- if ( *ipt<0x21 || *ipt>0x7e || ipt[1]<0x21 || ipt[1]>0x7e )
-return( (size_t) -1 );
- ch = (*ipt-0x21)*94 + (ipt[1]-0x21);
- ch = table[ch];
- *inlen -= 2;
- *inbuf = (char *) ipt+2;
- if ( endian==end_little ) {
- *((*outbuf)++) = ch&0xff;
- *((*outbuf)++) = ch>>8;
- } else {
- *((*outbuf)++) = ch>>8;
- *((*outbuf)++) = ch&0xff;
- }
- *outlen -= sizeof(unichar_t);
- ++char_cnt;
- }
- if ( *inlen==1 && *outlen>0 )
-return( (size_t) -1 ); /* Incomplete multi-byte sequence */
- } else if ( cd->from==e_wansung || cd->from==e_jisgbpk ) {
- table = cd->from==e_jisgbpk ? unicode_from_gb2312 :
- unicode_from_ksc5601 ;
- while ( *inlen>0 && *outlen>1 ) {
- unsigned char *ipt = (unsigned char *) *inbuf;
- int ch;
- if ( *ipt<0x7f ) {
- ch = *ipt;
- --*inlen;
- *inbuf = (char *) ipt+1;
- } else {
- if ( *ipt<0xa1 || *ipt>0xfe || ipt[1]<0xa1 || ipt[1]>0xfe ||
- *inlen==1 )
-return( (size_t) -1 );
- ch = (*ipt-0xa1)*94 + (ipt[1]-0xa1);
- ch = table[ch];
- *inlen -= 2;;
- *inbuf = (char *) ipt+2;
- }
- if ( endian==end_little ) {
- *((*outbuf)++) = ch&0xff;
- *((*outbuf)++) = ch>>8;
- } else {
- *((*outbuf)++) = ch>>8;
- *((*outbuf)++) = ch&0xff;
- }
- *outlen -= sizeof(unichar_t);
- ++char_cnt;
- }
+#ifdef FROM_CJK_ICONV
} else if ( cd->from==e_johab || cd->from==e_big5 || cd->from==e_big5hkscs ) {
int offset;
if ( cd->from==e_big5 ) {
@@ -786,6 +675,7 @@ return( (size_t) -1 );
*outlen -= sizeof(unichar_t);
++char_cnt;
}
+#endif
} else if ( cd->from==e_utf8 ) {
while ( *inlen>0 && *outlen>sizeof(unichar_t) ) {
unsigned char *ipt = (unsigned char *) *inbuf;
@@ -856,37 +746,7 @@ return( (size_t) -1 );
*outlen -= sizeof(unichar_t);
++char_cnt;
}
- } else if ( cd->from==e_jis || cd->from==e_jis2 ||
- cd->from==e_jiskorean || cd->from==e_jisgb ) {
- table = cd->from==e_jisgb ? unicode_from_gb2312 :
- cd->from==e_jiskorean ? unicode_from_ksc5601 :
- cd->from==e_jis ? unicode_from_jis208 :
- unicode_from_jis212;
- while ( *inlen>1 && *outlen>1 ) {
- unsigned char *ipt = (unsigned char *) *inbuf;
- int ch;
- if ( *ipt<0x21 || *ipt>0x7e || ipt[1]<0x21 || ipt[1]>0x7e )
-return( (size_t) -1 );
- ch = (*ipt-0x21)*94 + (ipt[1]-0x21);
- ch = table[ch];
- *inlen -= 2;
- *inbuf = (char *) ipt+2;
- if ( endian==end_little ) {
- *((*outbuf)++) = 0;
- *((*outbuf)++) = 0;
- *((*outbuf)++) = ch&0xff;
- *((*outbuf)++) = ch>>8;
- } else {
- *((*outbuf)++) = ch>>8;
- *((*outbuf)++) = ch&0xff;
- *((*outbuf)++) = 0;
- *((*outbuf)++) = 0;
- }
- *outlen -= sizeof(unichar_t);
- ++char_cnt;
- }
- if ( *inlen==1 && *outlen>0 )
-return( (size_t) -1 ); /* Incomplete multi-byte sequence */
+#ifdef FROM_CJK_ICONV
} else if ( cd->from==e_wansung || cd->from==e_jisgbpk ) {
table = cd->from==e_jisgbpk ? unicode_from_gb2312 :
unicode_from_ksc5601 ;
@@ -1010,6 +870,7 @@ return( (size_t) -1 );
*outlen -= sizeof(unichar_t);
++char_cnt;
}
+#endif
} else if ( cd->from==e_utf8 ) {
while ( *inlen>0 && *outlen>sizeof(unichar_t) ) {
unsigned char *ipt = (unsigned char *) *inbuf;
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c
index 316234246a9..b97aa3a633f 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/Unicode/ucharmap.c
@@ -75,6 +75,7 @@ unichar_t *encoding2u_strncpy(unichar_t *uto, const char *_from, int n, enum enc
fprintf( stderr, "Unexpected encoding %d, I'll pretend it's latin1\n", cs );
}
return( encoding2u_strncpy(uto,_from,n,e_iso8859_1));
+#ifdef FROM_CJK_ICONV
case e_johab: case e_big5: case e_big5hkscs:
if ( cs==e_big5 ) {
offset = 0xa100;
@@ -141,6 +142,7 @@ return( encoding2u_strncpy(uto,_from,n,e_iso8859_1));
--n;
}
break;
+#endif
}
} else if ( cs==e_unicode ) {
unichar_t *ufrom = (unichar_t *) from;
@@ -206,194 +208,6 @@ return( encoding2u_strncpy(uto,_from,n,e_iso8859_1));
return( uto );
}
-char *u2encoding_strncpy(char *to, const unichar_t *ufrom, int n, enum encoding cs) {
- char *pt = to;
-
- /* we just ignore anything that doesn't fit in the encoding we look at */
- if ( cs<e_first2byte ) {
- struct charmap *table = NULL;
- unsigned char *plane;
- table = alphabets_from_unicode[cs];
- if ( table==NULL ) { /* ASCII */
- while ( *ufrom && n>0 ) {
- int ch = *ufrom;
- if ( ch<127 ) {
- *pt++ = ch;
- --n;
- }
- ++ufrom;
- }
- } else {
- while ( *ufrom && n>0 ) {
- int highch = *ufrom>>8, ch;
- if ( highch>=table->first && highch<=table->last &&
- (plane = table->table[highch])!=NULL &&
- (ch=plane[*ufrom&0xff])!=0 ) {
- *pt++ = ch;
- --n;
- }
- ++ufrom;
- }
- }
- if ( n>0 )
- *pt = '\0';
- } else if ( cs<e_unicode ) {
- struct charmap2 *table;
- unsigned short *plane;
- unsigned char *plane1;
-
- *to = '\0';
- switch ( cs ) {
- default:
- if ( !bad_enc_warn ) {
- bad_enc_warn = true;
- fprintf( stderr, "Unexpected encoding %d, I'll pretend it's latin1\n", cs );
- }
-return( u2encoding_strncpy(to,ufrom,n,e_iso8859_1));
- case e_johab: case e_big5: case e_big5hkscs:
- table = cs==e_big5 ? &big5_from_unicode :
- cs==e_big5hkscs ? &big5hkscs_from_unicode :
- &johab_from_unicode;
- while ( *ufrom && n>0 ) {
- int highch = *ufrom>>8, ch;
- if ( *ufrom<0x80 ) {
- *pt++ = *ufrom;
- --n;
- } else if ( highch>=table->first && highch<=table->last &&
- (plane = table->table[highch-table->first])!=NULL &&
- (ch=plane[*ufrom&0xff])!=0 ) {
- *pt++ = ch>>8;
- *pt++ = ch&0xff;
- n -= 2;
- }
- ufrom ++;
- }
- break;
- case e_wansung:
- while ( *ufrom && n>0 ) {
- int highch = *ufrom>>8, ch;
- if ( *ufrom<0x80 ) {
- *pt++ = *ufrom;
- --n;
- } else if ( highch>=ksc5601_from_unicode.first && highch<=ksc5601_from_unicode.last &&
- (plane = ksc5601_from_unicode.table[highch-ksc5601_from_unicode.first])!=NULL &&
- (ch=plane[*ufrom&0xff])!=0 ) {
- *pt++ = (ch>>8) + 0x80;
- *pt++ = (ch&0xff) + 0x80;
- n -= 2;
- }
- ufrom ++;
- }
- break;
- case e_jisgb:
- while ( *ufrom && n>0 ) {
- int highch = *ufrom>>8, ch;
- if ( *ufrom<0x80 ) {
- *pt++ = *ufrom;
- --n;
- } else if ( highch>=gb2312_from_unicode.first && highch<=gb2312_from_unicode.last &&
- (plane = gb2312_from_unicode.table[highch-gb2312_from_unicode.first])!=NULL &&
- (ch=plane[*ufrom&0xff])!=0 ) {
- *pt++ = (ch>>8) + 0x80;
- *pt++ = (ch&0xff) + 0x80;
- n -= 2;
- }
- ufrom ++;
- }
- break;
- case e_sjis:
- while ( *ufrom && n>0 ) {
- int highch = *ufrom>>8, ch;
- if ( highch>=jis201_from_unicode.first && highch<=jis201_from_unicode.last &&
- (plane1 = jis201_from_unicode.table[highch-jis201_from_unicode.first])!=NULL &&
- (ch=plane1[*ufrom&0xff])!=0 ) {
- *pt++ = ch;
- --n;
- } else if ( *ufrom<' ' ) { /* control chars */
- *pt++ = *ufrom;
- --n;
- } else if ( highch>=jis_from_unicode.first && highch<=jis_from_unicode.last &&
- (plane = jis_from_unicode.table[highch-jis_from_unicode.first])!=NULL &&
- (ch=plane[*ufrom&0xff])!=0 && ch<0x8000 ) { /* no jis212 */
- int j1 = ch>>8, j2 = ch&0xff;
- int ro = j1<95 ? 112 : 176;
- int co = (j1&1) ? (j2>95?32:31) : 126;
- *pt++ = ((j1+1)>>1)+ro;
- *pt++ = j2+co;
- n -= 2;
- }
- ++ufrom;
- }
- break;
- }
- if ( n>0 )
- *pt = '\0';
- } else if ( cs==e_unicode ) {
- unichar_t *uto = (unichar_t *) to;
- while ( *ufrom && n>1 ) {
- *uto++ = *ufrom++;
- n-=sizeof(unichar_t);
- }
- if ( n>1 )
- *uto = '\0';
- } else if ( cs==e_unicode_backwards ) {
- unichar_t *uto = (unichar_t *) to;
- while ( *ufrom && n>sizeof(unichar_t)-1 ) {
-#ifdef UNICHAR_16
- unichar_t ch = (*ufrom>>8)|((*ufrom&0xff)<<8);
-#else
- unichar_t ch = (*ufrom>>24)|((*ufrom>>8)&0xff00)|
- ((*ufrom<<8)&0xff0000)|(*ufrom<<24);
-#endif
- *uto++ = ch;
- ++ufrom;
- n-=sizeof(unichar_t);
- }
- if ( n>1 )
- *uto = '\0';
- } else if ( cs==e_utf8 ) {
- while ( *ufrom ) {
- if ( *ufrom<0x80 ) {
- if ( n<=1 )
- break;
- *pt++ = *ufrom;
- --n;
- } else if ( *ufrom<0x800 ) {
- if ( n<=2 )
- break;
- *pt++ = 0xc0 | (*ufrom>>6);
- *pt++ = 0x80 | (*ufrom&0x3f);
- n -= 2;
- } else if ( *ufrom>=0xd800 && *ufrom<0xdc00 && ufrom[1]>=0xdc00 && ufrom[1]<0xe000 ) {
- int u = ((*ufrom>>6)&0xf)+1, y = ((*ufrom&3)<<4) | ((ufrom[1]>>6)&0xf);
- if ( n<=4 )
- break;
- *pt++ = 0xf0 | (u>>2);
- *pt++ = 0x80 | ((u&3)<<4) | ((*ufrom>>2)&0xf);
- *pt++ = 0x80 | y;
- *pt++ = 0x80 | (ufrom[1]&0x3f);
- n -= 4;
- } else {
- if ( n<=3 )
- break;
- *pt++ = 0xe0 | (*ufrom>>12);
- *pt++ = 0x80 | ((*ufrom>>6)&0x3f);
- *pt++ = 0x80 | (*ufrom&0x3f);
- }
- ++ufrom;
- }
- if ( n>1 )
- *pt = '\0';
- } else {
- if ( !bad_enc_warn ) {
- bad_enc_warn = true;
- fprintf( stderr, "Unexpected encoding %d, I'll pretend it's latin1\n", cs );
- }
-return( u2encoding_strncpy(to,ufrom,n,e_iso8859_1));
- }
-
-return( to );
-}
#if HAVE_ICONV_H
static char *old_local_name=NULL;
@@ -522,23 +336,6 @@ return( uto );
return( encoding2u_strncpy(uto,from,n,local_encoding));
}
-char *u2def_strncpy(char *to, const unichar_t *ufrom, int n) {
-#if HAVE_ICONV_H
- if ( my_iconv_setup() ) {
- size_t in_left = sizeof(unichar_t)*n, out_left = n;
- char *cfrom = (char *) ufrom, *cto=to;
- iconv(from_unicode, (iconv_arg2_t) &cfrom, &in_left, &cto, &out_left);
- if ( cto<to+n ) *cto++ = '\0';
- if ( cto<to+n ) *cto++ = '\0';
-#ifndef UNICHAR_16
- if ( cto<to+n ) *cto++ = '\0';
- if ( cto<to+n ) *cto++ = '\0';
-#endif
-return( to );
- }
-#endif
-return( u2encoding_strncpy(to,ufrom,n,local_encoding));
-}
unichar_t *def2u_copy(const char *from) {
int len;
@@ -570,45 +367,6 @@ return( uto );
return( ret );
}
-char *u2def_copy(const unichar_t *ufrom) {
- int len;
- char *to, *ret;
-
- if ( ufrom==NULL )
-return( NULL );
- len = u_strlen(ufrom);
-#if HAVE_ICONV_H
- if ( my_iconv_setup() ) {
- size_t in_left = sizeof(unichar_t)*len, out_left = 3*len;
- char *cfrom = (char *) ufrom, *cto;
- cto = to = galloc(3*len+2);
- iconv(from_unicode, (iconv_arg2_t) &cfrom, &in_left, &cto, &out_left);
- *cto++ = '\0';
- *cto++ = '\0';
-#ifndef UNICHAR_16
- *cto++ = '\0';
- *cto++ = '\0';
-#endif
-return( to );
- }
-#endif
- if ( local_encoding==e_utf8 )
- len *= 3;
- if ( local_encoding>=e_first2byte )
- len *= 2;
- to = galloc(len+sizeof(unichar_t));
- ret = u2encoding_strncpy(to,ufrom,len,local_encoding);
- if ( ret==NULL )
- free( to );
- else if ( local_encoding<e_first2byte )
- to[len] = '\0';
- else {
- to[len] = '\0';
- to[len+1] = '\0';
- }
-return( ret );
-}
-
char *def2utf8_copy(const char *from) {
int len;
char *ret;
@@ -643,33 +401,3 @@ return( NULL );
return( ret );
}
-char *utf82def_copy(const char *ufrom) {
- int len;
- char *ret;
- unichar_t *u2from;
-
- if ( ufrom==NULL )
-return( NULL );
- len = strlen(ufrom);
-#if HAVE_ICONV_H
- if ( my_iconv_setup() ) {
- size_t in_left = len, out_left = 3*len;
- char *cfrom = (char *) ufrom, *cto, *to;
- cto = to = galloc(3*len+2);
- iconv(from_utf8, (iconv_arg2_t) &cfrom, &in_left, &cto, &out_left);
- *cto++ = '\0';
- *cto++ = '\0';
-#ifndef UNICHAR_16
- *cto++ = '\0';
- *cto++ = '\0';
-#endif
-return( to );
- }
-#endif
- if ( local_encoding==e_utf8 )
-return( copy( ufrom )); /* Well that's easy */
- u2from = utf82u_copy(ufrom);
- ret = u2def_copy(u2from);
- free(u2from);
-return( ret );
-}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/autohint.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/autohint.c
index a55a3d3d637..38e3b1b3b48 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/autohint.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/autohint.c
@@ -94,17 +94,21 @@ void FindBlues( SplineFont *sf, int layer, real blues[14], real otherblues[10])
for ( i=0; i<sf->glyphcnt; ++i ) {
if ( sf->glyphs[i]!=NULL && sf->glyphs[i]->layers[layer].splines!=NULL ) {
int enc = sf->glyphs[i]->unicodeenc;
+#ifndef LUA_FF_LIB
const unichar_t *upt;
+#endif
if ( enc<0x10000 && isalnum(enc) &&
((enc>=32 && enc<128 ) || enc == 0xfe || enc==0xf0 || enc==0xdf ||
enc==0x131 ||
(enc>=0x391 && enc<=0x3f3 ) ||
(enc>=0x400 && enc<=0x4e9 ) )) {
/* no accented characters (or ligatures) */
+#ifndef LUA_FF_LIB
if ( unicode_alternates[enc>>8]!=NULL &&
(upt =unicode_alternates[enc>>8][enc&0xff])!=NULL &&
upt[1]!='\0' )
continue;
+#endif
SplineCharFindBounds(sf->glyphs[i],&b);
if ( b.miny==0 && b.maxy==0 )
continue;
@@ -256,16 +260,20 @@ void FindBlues( SplineFont *sf, int layer, real blues[14], real otherblues[10])
base[3] = base[4] = 0;
for ( i=0; i<sf->glyphcnt; ++i ) if ( sf->glyphs[i]!=NULL ) {
int enc = sf->glyphs[i]->unicodeenc;
+#ifndef LUA_FF_LIB
const unichar_t *upt;
+#endif
if ( enc<0x10000 && isalnum(enc) &&
((enc>=32 && enc<128 ) || enc == 0xfe || enc==0xf0 || enc==0xdf ||
(enc>=0x391 && enc<=0x3f3 ) ||
(enc>=0x400 && enc<=0x4e9 ) )) {
/* no accented characters (or ligatures) */
+#ifndef LUA_FF_LIB
if ( unicode_alternates[enc>>8]!=NULL &&
(upt =unicode_alternates[enc>>8][enc&0xff])!=NULL &&
upt[1]!='\0' )
continue;
+#endif
SplineCharFindBounds(sf->glyphs[i],&b);
if ( b.miny==0 && b.maxy==0 )
continue;
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c
index 6fccf29e8ae..b4be6b5b5fe 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/encoding.c
@@ -289,16 +289,8 @@ return( &unicodefull );
/* Mac seems to work ok */
if ( strcasecmp(name,"win")==0 || strcasecmp(name,"ansi")==0 )
iconv_name = "MS-ANSI"; /* "WINDOWS-1252";*/
- else if ( strncasecmp(name,"jis208",6)==0 || strncasecmp(name,"jisx0208",8)==0 )
- iconv_name = "ISO-2022-JP";
- else if ( strncasecmp(name,"jis212",6)==0 || strncasecmp(name,"jisx0212",8)==0 )
- iconv_name = "ISO-2022-JP-2";
- else if ( strncasecmp(name,"ksc5601",7)==0 )
- iconv_name = "ISO-2022-KR";
else if ( strcasecmp(name,"gb2312pk")==0 || strcasecmp(name,"gb2312packed")==0 )
- iconv_name = "EUC-CN";
- else if ( strncasecmp(name,"gb2312",6)==0 )
- iconv_name = "ISO-2022-CN";
+ iconv_name = "EUC-CN";
else if ( strcasecmp(name,"wansung")==0 )
iconv_name = "EUC-KR";
else if ( strcasecmp(name,"EUC-CN")==0 ) {
@@ -720,8 +712,7 @@ return( maybe );
maybefile = NULL;
}
} else {
- file = utf82def_copy(uret);
- free(uret);
+ file = uret; /* no utf82def() call for luatex */
}
}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c
index 2f92df3e03e..63212410578 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/macbinary.c
@@ -36,15 +36,15 @@
#include "ttf.h"
#include "psfont.h"
#ifdef LUA_FF_LIB
-#undef __Mac
+# undef __Mac
#endif
#if __Mac
-# include <ctype.h>
-# include </Developer/Headers/FlatCarbon/Files.h>
+# include <ctype.h>
+# include </Developer/Headers/FlatCarbon/Files.h>
#else
-# include <utype.h>
-#undef __Mac
-#define __Mac 0
+# include <utype.h>
+# undef __Mac
+# define __Mac 0
#endif
const int mac_dpi = 72;
@@ -123,82 +123,90 @@ struct resourcetype {
struct macbinaryheader {
char *macfilename;
- char *binfilename; /* if macfilename is null and this is set we will figure out macfilename by removing .bin */
+ char *binfilename; /* if macfilename is null and this is set we will figure out macfilename by removing .bin */
uint32 type;
uint32 creator;
};
-
+
enum psstyle_flags { psf_bold = 1, psf_italic = 2, psf_outline = 4,
- psf_shadow = 0x8, psf_condense = 0x10, psf_extend = 0x20 };
+ psf_shadow = 0x8, psf_condense = 0x10, psf_extend = 0x20
+};
-uint16 _MacStyleCode( char *styles, SplineFont *sf, uint16 *psstylecode ) {
- unsigned short stylecode= 0, psstyle=0;
+uint16 _MacStyleCode(char *styles, SplineFont * sf, uint16 * psstylecode)
+{
+ unsigned short stylecode = 0, psstyle = 0;
- if ( strstrmatch( styles, "Bold" ) || strstrmatch(styles,"Demi") ||
- strstrmatch( styles,"Heav") || strstrmatch(styles,"Blac") ||
+ if (strstrmatch(styles, "Bold") || strstrmatch(styles, "Demi") ||
+ strstrmatch(styles, "Heav") || strstrmatch(styles, "Blac") ||
/* A few fonts have German/French styles in their names */
- strstrmatch( styles,"Fett") || strstrmatch(styles,"Gras") ) {
- stylecode = sf_bold;
- psstyle = psf_bold;
- } else if ( sf!=NULL && sf->weight!=NULL &&
- (strstrmatch( sf->weight, "Bold" ) || strstrmatch(sf->weight,"Demi") ||
- strstrmatch( sf->weight,"Heav") || strstrmatch(sf->weight,"Blac") ||
- strstrmatch( sf->weight,"Fett") || strstrmatch(sf->weight,"Gras")) ) {
- stylecode = sf_bold;
- psstyle = psf_bold;
+ strstrmatch(styles, "Fett") || strstrmatch(styles, "Gras")) {
+ stylecode = sf_bold;
+ psstyle = psf_bold;
+ } else if (sf != NULL && sf->weight != NULL &&
+ (strstrmatch(sf->weight, "Bold")
+ || strstrmatch(sf->weight, "Demi")
+ || strstrmatch(sf->weight, "Heav")
+ || strstrmatch(sf->weight, "Blac")
+ || strstrmatch(sf->weight, "Fett")
+ || strstrmatch(sf->weight, "Gras"))) {
+ stylecode = sf_bold;
+ psstyle = psf_bold;
}
/* URW uses four leter abbreviations of Italic and Oblique */
/* Somebody else uses two letter abbrevs */
- if ( (sf!=NULL && sf->italicangle!=0) ||
- strstrmatch( styles, "Ital" ) ||
- strstrmatch( styles, "Obli" ) ||
- strstrmatch(styles, "Slanted") ||
- strstrmatch(styles, "Kurs") ||
- strstr( styles,"It" ) ) {
- stylecode |= sf_italic;
- psstyle |= psf_italic;
+ if ((sf != NULL && sf->italicangle != 0) ||
+ strstrmatch(styles, "Ital") ||
+ strstrmatch(styles, "Obli") ||
+ strstrmatch(styles, "Slanted") ||
+ strstrmatch(styles, "Kurs") || strstr(styles, "It")) {
+ stylecode |= sf_italic;
+ psstyle |= psf_italic;
}
- if ( strstrmatch( styles, "Underline" ) ) {
- stylecode |= sf_underline;
+ if (strstrmatch(styles, "Underline")) {
+ stylecode |= sf_underline;
}
- if ( strstrmatch( styles, "Outl" ) ) {
- stylecode |= sf_outline;
- psstyle |= psf_outline;
+ if (strstrmatch(styles, "Outl")) {
+ stylecode |= sf_outline;
+ psstyle |= psf_outline;
}
- if ( strstr(styles,"Shadow")!=NULL ) {
- stylecode |= sf_shadow;
- psstyle |= psf_shadow;
+ if (strstr(styles, "Shadow") != NULL) {
+ stylecode |= sf_shadow;
+ psstyle |= psf_shadow;
}
- if ( strstrmatch( styles, "Cond" ) || strstr( styles,"Cn") ||
- strstrmatch( styles, "Narrow") ) {
- stylecode |= sf_condense;
- psstyle |= psf_condense;
+ if (strstrmatch(styles, "Cond") || strstr(styles, "Cn") ||
+ strstrmatch(styles, "Narrow")) {
+ stylecode |= sf_condense;
+ psstyle |= psf_condense;
}
- if ( strstrmatch( styles, "Exte" ) || strstr( styles,"Ex") ) {
- stylecode |= sf_extend;
- psstyle |= psf_extend;
+ if (strstrmatch(styles, "Exte") || strstr(styles, "Ex")) {
+ stylecode |= sf_extend;
+ psstyle |= psf_extend;
}
- if ( (psstyle&psf_extend) && (psstyle&psf_condense) ) {
- if ( sf!=NULL )
- LogError( _("Warning: %s(%s) is both extended and condensed. That's impossible.\n"),
- sf->fontname, sf->origname );
- else
- LogError( _("Warning: Both extended and condensed. That's impossible.\n") );
- psstyle &= ~psf_extend;
- stylecode &= ~sf_extend;
+ if ((psstyle & psf_extend) && (psstyle & psf_condense)) {
+ if (sf != NULL)
+ LogError(_
+ ("Warning: %s(%s) is both extended and condensed. That's impossible.\n"),
+ sf->fontname, sf->origname);
+ else
+ LogError(_
+ ("Warning: Both extended and condensed. That's impossible.\n"));
+ psstyle &= ~psf_extend;
+ stylecode &= ~sf_extend;
}
- if ( psstylecode!=NULL )
- *psstylecode = psstyle;
-return( stylecode );
+ if (psstylecode != NULL)
+ *psstylecode = psstyle;
+ return (stylecode);
}
/* ******************************** Reading ********************************* */
-static SplineFont *SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,long rdata_pos,
- long name_list, int flags) {
+static SplineFont *SearchPostscriptResources(FILE * f, long rlistpos,
+ int subcnt, long rdata_pos,
+ long name_list, int flags)
+{
long here = ftell(f);
long *offsets, lenpos;
int rname = -1, tmp;
@@ -209,242 +217,257 @@ static SplineFont *SearchPostscriptResources(FILE *f,long rlistpos,int subcnt,lo
/* postscript font. It appears to be split up into chunks where the */
/* maximum chunk size is 0x800, each section (ascii, binary, ascii, eof) */
/* has its own set of chunks (ie chunks don't cross sections) */
- char *buffer=NULL;
+ char *buffer = NULL;
int max = 0;
FILE *pfb;
FontDict *fd;
SplineFont *sf;
- (void)name_list;
- fseek(f,rlistpos,SEEK_SET);
- rsrcids = gcalloc(subcnt,sizeof(short));
- offsets = gcalloc(subcnt,sizeof(long));
- for ( i=0; i<subcnt; ++i ) {
- rsrcids[i] = getushort(f);
- tmp = (short) getushort(f);
- if ( rname==-1 ) rname = tmp;
- /* flags = */ getc(f);
- ch1 = getc(f); ch2 = getc(f);
- offsets[i] = rdata_pos+((ch1<<16)|(ch2<<8)|getc(f));
- /* mbz = */ getlong(f);
+ (void) name_list;
+ fseek(f, rlistpos, SEEK_SET);
+ rsrcids = gcalloc(subcnt, sizeof(short));
+ offsets = gcalloc(subcnt, sizeof(long));
+ for (i = 0; i < subcnt; ++i) {
+ rsrcids[i] = getushort(f);
+ tmp = (short) getushort(f);
+ if (rname == -1)
+ rname = tmp;
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ offsets[i] = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
}
pfb = tmpfile();
- if ( pfb==NULL ) {
- LogError( _("Can't open temporary file for postscript output\n") );
- fseek(f,here,SEEK_SET );
- free(offsets);
-return(NULL);
+ if (pfb == NULL) {
+ LogError(_("Can't open temporary file for postscript output\n"));
+ fseek(f, here, SEEK_SET);
+ free(offsets);
+ return (NULL);
}
- putc(0x80,pfb);
- putc(1,pfb);
+ putc(0x80, pfb);
+ putc(1, pfb);
lenpos = ftell(pfb);
- putc(0,pfb);
- putc(0,pfb);
- putc(0,pfb);
- putc(0,pfb);
- len = 0; type = 1;
+ putc(0, pfb);
+ putc(0, pfb);
+ putc(0, pfb);
+ putc(0, pfb);
+ len = 0;
+ type = 1;
id = 501;
- for ( i=0; i<subcnt; ++i ) {
- for ( j=0; j<subcnt; ++j )
- if ( rsrcids[j]==id )
- break;
- if ( j == subcnt ) {
- LogError( _("Missing POST resource %u\n"), id );
- break;
- }
- id = id + 1;
- fseek(f,offsets[j],SEEK_SET);
- rlen = getlong(f);
- ch1 = getc(f); ch2 = getc(f);
- rlen -= 2; /* those two bytes don't count as real data */
- if ( ch1==type )
- len += rlen;
- else {
- long hold = ftell(pfb);
- fseek(pfb,lenpos,SEEK_SET);
- putc(len>>24,pfb);
- putc((len>>16)&0xff,pfb);
- putc((len>>8)&0xff,pfb);
- putc(len&0xff,pfb);
- fseek(pfb,hold,SEEK_SET);
- if ( ch1==5 ) /* end of font mark */
- break;
- putc(0x80,pfb);
- putc(ch1,pfb);
- lenpos = ftell(pfb);
- putc(0,pfb);
- putc(0,pfb);
- putc(0,pfb);
- putc(0,pfb);
- type = ch1;
- len = rlen;
- }
- if ( rlen>max ) {
- free(buffer);
- max = rlen;
- if ( max<0x800 ) max = 0x800;
- buffer=galloc(max);
- if ( buffer==NULL ) {
- LogError( _("Out of memory\n") );
- exit( 1 );
- }
- }
- fread(buffer,1,rlen,f);
- fwrite(buffer,1,rlen,pfb);
+ for (i = 0; i < subcnt; ++i) {
+ for (j = 0; j < subcnt; ++j)
+ if (rsrcids[j] == id)
+ break;
+ if (j == subcnt) {
+ LogError(_("Missing POST resource %u\n"), id);
+ break;
+ }
+ id = id + 1;
+ fseek(f, offsets[j], SEEK_SET);
+ rlen = getlong(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ rlen -= 2; /* those two bytes don't count as real data */
+ if (ch1 == type)
+ len += rlen;
+ else {
+ long hold = ftell(pfb);
+ fseek(pfb, lenpos, SEEK_SET);
+ putc(len >> 24, pfb);
+ putc((len >> 16) & 0xff, pfb);
+ putc((len >> 8) & 0xff, pfb);
+ putc(len & 0xff, pfb);
+ fseek(pfb, hold, SEEK_SET);
+ if (ch1 == 5) /* end of font mark */
+ break;
+ putc(0x80, pfb);
+ putc(ch1, pfb);
+ lenpos = ftell(pfb);
+ putc(0, pfb);
+ putc(0, pfb);
+ putc(0, pfb);
+ putc(0, pfb);
+ type = ch1;
+ len = rlen;
+ }
+ if (rlen > max) {
+ free(buffer);
+ max = rlen;
+ if (max < 0x800)
+ max = 0x800;
+ buffer = galloc(max);
+ if (buffer == NULL) {
+ LogError(_("Out of memory\n"));
+ exit(1);
+ }
+ }
+ fread(buffer, 1, rlen, f);
+ fwrite(buffer, 1, rlen, pfb);
}
free(buffer);
free(offsets);
- free(rsrcids);
- putc(0x80,pfb);
- putc(3,pfb);
- fseek(pfb,lenpos,SEEK_SET);
- putc(len>>24,pfb);
- putc((len>>16)&0xff,pfb);
- putc((len>>8)&0xff,pfb);
- putc(len&0xff,pfb);
- fseek(f,here,SEEK_SET);
+ free(rsrcids);
+ putc(0x80, pfb);
+ putc(3, pfb);
+ fseek(pfb, lenpos, SEEK_SET);
+ putc(len >> 24, pfb);
+ putc((len >> 16) & 0xff, pfb);
+ putc((len >> 8) & 0xff, pfb);
+ putc(len & 0xff, pfb);
+ fseek(f, here, SEEK_SET);
rewind(pfb);
- if ( flags&ttf_onlynames )
-return( (SplineFont *) _NamesReadPostscript(pfb) ); /* This closes the font for us */
+ if (flags & ttf_onlynames)
+ return ((SplineFont *) _NamesReadPostscript(pfb)); /* This closes the font for us */
fd = _ReadPSFont(pfb);
sf = NULL;
- if ( fd!=NULL ) {
- sf = SplineFontFromPSFont(fd);
- PSFontFree(fd);
- /* There is no FOND in a postscript file, so we can't read any kerning*/
+ if (fd != NULL) {
+ sf = SplineFontFromPSFont(fd);
+ PSFontFree(fd);
+ /* There is no FOND in a postscript file, so we can't read any kerning */
}
fclose(pfb);
-return( sf );
+ return (sf);
}
-static SplineFont *SearchTtfResources(FILE *f,long rlistpos,int subcnt,long rdata_pos,
- long name_list,char *filename,int flags,enum openflags openflags) {
+static SplineFont *SearchTtfResources(FILE * f, long rlistpos, int subcnt,
+ long rdata_pos, long name_list,
+ char *filename, int flags,
+ enum openflags openflags)
+{
long here, start = ftell(f);
long roff;
int rname = -1;
int ch1, ch2;
int len, i, rlen, ilen;
/* The sfnt resource is just a copy of the ttf file */
- char *buffer=NULL;
+ char *buffer = NULL;
int max = 0;
FILE *ttf;
SplineFont *sf;
int which = 0;
char **names;
- char *pt,*lparen, *rparen;
- char *chosenname=NULL;
- (void)name_list;
- fseek(f,rlistpos,SEEK_SET);
- if ( subcnt>1 || (flags&ttf_onlynames) ) {
- names = gcalloc(subcnt+1,sizeof(char *));
- for ( i=0; i<subcnt; ++i ) {
- /* resource id = */ getushort(f);
- /* rname = (short) */ getushort(f);
- /* flags = */ getc(f);
- ch1 = getc(f); ch2 = getc(f);
- roff = rdata_pos+((ch1<<16)|(ch2<<8)|getc(f));
- /* mbz = */ getlong(f);
- here = ftell(f);
- names[i] = TTFGetFontName(f,roff+4,roff+4);
- if ( names[i]==NULL ) {
- char buffer[32];
- sprintf( buffer, "Nameless%d", i );
- names[i] = copy(buffer);
- }
- fseek(f,here,SEEK_SET);
- }
- if ( flags&ttf_onlynames ) {
-return( (SplineFont *) names );
- }
- if ((pt = strrchr(filename,'/'))==NULL ) pt = filename;
- /* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */
- /* that ff wouldn't open it */
- /* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */
- if ( (lparen = strrchr(pt,'('))!=NULL &&
- (rparen = strrchr(lparen,')'))!=NULL &&
- rparen[1]=='\0' ) {
- char *find = copy(lparen+1);
- pt = strchr(find,')');
- if ( pt!=NULL ) *pt='\0';
- for ( which=subcnt-1; which>=0; --which )
- if ( strcmp(names[which],find)==0 )
- break;
- if ( which==-1 ) {
- char *end;
- which = strtol(find,&end,10);
- if ( *end!='\0' )
- which = -1;
- }
- if ( which==-1 ) {
- char *fn = copy(filename);
- fn[lparen-filename] = '\0';
- ff_post_error(_("Not in Collection"),_("%s is not in %.100s"),find,fn);
- free(fn);
- }
- free(find);
- } else
- which = 0;
- if ( lparen==NULL && which!=-1 )
- chosenname = copy(names[which]);
- for ( i=0; i<subcnt; ++i )
- free(names[i]);
- free(names);
- fseek(f,rlistpos,SEEK_SET);
+ char *pt, *lparen, *rparen;
+ char *chosenname = NULL;
+ (void) name_list;
+ fseek(f, rlistpos, SEEK_SET);
+ if (subcnt > 1 || (flags & ttf_onlynames)) {
+ names = gcalloc(subcnt + 1, sizeof(char *));
+ for (i = 0; i < subcnt; ++i) {
+ /* resource id = */ getushort(f);
+ /* rname = (short) */ getushort(f);
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
+ here = ftell(f);
+ names[i] = TTFGetFontName(f, roff + 4, roff + 4);
+ if (names[i] == NULL) {
+ char buffer[32];
+ sprintf(buffer, "Nameless%d", i);
+ names[i] = copy(buffer);
+ }
+ fseek(f, here, SEEK_SET);
+ }
+ if (flags & ttf_onlynames) {
+ return ((SplineFont *) names);
+ }
+ if ((pt = strrchr(filename, '/')) == NULL)
+ pt = filename;
+ /* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */
+ /* that ff wouldn't open it */
+ /* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */
+ if ((lparen = strrchr(pt, '(')) != NULL &&
+ (rparen = strrchr(lparen, ')')) != NULL && rparen[1] == '\0') {
+ char *find = copy(lparen + 1);
+ pt = strchr(find, ')');
+ if (pt != NULL)
+ *pt = '\0';
+ for (which = subcnt - 1; which >= 0; --which)
+ if (strcmp(names[which], find) == 0)
+ break;
+ if (which == -1) {
+ char *end;
+ which = strtol(find, &end, 10);
+ if (*end != '\0')
+ which = -1;
+ }
+ if (which == -1) {
+ char *fn = copy(filename);
+ fn[lparen - filename] = '\0';
+ ff_post_error(_("Not in Collection"), _("%s is not in %.100s"),
+ find, fn);
+ free(fn);
+ }
+ free(find);
+ } else
+ which = 0;
+ if (lparen == NULL && which != -1)
+ chosenname = copy(names[which]);
+ for (i = 0; i < subcnt; ++i)
+ free(names[i]);
+ free(names);
+ fseek(f, rlistpos, SEEK_SET);
}
- for ( i=0; i<subcnt; ++i ) {
- /* resource id = */ getushort(f);
- rname = (short) getushort(f);
- /* flags = */ getc(f);
- ch1 = getc(f); ch2 = getc(f);
- roff = rdata_pos+((ch1<<16)|(ch2<<8)|getc(f));
- /* mbz = */ getlong(f);
- if ( i!=which )
- continue;
- here = ftell(f);
-
- ttf = tmpfile();
- if ( ttf==NULL ) {
- LogError( _("Can't open temporary file for truetype output.\n") );
- continue;
- }
-
- fseek(f,roff,SEEK_SET);
- ilen = rlen = getlong(f);
- if ( rlen>16*1024 )
- ilen = 16*1024;
- if ( ilen>max ) {
- free(buffer);
- max = ilen;
- if ( max<0x800 ) max = 0x800;
- buffer=malloc(max);
- }
- for ( len=0; len<rlen; ) {
- int temp = ilen;
- if ( rlen-len<ilen ) temp = rlen-len;
- temp = fread(buffer,1,temp,f);
- if ( temp==EOF )
- break;
- fwrite(buffer,1,temp,ttf);
- len += temp;
- }
- rewind(ttf);
- sf = _SFReadTTF(ttf,flags,openflags,NULL,NULL);
- fclose(ttf);
- if ( sf!=NULL ) {
- free(buffer);
- fseek(f,start,SEEK_SET);
- if ( sf->chosenname==NULL ) sf->chosenname = chosenname;
-return( sf );
- }
- fseek(f,here,SEEK_SET);
+ for (i = 0; i < subcnt; ++i) {
+ /* resource id = */ getushort(f);
+ rname = (short) getushort(f);
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
+ if (i != which)
+ continue;
+ here = ftell(f);
+
+ ttf = tmpfile();
+ if (ttf == NULL) {
+ LogError(_("Can't open temporary file for truetype output.\n"));
+ continue;
+ }
+
+ fseek(f, roff, SEEK_SET);
+ ilen = rlen = getlong(f);
+ if (rlen > 16 * 1024)
+ ilen = 16 * 1024;
+ if (ilen > max) {
+ free(buffer);
+ max = ilen;
+ if (max < 0x800)
+ max = 0x800;
+ buffer = malloc(max);
+ }
+ for (len = 0; len < rlen;) {
+ int temp = ilen;
+ if (rlen - len < ilen)
+ temp = rlen - len;
+ temp = fread(buffer, 1, temp, f);
+ if (temp == EOF)
+ break;
+ fwrite(buffer, 1, temp, ttf);
+ len += temp;
+ }
+ rewind(ttf);
+ sf = _SFReadTTF(ttf, flags, openflags, NULL, NULL);
+ fclose(ttf);
+ if (sf != NULL) {
+ free(buffer);
+ fseek(f, start, SEEK_SET);
+ if (sf->chosenname == NULL)
+ sf->chosenname = chosenname;
+ return (sf);
+ }
+ fseek(f, here, SEEK_SET);
}
free(chosenname);
free(buffer);
- fseek(f,start,SEEK_SET);
-return( NULL );
+ fseek(f, start, SEEK_SET);
+ return (NULL);
}
typedef struct fond {
@@ -452,69 +475,70 @@ typedef struct fond {
int first, last;
int assoc_cnt;
struct assoc {
- short size, style, id;
+ short size, style, id;
} *assoc;
- /* size==0 => scalable */
- /* style>>8 is the bit depth (0=>1, 1=>2, 2=>4, 3=>8) */
- /* search order for ID is sfnt, NFNT, FONT */
+ /* size==0 => scalable */
+ /* style>>8 is the bit depth (0=>1, 1=>2, 2=>4, 3=>8) */
+ /* search order for ID is sfnt, NFNT, FONT */
int stylewidthcnt;
struct stylewidths {
- short style;
- short *widthtab; /* 4.12 fixed number with the width specified as a fraction of an em */
+ short style;
+ short *widthtab; /* 4.12 fixed number with the width specified as a fraction of an em */
} *stylewidths;
int stylekerncnt;
struct stylekerns {
- short style;
- int kernpairs;
- struct kerns {
- unsigned char ch1, ch2;
- short offset; /* 4.12 */
- } *kerns;
+ short style;
+ int kernpairs;
+ struct kerns {
+ unsigned char ch1, ch2;
+ short offset; /* 4.12 */
+ } *kerns;
} *stylekerns;
char *psnames[48];
struct fond *next;
} FOND;
struct MacFontRec {
- short fontType;
- short firstChar;
- short lastChar;
- short widthMax;
- short kernMax; /* bb learing */
- short Descent; /* maximum negative distance below baseline*/
- short fRectWidth; /* bounding box width */
- short fRectHeight; /* bounding box height */
- unsigned short *offsetWidths;/* offset to start of offset/width table */
- /* 0xffff => undefined, else high byte is offset in locTable, */
- /* low byte is width */
- short ascent;
- short descent;
- short leading;
- short rowWords; /* shorts per row */
- unsigned short *fontImage; /* rowWords*fRectHeight */
- /* Images for all characters plus one extra for undefined */
- unsigned short *locs; /* lastchar-firstchar+3 words */
- /* Horizontal offset to start of n'th character. Note: applies */
- /* to each row. Missing characters have same loc as following */
+ short fontType;
+ short firstChar;
+ short lastChar;
+ short widthMax;
+ short kernMax; /* bb learing */
+ short Descent; /* maximum negative distance below baseline */
+ short fRectWidth; /* bounding box width */
+ short fRectHeight; /* bounding box height */
+ unsigned short *offsetWidths; /* offset to start of offset/width table */
+ /* 0xffff => undefined, else high byte is offset in locTable, */
+ /* low byte is width */
+ short ascent;
+ short descent;
+ short leading;
+ short rowWords; /* shorts per row */
+ unsigned short *fontImage; /* rowWords*fRectHeight */
+ /* Images for all characters plus one extra for undefined */
+ unsigned short *locs; /* lastchar-firstchar+3 words */
+ /* Horizontal offset to start of n'th character. Note: applies */
+ /* to each row. Missing characters have same loc as following */
};
-static void FondListFree(FOND *list) {
+static void FondListFree(FOND * list)
+{
FOND *next;
int i;
- while ( list!=NULL ) {
- next = list->next;
- free(list->assoc);
- for ( i=0; i<list->stylewidthcnt; ++i )
- free(list->stylewidths[i].widthtab);
- free(list->stylewidths);
- for ( i=0; i<list->stylekerncnt; ++i )
- free(list->stylekerns[i].kerns);
- free(list->stylekerns);
- for ( i=0; i<48; ++i )
- free(list->psnames[i]);
- free(list);
- list = next;
+ while (list != NULL) {
+ next = list->next;
+ free(list->assoc);
+ for (i = 0; i < list->stylewidthcnt; ++i)
+ free(list->stylewidths[i].widthtab);
+ free(list->stylewidths);
+ for (i = 0; i < list->stylekerncnt; ++i)
+ free(list->stylekerns[i].kerns);
+ free(list->stylekerns);
+ for (i = 0; i < 48; ++i)
+ free(list->psnames[i]);
+ free(list);
+ list = next;
}
}
@@ -526,180 +550,190 @@ static void FondListFree(FOND *list) {
/* to get the font association tables */
/* to get the style flags */
/* http://developer.apple.com/techpubs/mac/Text/Text-269.html */
-static FOND *BuildFondList(FILE *f,long rlistpos,int subcnt,long rdata_pos,
- long name_list,int flags) {
+static FOND *BuildFondList(FILE * f, long rlistpos, int subcnt, long rdata_pos,
+ long name_list, int flags)
+{
long here, start = ftell(f);
long offset;
int rname = -1;
char name[300];
int ch1, ch2;
int i, j, k, cnt, isfixed;
- FOND *head=NULL, *cur;
+ FOND *head = NULL, *cur;
long widoff, kernoff, styleoff;
- fseek(f,rlistpos,SEEK_SET);
- for ( i=0; i<subcnt; ++i ) {
- /* resource id = */ getushort(f);
- rname = (short) getushort(f);
- /* flags = */ getc(f);
- ch1 = getc(f); ch2 = getc(f);
- offset = rdata_pos+((ch1<<16)|(ch2<<8)|getc(f));
- /* mbz = */ getlong(f);
- here = ftell(f);
-
- cur = gcalloc(1,sizeof(FOND));
- cur->next = head;
- head = cur;
-
- if ( rname!=-1 ) {
- fseek(f,name_list+rname,SEEK_SET);
- ch1 = getc(f);
- fread(name,1,ch1,f);
- name[ch1] = '\0';
- cur->fondname = copy(name);
- }
-
- offset += 4;
- fseek(f,offset,SEEK_SET);
- isfixed = getushort(f)&0x8000?1:0;
- /* family id = */ getushort(f);
- cur->first = getushort(f);
- cur->last = getushort(f);
+ fseek(f, rlistpos, SEEK_SET);
+ for (i = 0; i < subcnt; ++i) {
+ /* resource id = */ getushort(f);
+ rname = (short) getushort(f);
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ offset = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
+ here = ftell(f);
+
+ cur = gcalloc(1, sizeof(FOND));
+ cur->next = head;
+ head = cur;
+
+ if (rname != -1) {
+ fseek(f, name_list + rname, SEEK_SET);
+ ch1 = getc(f);
+ fread(name, 1, ch1, f);
+ name[ch1] = '\0';
+ cur->fondname = copy(name);
+ }
+
+ offset += 4;
+ fseek(f, offset, SEEK_SET);
+ isfixed = getushort(f) & 0x8000 ? 1 : 0;
+ /* family id = */ getushort(f);
+ cur->first = getushort(f);
+ cur->last = getushort(f);
/* on a 1 point font... */
- /* ascent = */ getushort(f);
- /* descent = (short) */ getushort(f);
- /* leading = */ getushort(f);
- /* widmax = */ getushort(f);
- if ( (widoff = getlong(f))!=0 ) widoff += offset;
- if ( (kernoff = getlong(f))!=0 ) kernoff += offset;
- if ( (styleoff = getlong(f))!=0 ) styleoff += offset;
- for ( j=0; j<9; ++j )
- getushort(f);
- /* internal & undefined, for international scripts = */ getlong(f);
- /* version = */ getushort(f);
- cur->assoc_cnt = getushort(f)+1;
- cur->assoc = gcalloc(cur->assoc_cnt,sizeof(struct assoc));
- for ( j=0; j<cur->assoc_cnt; ++j ) {
- cur->assoc[j].size = getushort(f);
- cur->assoc[j].style = getushort(f);
- cur->assoc[j].id = getushort(f);
- }
- if ( widoff!=0 ) {
- fseek(f,widoff,SEEK_SET);
- cnt = getushort(f)+1;
- cur->stylewidthcnt = cnt;
- cur->stylewidths = gcalloc(cnt,sizeof(struct stylewidths));
- for ( j=0; j<cnt; ++j ) {
- cur->stylewidths[j].style = getushort(f);
- cur->stylewidths[j].widthtab = galloc((cur->last-cur->first+3)*sizeof(short));
- for ( k=cur->first; k<=cur->last+2; ++k )
- cur->stylewidths[j].widthtab[k] = getushort(f);
- }
- }
- if ( kernoff!=0 && (flags&ttf_onlykerns) ) {
- fseek(f,kernoff,SEEK_SET);
- cnt = getushort(f)+1;
- cur->stylekerncnt = cnt;
- cur->stylekerns = gcalloc(cnt,sizeof(struct stylekerns));
- for ( j=0; j<cnt; ++j ) {
- cur->stylekerns[j].style = getushort(f);
- cur->stylekerns[j].kernpairs = getushort(f);
- cur->stylekerns[j].kerns = galloc(cur->stylekerns[j].kernpairs*sizeof(struct kerns));
- for ( k=0; k<cur->stylekerns[j].kernpairs; ++k ) {
- cur->stylekerns[j].kerns[k].ch1 = getc(f);
- cur->stylekerns[j].kerns[k].ch2 = getc(f);
- cur->stylekerns[j].kerns[k].offset = getushort(f);
- }
- }
- }
- if ( styleoff!=0 ) {
- uint8 stringoffsets[48];
- int strcnt, stringlen, format;
- char **strings, *pt;
- fseek(f,styleoff,SEEK_SET);
- /* class = */ getushort(f);
- /* glyph encoding offset = */ getlong(f);
- /* reserved = */ getlong(f);
- for ( j=0; j<48; ++j )
- stringoffsets[j] = getc(f);
- strcnt = getushort(f);
- strings = galloc(strcnt*sizeof(char *));
- for ( j=0; j<strcnt; ++j ) {
- stringlen = getc(f);
- strings[j] = galloc(stringlen+2);
- strings[j][0] = stringlen;
- strings[j][stringlen+1] = '\0';
- for ( k=0; k<stringlen; ++k )
- strings[j][k+1] = getc(f);
- }
- for ( j=0; j<48; ++j ) {
- for ( k=j-1; k>=0; --k )
- if ( stringoffsets[j]==stringoffsets[k] )
- break;
- if ( k!=-1 )
- continue; /* this style doesn't exist */
- format = stringoffsets[j]-1;
- stringlen = strings[0][0];
- if ( format!=0 )
- for ( k=0; k<strings[format][0]; ++k )
- stringlen += strings[ strings[format][k+1]-1 ][0];
- pt = cur->psnames[j] = galloc(stringlen+1);
- strcpy(pt,strings[ 0 ]+1);
- pt += strings[ 0 ][0];
- if ( format!=0 )
- for ( k=0; k<strings[format][0]; ++k ) {
- strcpy(pt,strings[ strings[format][k+1]-1 ]+1);
- pt += strings[ strings[format][k+1]-1 ][0];
- }
- *pt = '\0';
- }
- for ( j=0; j<strcnt; ++j )
- free(strings[j]);
- free(strings);
- }
- fseek(f,here,SEEK_SET);
+ /* ascent = */ getushort(f);
+ /* descent = (short) */ getushort(f);
+ /* leading = */ getushort(f);
+ /* widmax = */ getushort(f);
+ if ((widoff = getlong(f)) != 0)
+ widoff += offset;
+ if ((kernoff = getlong(f)) != 0)
+ kernoff += offset;
+ if ((styleoff = getlong(f)) != 0)
+ styleoff += offset;
+ for (j = 0; j < 9; ++j)
+ getushort(f);
+ /* internal & undefined, for international scripts = */ getlong(f);
+ /* version = */ getushort(f);
+ cur->assoc_cnt = getushort(f) + 1;
+ cur->assoc = gcalloc(cur->assoc_cnt, sizeof(struct assoc));
+ for (j = 0; j < cur->assoc_cnt; ++j) {
+ cur->assoc[j].size = getushort(f);
+ cur->assoc[j].style = getushort(f);
+ cur->assoc[j].id = getushort(f);
+ }
+ if (widoff != 0) {
+ fseek(f, widoff, SEEK_SET);
+ cnt = getushort(f) + 1;
+ cur->stylewidthcnt = cnt;
+ cur->stylewidths = gcalloc(cnt, sizeof(struct stylewidths));
+ for (j = 0; j < cnt; ++j) {
+ cur->stylewidths[j].style = getushort(f);
+ cur->stylewidths[j].widthtab =
+ galloc((cur->last - cur->first + 3) * sizeof(short));
+ for (k = cur->first; k <= cur->last + 2; ++k)
+ cur->stylewidths[j].widthtab[k] = getushort(f);
+ }
+ }
+ if (kernoff != 0 && (flags & ttf_onlykerns)) {
+ fseek(f, kernoff, SEEK_SET);
+ cnt = getushort(f) + 1;
+ cur->stylekerncnt = cnt;
+ cur->stylekerns = gcalloc(cnt, sizeof(struct stylekerns));
+ for (j = 0; j < cnt; ++j) {
+ cur->stylekerns[j].style = getushort(f);
+ cur->stylekerns[j].kernpairs = getushort(f);
+ cur->stylekerns[j].kerns =
+ galloc(cur->stylekerns[j].kernpairs * sizeof(struct kerns));
+ for (k = 0; k < cur->stylekerns[j].kernpairs; ++k) {
+ cur->stylekerns[j].kerns[k].ch1 = getc(f);
+ cur->stylekerns[j].kerns[k].ch2 = getc(f);
+ cur->stylekerns[j].kerns[k].offset = getushort(f);
+ }
+ }
+ }
+ if (styleoff != 0) {
+ uint8 stringoffsets[48];
+ int strcnt, stringlen, format;
+ char **strings, *pt;
+ fseek(f, styleoff, SEEK_SET);
+ /* class = */ getushort(f);
+ /* glyph encoding offset = */ getlong(f);
+ /* reserved = */ getlong(f);
+ for (j = 0; j < 48; ++j)
+ stringoffsets[j] = getc(f);
+ strcnt = getushort(f);
+ strings = galloc(strcnt * sizeof(char *));
+ for (j = 0; j < strcnt; ++j) {
+ stringlen = getc(f);
+ strings[j] = galloc(stringlen + 2);
+ strings[j][0] = stringlen;
+ strings[j][stringlen + 1] = '\0';
+ for (k = 0; k < stringlen; ++k)
+ strings[j][k + 1] = getc(f);
+ }
+ for (j = 0; j < 48; ++j) {
+ for (k = j - 1; k >= 0; --k)
+ if (stringoffsets[j] == stringoffsets[k])
+ break;
+ if (k != -1)
+ continue; /* this style doesn't exist */
+ format = stringoffsets[j] - 1;
+ stringlen = strings[0][0];
+ if (format != 0)
+ for (k = 0; k < strings[format][0]; ++k)
+ stringlen += strings[strings[format][k + 1] - 1][0];
+ pt = cur->psnames[j] = galloc(stringlen + 1);
+ strcpy(pt, strings[0] + 1);
+ pt += strings[0][0];
+ if (format != 0)
+ for (k = 0; k < strings[format][0]; ++k) {
+ strcpy(pt, strings[strings[format][k + 1] - 1] + 1);
+ pt += strings[strings[format][k + 1] - 1][0];
+ }
+ *pt = '\0';
+ }
+ for (j = 0; j < strcnt; ++j)
+ free(strings[j]);
+ free(strings);
+ }
+ fseek(f, here, SEEK_SET);
}
- fseek(f,start,SEEK_SET);
-return( head );
+ fseek(f, start, SEEK_SET);
+ return (head);
}
-static char *BuildName(char *family,int style) {
+static char *BuildName(char *family, int style)
+{
char buffer[350];
- strncpy(buffer,family,200);
- if ( style!=0 )
- strcat(buffer,"-");
- if ( style&sf_bold )
- strcat(buffer,"Bold");
- if ( style&sf_italic )
- strcat(buffer,"Italic");
- if ( style&sf_underline )
- strcat(buffer,"Underline");
- if ( style&sf_outline )
- strcat(buffer,"Outline");
- if ( style&sf_shadow )
- strcat(buffer,"Shadow");
- if ( style&sf_condense )
- strcat(buffer,"Condensed");
- if ( style&sf_extend )
- strcat(buffer,"Extended");
-return( copy(buffer));
+ strncpy(buffer, family, 200);
+ if (style != 0)
+ strcat(buffer, "-");
+ if (style & sf_bold)
+ strcat(buffer, "Bold");
+ if (style & sf_italic)
+ strcat(buffer, "Italic");
+ if (style & sf_underline)
+ strcat(buffer, "Underline");
+ if (style & sf_outline)
+ strcat(buffer, "Outline");
+ if (style & sf_shadow)
+ strcat(buffer, "Shadow");
+ if (style & sf_condense)
+ strcat(buffer, "Condensed");
+ if (style & sf_extend)
+ strcat(buffer, "Extended");
+ return (copy(buffer));
}
-static int GuessStyle(char *fontname,int *styles,int style_cnt) {
+static int GuessStyle(char *fontname, int *styles, int style_cnt)
+{
int which, style;
- char *stylenames = _GetModifiers(fontname,NULL,NULL);
+ char *stylenames = _GetModifiers(fontname, NULL, NULL);
- style = _MacStyleCode(stylenames,NULL,NULL);
- for ( which = style_cnt; which>=0; --which )
- if ( styles[which] == style )
-return( which );
+ style = _MacStyleCode(stylenames, NULL, NULL);
+ for (which = style_cnt; which >= 0; --which)
+ if (styles[which] == style)
+ return (which);
-return( -1 );
+ return (-1);
}
-static FOND *PickFOND(FOND *fondlist,char *filename,char **name, int *style) {
- int i,j;
+static FOND *PickFOND(FOND * fondlist, char *filename, char **name, int *style)
+{
+ int i, j;
FOND *test;
uint8 stylesused[96];
char **names;
@@ -709,163 +743,180 @@ static FOND *PickFOND(FOND *fondlist,char *filename,char **name, int *style) {
char *pt, *lparen;
char *find = NULL;
- if ((pt = strrchr(filename,'/'))!=NULL ) pt = filename;
- if ( (lparen = strchr(filename,'('))!=NULL && strchr(lparen,')')!=NULL ) {
- find = copy(lparen+1);
- pt = strchr(find,')');
- if ( pt!=NULL ) *pt='\0';
- for ( test=fondlist; test!=NULL; test=test->next ) {
- for ( i=0; i<48; ++i )
- if ( test->psnames[i]!=NULL && strcmp(find,test->psnames[i])==0 ) {
- *style = (i&3) | ((i&~3)<<1); /* PS styles skip underline bit */
- *name = copy(test->psnames[i]);
-return( test );
- }
- }
+ if ((pt = strrchr(filename, '/')) != NULL)
+ pt = filename;
+ if ((lparen = strchr(filename, '(')) != NULL && strchr(lparen, ')') != NULL) {
+ find = copy(lparen + 1);
+ pt = strchr(find, ')');
+ if (pt != NULL)
+ *pt = '\0';
+ for (test = fondlist; test != NULL; test = test->next) {
+ for (i = 0; i < 48; ++i)
+ if (test->psnames[i] != NULL
+ && strcmp(find, test->psnames[i]) == 0) {
+ *style = (i & 3) | ((i & ~3) << 1); /* PS styles skip underline bit */
+ *name = copy(test->psnames[i]);
+ return (test);
+ }
+ }
}
/* The file may contain multiple families, and each family may contain */
/* multiple styles (and each style may contain multiple sizes, but that's */
/* not an issue for us here) */
names = NULL;
- for ( i=0; i<2; ++i ) {
- cnt = 0;
- for ( test=fondlist; test!=NULL; test=test->next ) if ( test->fondname!=NULL ) {
- memset(stylesused,0,sizeof(stylesused));
- for ( j=0; j<test->assoc_cnt; ++j ) {
- if ( test->assoc[j].size!=0 && !stylesused[test->assoc[j].style]) {
- stylesused[test->assoc[j].style]=true;
- if ( names!=NULL ) {
- names[cnt] = BuildName(test->fondname,test->assoc[j].style);
- styles[cnt] = test->assoc[j].style;
- fonds[cnt] = test;
- }
- ++cnt;
- }
- }
- }
- if ( names==NULL ) {
- names = gcalloc(cnt+1,sizeof(char *));
- fonds = galloc(cnt*sizeof(FOND *));
- styles = galloc(cnt*sizeof(int));
- }
+ for (i = 0; i < 2; ++i) {
+ cnt = 0;
+ for (test = fondlist; test != NULL; test = test->next)
+ if (test->fondname != NULL) {
+ memset(stylesused, 0, sizeof(stylesused));
+ for (j = 0; j < test->assoc_cnt; ++j) {
+ if (test->assoc[j].size != 0
+ && !stylesused[test->assoc[j].style]) {
+ stylesused[test->assoc[j].style] = true;
+ if (names != NULL) {
+ names[cnt] =
+ BuildName(test->fondname, test->assoc[j].style);
+ styles[cnt] = test->assoc[j].style;
+ fonds[cnt] = test;
+ }
+ ++cnt;
+ }
+ }
+ }
+ if (names == NULL) {
+ names = gcalloc(cnt + 1, sizeof(char *));
+ fonds = galloc(cnt * sizeof(FOND *));
+ styles = galloc(cnt * sizeof(int));
+ }
}
- if ( find!=NULL ) {
- for ( which=cnt-1; which>=0; --which )
- if ( strcmp(names[which],find)==0 )
- break;
- if ( which==-1 && strstrmatch(find,test->fondname)!=NULL )
- which = GuessStyle(find,styles,cnt);
- if ( which==-1 ) {
- char *fn = copy(filename);
- fn[lparen-filename] = '\0';
- ff_post_error(_("Not in Collection"),_("%s is not in %.100s"),find,fn);
- free(fn);
- }
- free(find);
- } else
- which = 0;
-
- if ( which!=-1 ) {
- fond = fonds[which];
- *name = copy(names[which]);
- *style = styles[which];
+ if (find != NULL) {
+ for (which = cnt - 1; which >= 0; --which)
+ if (strcmp(names[which], find) == 0)
+ break;
+ if (which == -1 && strstrmatch(find, test->fondname) != NULL)
+ which = GuessStyle(find, styles, cnt);
+ if (which == -1) {
+ char *fn = copy(filename);
+ fn[lparen - filename] = '\0';
+ ff_post_error(_("Not in Collection"), _("%s is not in %.100s"),
+ find, fn);
+ free(fn);
+ }
+ free(find);
+ } else
+ which = 0;
+
+ if (which != -1) {
+ fond = fonds[which];
+ *name = copy(names[which]);
+ *style = styles[which];
}
- for ( i=0; i<cnt; ++i )
- free(names[i]);
- free(names); free(fonds); free(styles);
- if ( which==-1 )
-return( NULL );
-
-return( fond );
+ for (i = 0; i < cnt; ++i)
+ free(names[i]);
+ free(names);
+ free(fonds);
+ free(styles);
+ if (which == -1)
+ return (NULL);
+
+ return (fond);
}
/* Look for kerning info and merge it into the currently existing font "into" */
-static SplineFont *FindFamilyStyleKerns(SplineFont *into,EncMap *map,FOND *fondlist,char *filename) {
+static SplineFont *FindFamilyStyleKerns(SplineFont * into, EncMap * map,
+ FOND * fondlist, char *filename)
+{
char *name;
int style;
FOND *fond;
- int i,j;
+ int i, j;
int ch1, ch2, offset;
KernPair *kp;
SplineChar *sc1, *sc2;
- fond = PickFOND(fondlist,filename,&name,&style);
- if ( fond==NULL || into==NULL )
-return( NULL );
- for ( i=0; i<fond->stylekerncnt; ++i )
- if ( fond->stylekerns[i].style==style )
- break;
- if ( i==fond->stylekerncnt ) {
- LogError(_("No kerning table for %s\n"), name );
- free(name);
-return( NULL );
+ fond = PickFOND(fondlist, filename, &name, &style);
+ if (fond == NULL || into == NULL)
+ return (NULL);
+ for (i = 0; i < fond->stylekerncnt; ++i)
+ if (fond->stylekerns[i].style == style)
+ break;
+ if (i == fond->stylekerncnt) {
+ LogError(_("No kerning table for %s\n"), name);
+ free(name);
+ return (NULL);
}
- for ( j=0; j<fond->stylekerns[i].kernpairs; ++j ) {
- ch1 = fond->stylekerns[i].kerns[j].ch1;
- ch2 = fond->stylekerns[i].kerns[j].ch2;
- offset = (fond->stylekerns[i].kerns[j].offset*(into->ascent+into->descent)+(1<<11))>>12;
- sc1 = SFMakeChar(into,map,ch1);
- sc2 = SFMakeChar(into,map,ch2);
- for ( kp=sc1->kerns; kp!=NULL; kp=kp->next )
- if ( kp->sc==sc2 )
- break;
- if ( kp==NULL ) {
- uint32 script;
- kp = chunkalloc(sizeof(KernPair));
- kp->sc = sc2;
- kp->next = sc1->kerns;
- sc1->kerns = kp;
- script = SCScriptFromUnicode(sc1);
- if ( script==DEFAULT_SCRIPT )
- script = SCScriptFromUnicode(sc2);
- kp->subtable = SFSubTableFindOrMake(sc1->parent,CHR('k','e','r','n'),
- script, gpos_pair);
- }
- kp->off = offset;
+ for (j = 0; j < fond->stylekerns[i].kernpairs; ++j) {
+ ch1 = fond->stylekerns[i].kerns[j].ch1;
+ ch2 = fond->stylekerns[i].kerns[j].ch2;
+ offset =
+ (fond->stylekerns[i].kerns[j].offset *
+ (into->ascent + into->descent) + (1 << 11)) >> 12;
+ sc1 = SFMakeChar(into, map, ch1);
+ sc2 = SFMakeChar(into, map, ch2);
+ for (kp = sc1->kerns; kp != NULL; kp = kp->next)
+ if (kp->sc == sc2)
+ break;
+ if (kp == NULL) {
+ uint32 script;
+ kp = chunkalloc(sizeof(KernPair));
+ kp->sc = sc2;
+ kp->next = sc1->kerns;
+ sc1->kerns = kp;
+ script = SCScriptFromUnicode(sc1);
+ if (script == DEFAULT_SCRIPT)
+ script = SCScriptFromUnicode(sc2);
+ kp->subtable =
+ SFSubTableFindOrMake(sc1->parent, CHR('k', 'e', 'r', 'n'),
+ script, gpos_pair);
+ }
+ kp->off = offset;
}
-return( into );
+ return (into);
}
/* Look for a bare truetype font in a binhex/macbinary wrapper */
-static SplineFont *MightBeTrueType(FILE *binary,int32 pos,int32 dlen,int flags,
- enum openflags openflags) {
+static SplineFont *MightBeTrueType(FILE * binary, int32 pos, int32 dlen,
+ int flags, enum openflags openflags)
+{
FILE *temp = tmpfile();
char *buffer = galloc(8192);
int len;
SplineFont *sf;
- if ( flags&ttf_onlynames ) {
- char **ret;
- char *temp = TTFGetFontName(binary,pos,pos);
- if ( temp==NULL )
-return( NULL );
- ret = galloc(2*sizeof(char *));
- ret[0] = temp;
- ret[1] = NULL;
-return( (SplineFont *) ret );
+ if (flags & ttf_onlynames) {
+ char **ret;
+ char *temp = TTFGetFontName(binary, pos, pos);
+ if (temp == NULL)
+ return (NULL);
+ ret = galloc(2 * sizeof(char *));
+ ret[0] = temp;
+ ret[1] = NULL;
+ return ((SplineFont *) ret);
}
- fseek(binary,pos,SEEK_SET);
- while ( dlen>0 ) {
- len = dlen > 8192 ? 8192 : dlen;
- len = fread(buffer,1,dlen > 8192 ? 8192 : dlen,binary);
- if ( len==0 )
- break;
- fwrite(buffer,1,len,temp);
- dlen -= len;
+ fseek(binary, pos, SEEK_SET);
+ while (dlen > 0) {
+ len = dlen > 8192 ? 8192 : dlen;
+ len = fread(buffer, 1, dlen > 8192 ? 8192 : dlen, binary);
+ if (len == 0)
+ break;
+ fwrite(buffer, 1, len, temp);
+ dlen -= len;
}
rewind(temp);
- sf = _SFReadTTF(temp,flags,openflags,NULL,NULL);
+ sf = _SFReadTTF(temp, flags, openflags, NULL, NULL);
fclose(temp);
free(buffer);
-return( sf );
+ return (sf);
}
-static SplineFont *IsResourceFork(FILE *f, long offset,char *filename,int flags,
- enum openflags openflags, SplineFont *into,EncMap *map) {
+static SplineFont *IsResourceFork(FILE * f, long offset, char *filename,
+ int flags, enum openflags openflags,
+ SplineFont * into, EncMap * map)
+{
/* If it is a good resource fork then the first 16 bytes are repeated */
/* at the location specified in bytes 4-7 */
/* We include an offset because if we are looking at a mac binary file */
@@ -876,326 +927,599 @@ static SplineFont *IsResourceFork(FILE *f, long offset,char *filename,int flags,
int32 rdata_len, map_len;
uint32 nfnt_pos, font_pos, fond_pos;
unsigned long tag;
- int i, cnt, subcnt, nfnt_subcnt=0, font_subcnt=0, fond_subcnt=0;
+ int i, cnt, subcnt, nfnt_subcnt = 0, font_subcnt = 0, fond_subcnt = 0;
SplineFont *sf;
- FOND *fondlist=NULL;
- fond_pos=0;
- fseek(f,offset,SEEK_SET);
- if ( fread(buffer,1,16,f)!=16 )
-return( NULL );
- rdata_pos = offset + ((buffer[0]<<24)|(buffer[1]<<16)|(buffer[2]<<8)|buffer[3]);
- map_pos = offset + ((buffer[4]<<24)|(buffer[5]<<16)|(buffer[6]<<8)|buffer[7]);
- rdata_len = ((buffer[8]<<24)|(buffer[9]<<16)|(buffer[10]<<8)|buffer[11]);
- map_len = ((buffer[12]<<24)|(buffer[13]<<16)|(buffer[14]<<8)|buffer[15]);
- if ( rdata_pos+rdata_len!=map_pos || rdata_len==0 )
-return( NULL );
- fseek(f,map_pos,SEEK_SET);
- buffer2[15] = buffer[15]+1; /* make it be different */
- if ( fread(buffer2,1,16,f)!=16 )
-return( NULL );
+ FOND *fondlist = NULL;
+ fond_pos = 0;
+ fseek(f, offset, SEEK_SET);
+ if (fread(buffer, 1, 16, f) != 16)
+ return (NULL);
+ rdata_pos =
+ offset +
+ ((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]);
+ map_pos =
+ offset +
+ ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]);
+ rdata_len =
+ ((buffer[8] << 24) | (buffer[9] << 16) | (buffer[10] << 8) |
+ buffer[11]);
+ map_len =
+ ((buffer[12] << 24) | (buffer[13] << 16) | (buffer[14] << 8) |
+ buffer[15]);
+ if (rdata_pos + rdata_len != map_pos || rdata_len == 0)
+ return (NULL);
+ fseek(f, map_pos, SEEK_SET);
+ buffer2[15] = buffer[15] + 1; /* make it be different */
+ if (fread(buffer2, 1, 16, f) != 16)
+ return (NULL);
/* Apple's data fork resources appear to have a bunch of zeroes here instead */
/* of a copy of the first 16 bytes */
- for ( i=0; i<16; ++i )
- if ( buffer2[i]!=0 )
- break;
- if ( i!=16 ) {
- for ( i=0; i<16; ++i )
- if ( buffer[i]!=buffer2[i] )
-return( NULL );
+ for (i = 0; i < 16; ++i)
+ if (buffer2[i] != 0)
+ break;
+ if (i != 16) {
+ for (i = 0; i < 16; ++i)
+ if (buffer[i] != buffer2[i])
+ return (NULL);
}
- getlong(f); /* skip the handle to the next resource map */
- getushort(f); /* skip the file resource number */
- getushort(f); /* skip the attributes */
+ getlong(f); /* skip the handle to the next resource map */
+ getushort(f); /* skip the file resource number */
+ getushort(f); /* skip the attributes */
type_list = map_pos + getushort(f);
name_list = map_pos + getushort(f);
- fseek(f,type_list,SEEK_SET);
- cnt = getushort(f)+1;
- for ( i=0; i<cnt; ++i ) {
- tag = getlong(f);
- /* printf( "%c%c%c%c\n", tag>>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff );*/
- subcnt = getushort(f)+1;
- rpos = type_list+getushort(f);
- sf = NULL;
- if ( tag==CHR('P','O','S','T') && !(flags&(ttf_onlystrikes|ttf_onlykerns))) /* No FOND */
- sf = SearchPostscriptResources(f,rpos,subcnt,rdata_pos,name_list,flags);
- else if ( tag==CHR('s','f','n','t') && !(flags&ttf_onlykerns))
- sf = SearchTtfResources(f,rpos,subcnt,rdata_pos,name_list,filename,flags,openflags);
- else if ( tag==CHR('N','F','N','T') ) {
- nfnt_pos = rpos;
- nfnt_subcnt = subcnt;
- } else if ( tag==CHR('F','O','N','T') ) {
- font_pos = rpos;
- font_subcnt = subcnt;
- } else if ( tag==CHR('F','O','N','D') ) {
- fond_pos = rpos;
- fond_subcnt = subcnt;
- }
- if ( sf!=NULL )
-return( sf );
+ fseek(f, type_list, SEEK_SET);
+ cnt = getushort(f) + 1;
+ for (i = 0; i < cnt; ++i) {
+ tag = getlong(f);
+ /* printf( "%c%c%c%c\n", tag>>24, (tag>>16)&0xff, (tag>>8)&0xff, tag&0xff ); */
+ subcnt = getushort(f) + 1;
+ rpos = type_list + getushort(f);
+ sf = NULL;
+ if (tag == CHR('P', 'O', 'S', 'T') && !(flags & (ttf_onlystrikes | ttf_onlykerns))) /* No FOND */
+ sf = SearchPostscriptResources(f, rpos, subcnt, rdata_pos,
+ name_list, flags);
+ else if (tag == CHR('s', 'f', 'n', 't') && !(flags & ttf_onlykerns))
+ sf = SearchTtfResources(f, rpos, subcnt, rdata_pos, name_list,
+ filename, flags, openflags);
+ else if (tag == CHR('N', 'F', 'N', 'T')) {
+ nfnt_pos = rpos;
+ nfnt_subcnt = subcnt;
+ } else if (tag == CHR('F', 'O', 'N', 'T')) {
+ font_pos = rpos;
+ font_subcnt = subcnt;
+ } else if (tag == CHR('F', 'O', 'N', 'D')) {
+ fond_pos = rpos;
+ fond_subcnt = subcnt;
+ }
+ if (sf != NULL)
+ return (sf);
}
- if ( flags&ttf_onlynames ) /* Not interested in bitmap resources here */
-return( NULL );
-
- if ( flags&ttf_onlykerns ) { /* For kerns */
- if ( fond_subcnt!=0 )
- fondlist = BuildFondList(f,fond_pos,fond_subcnt,rdata_pos,name_list,flags);
- into = FindFamilyStyleKerns(into,map,fondlist,filename);
- FondListFree(fondlist);
-return( into );
+ if (flags & ttf_onlynames) /* Not interested in bitmap resources here */
+ return (NULL);
+
+ if (flags & ttf_onlykerns) { /* For kerns */
+ if (fond_subcnt != 0)
+ fondlist =
+ BuildFondList(f, fond_pos, fond_subcnt, rdata_pos, name_list,
+ flags);
+ into = FindFamilyStyleKerns(into, map, fondlist, filename);
+ FondListFree(fondlist);
+ return (into);
}
/* Ok. If no outline font, try for a bitmap */
- if ( nfnt_subcnt==0 ) {
- nfnt_pos = font_pos;
- nfnt_subcnt = font_subcnt;
+ if (nfnt_subcnt == 0) {
+ nfnt_pos = font_pos;
+ nfnt_subcnt = font_subcnt;
}
-return( (SplineFont *) -1 ); /* It's a valid resource file, but just has no fonts */
+ return ((SplineFont *) - 1); /* It's a valid resource file, but just has no fonts */
}
-static SplineFont *IsResourceInBinary(FILE *f,char *filename,int flags,
- enum openflags openflags, SplineFont *into,EncMap *map) {
+static SplineFont *IsResourceInBinary(FILE * f, char *filename, int flags,
+ enum openflags openflags,
+ SplineFont * into, EncMap * map)
+{
unsigned char header[128];
unsigned long offset, dlen, rlen;
- if ( fread(header,1,128,f)!=128 )
-return( NULL );
- if ( header[0]!=0 || header[74]!=0 || header[82]!=0 || header[1]<=0 ||
- header[1]>33 || header[63]!=0 || header[2+header[1]]!=0 )
-return( NULL );
- dlen = ((header[0x53]<<24)|(header[0x54]<<16)|(header[0x55]<<8)|header[0x56]);
- rlen = ((header[0x57]<<24)|(header[0x58]<<16)|(header[0x59]<<8)|header[0x5a]);
- /* 128 bytes for header, then the dlen is padded to a 128 byte boundary */
- offset = 128 + ((dlen+127)&~127);
+ if (fread(header, 1, 128, f) != 128)
+ return (NULL);
+ if (header[0] != 0 || header[74] != 0 || header[82] != 0 || header[1] <= 0
+ || header[1] > 33 || header[63] != 0 || header[2 + header[1]] != 0)
+ return (NULL);
+ dlen =
+ ((header[0x53] << 24) | (header[0x54] << 16) | (header[0x55] << 8) |
+ header[0x56]);
+ rlen =
+ ((header[0x57] << 24) | (header[0x58] << 16) | (header[0x59] << 8) |
+ header[0x5a]);
+ /* 128 bytes for header, then the dlen is padded to a 128 byte boundary */
+ offset = 128 + ((dlen + 127) & ~127);
/* Look for a bare truetype font in a binhex/macbinary wrapper */
- if ( dlen!=0 && rlen<=dlen) {
- int pos = ftell(f);
- fread(header,1,4,f);
- header[5] = '\0';
- if ( strcmp((char *) header,"OTTO")==0 || strcmp((char *) header,"true")==0 ||
- strcmp((char *) header,"ttcf")==0 ||
- (header[0]==0 && header[1]==1 && header[2]==0 && header[3]==0))
-return( MightBeTrueType(f,pos,dlen,flags,openflags));
+ if (dlen != 0 && rlen <= dlen) {
+ int pos = ftell(f);
+ fread(header, 1, 4, f);
+ header[5] = '\0';
+ if (strcmp((char *) header, "OTTO") == 0
+ || strcmp((char *) header, "true") == 0
+ || strcmp((char *) header, "ttcf") == 0 || (header[0] == 0
+ && header[1] == 1
+ && header[2] == 0
+ && header[3] == 0))
+ return (MightBeTrueType(f, pos, dlen, flags, openflags));
}
-return( IsResourceFork(f,offset,filename,flags,openflags,into,map));
+ return (IsResourceFork(f, offset, filename, flags, openflags, into, map));
}
-static int lastch=0, repeat = 0;
-static void outchr(FILE *binary, int ch) {
+static int lastch = 0, repeat = 0;
+static void outchr(FILE * binary, int ch)
+{
int i;
- if ( repeat ) {
- if ( ch==0 ) {
- /* no repeat, output a literal 0x90 (the repeat flag) */
- lastch=0x90;
- putc(lastch,binary);
- } else {
- for ( i=1; i<ch; ++i )
- putc(lastch,binary);
- }
- repeat = 0;
- } else if ( ch==0x90 ) {
- repeat = 1;
+ if (repeat) {
+ if (ch == 0) {
+ /* no repeat, output a literal 0x90 (the repeat flag) */
+ lastch = 0x90;
+ putc(lastch, binary);
+ } else {
+ for (i = 1; i < ch; ++i)
+ putc(lastch, binary);
+ }
+ repeat = 0;
+ } else if (ch == 0x90) {
+ repeat = 1;
} else {
- putc(ch,binary);
- lastch = ch;
+ putc(ch, binary);
+ lastch = ch;
}
}
-static SplineFont *IsResourceInHex(FILE *f,char *filename,int flags,enum openflags openflags,
- SplineFont *into,EncMap *map) {
+static SplineFont *IsResourceInHex(FILE * f, char *filename, int flags,
+ enum openflags openflags, SplineFont * into,
+ EncMap * map)
+{
/* convert file from 6bit to 8bit */
/* interesting data is enclosed between two colons */
FILE *binary = tmpfile();
- char *sixbit = "!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
+ char *sixbit =
+ "!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
int ch, val, cnt, i, dlen, rlen;
- unsigned char header[20]; char *pt;
+ unsigned char header[20];
+ char *pt;
SplineFont *ret;
- if ( binary==NULL ) {
- LogError( _("can't create temporary file\n") );
-return( NULL );
+ if (binary == NULL) {
+ LogError(_("can't create temporary file\n"));
+ return (NULL);
}
lastch = repeat = 0;
- while ( (ch=getc(f))!=':' ); /* There may be comments before file start */
+ while ((ch = getc(f)) != ':'); /* There may be comments before file start */
cnt = val = 0;
- while ( (ch=getc(f))!=':' ) {
- if ( isspace(ch))
- continue;
- for ( pt=sixbit; *pt!=ch && *pt!='\0'; ++pt );
- if ( *pt=='\0' ) {
- fclose(binary);
-return( NULL );
- }
- val = (val<<6) | (pt-sixbit);
- if ( ++cnt==4 ) {
- outchr(binary,(val>>16)&0xff);
- outchr(binary,(val>>8)&0xff);
- outchr(binary,val&0xff);
- val = cnt = 0;
- }
+ while ((ch = getc(f)) != ':') {
+ if (isspace(ch))
+ continue;
+ for (pt = sixbit; *pt != ch && *pt != '\0'; ++pt);
+ if (*pt == '\0') {
+ fclose(binary);
+ return (NULL);
+ }
+ val = (val << 6) | (pt - sixbit);
+ if (++cnt == 4) {
+ outchr(binary, (val >> 16) & 0xff);
+ outchr(binary, (val >> 8) & 0xff);
+ outchr(binary, val & 0xff);
+ val = cnt = 0;
+ }
}
- if ( cnt!=0 ) {
- if ( cnt==1 )
- outchr(binary,val<<2);
- else if ( cnt==2 ) {
- val<<=4;
- outchr(binary,(val>>8)&0xff);
- outchr(binary,val&0xff);
- } else if ( cnt==3 ) {
- val<<=6;
- outchr(binary,(val>>16)&0xff);
- outchr(binary,(val>>8)&0xff);
- outchr(binary,val&0xff);
- }
+ if (cnt != 0) {
+ if (cnt == 1)
+ outchr(binary, val << 2);
+ else if (cnt == 2) {
+ val <<= 4;
+ outchr(binary, (val >> 8) & 0xff);
+ outchr(binary, val & 0xff);
+ } else if (cnt == 3) {
+ val <<= 6;
+ outchr(binary, (val >> 16) & 0xff);
+ outchr(binary, (val >> 8) & 0xff);
+ outchr(binary, val & 0xff);
+ }
}
rewind(binary);
- ch = getc(binary); /* Name length */
+ ch = getc(binary); /* Name length */
/* skip name */
- for ( i=0; i<ch; ++i )
- getc(binary);
- if ( getc(binary)!='\0' ) {
- fclose(binary);
-return( NULL );
+ for (i = 0; i < ch; ++i)
+ getc(binary);
+ if (getc(binary) != '\0') {
+ fclose(binary);
+ return (NULL);
}
- fread(header,1,20,binary);
- dlen = (header[10]<<24)|(header[11]<<16)|(header[12]<<8)|header[13];
- rlen = (header[14]<<24)|(header[15]<<16)|(header[16]<<8)|header[17];
+ fread(header, 1, 20, binary);
+ dlen =
+ (header[10] << 24) | (header[11] << 16) | (header[12] << 8) |
+ header[13];
+ rlen =
+ (header[14] << 24) | (header[15] << 16) | (header[16] << 8) |
+ header[17];
/* Look for a bare truetype font in a binhex/macbinary wrapper */
- if ( dlen!=0 && rlen<dlen ) {
- int pos = ftell(binary);
- fread(header,1,4,binary);
- header[5] = '\0';
- if ( strcmp((char *) header,"OTTO")==0 || strcmp((char *) header,"true")==0 ||
- strcmp((char *) header,"ttcf")==0 ||
- (header[0]==0 && header[1]==1 && header[2]==0 && header[3]==0)) {
- ret = MightBeTrueType(binary,pos,dlen,flags,openflags);
- fclose(binary);
-return( ret );
- }
+ if (dlen != 0 && rlen < dlen) {
+ int pos = ftell(binary);
+ fread(header, 1, 4, binary);
+ header[5] = '\0';
+ if (strcmp((char *) header, "OTTO") == 0
+ || strcmp((char *) header, "true") == 0
+ || strcmp((char *) header, "ttcf") == 0 || (header[0] == 0
+ && header[1] == 1
+ && header[2] == 0
+ && header[3] == 0)) {
+ ret = MightBeTrueType(binary, pos, dlen, flags, openflags);
+ fclose(binary);
+ return (ret);
+ }
}
- if ( rlen==0 ) {
- fclose(binary);
-return( NULL );
+ if (rlen == 0) {
+ fclose(binary);
+ return (NULL);
}
- ret = IsResourceFork(binary,ftell(binary)+dlen+2,filename,flags,openflags,into,map);
+ ret =
+ IsResourceFork(binary, ftell(binary) + dlen + 2, filename, flags,
+ openflags, into, map);
fclose(binary);
-return( ret );
+ return (ret);
}
-static SplineFont *IsResourceInFile(char *filename,int flags,enum openflags openflags,
- SplineFont *into, EncMap *map) {
+static SplineFont *IsResourceInFile(char *filename, int flags,
+ enum openflags openflags, SplineFont * into,
+ EncMap * map)
+{
FILE *f;
char *spt, *pt;
SplineFont *sf;
- char *temp=filename, *lparen;
+ char *temp = filename, *lparen;
- if (( pt=strrchr(filename,'/'))==NULL ) pt = filename;
- if ( (lparen = strchr(pt,'('))!=NULL && strchr(lparen,')')!=NULL ) {
- temp = copy(filename);
- temp[lparen-filename] = '\0';
+ if ((pt = strrchr(filename, '/')) == NULL)
+ pt = filename;
+ if ((lparen = strchr(pt, '(')) != NULL && strchr(lparen, ')') != NULL) {
+ temp = copy(filename);
+ temp[lparen - filename] = '\0';
}
- f = fopen(temp,"rb");
- if ( temp!=filename ) free(temp);
- if ( f==NULL )
-return( NULL );
- spt = strrchr(filename,'/');
- if ( spt==NULL ) spt = filename;
- pt = strrchr(spt,'.');
- if ( pt!=NULL && (pt[1]=='b' || pt[1]=='B') && (pt[2]=='i' || pt[2]=='I') &&
- (pt[3]=='n' || pt[3]=='N') && (pt[4]=='\0' || pt[4]=='(') ) {
- if ( (sf = IsResourceInBinary(f,filename,flags,openflags,into,map))) {
- fclose(f);
-return( sf );
- }
- } else if ( pt!=NULL && (pt[1]=='h' || pt[1]=='H') && (pt[2]=='q' || pt[2]=='Q') &&
- (pt[3]=='x' || pt[3]=='X') && (pt[4]=='\0' || pt[4]=='(')) {
- if ( (sf = IsResourceInHex(f,filename,flags,openflags,into,map))) {
- fclose(f);
-return( sf );
- }
+ f = fopen(temp, "rb");
+ if (temp != filename)
+ free(temp);
+ if (f == NULL)
+ return (NULL);
+ spt = strrchr(filename, '/');
+ if (spt == NULL)
+ spt = filename;
+ pt = strrchr(spt, '.');
+ if (pt != NULL && (pt[1] == 'b' || pt[1] == 'B')
+ && (pt[2] == 'i' || pt[2] == 'I') && (pt[3] == 'n' || pt[3] == 'N')
+ && (pt[4] == '\0' || pt[4] == '(')) {
+ if ((sf = IsResourceInBinary(f, filename, flags, openflags, into, map))) {
+ fclose(f);
+ return (sf);
+ }
+ } else if (pt != NULL && (pt[1] == 'h' || pt[1] == 'H')
+ && (pt[2] == 'q' || pt[2] == 'Q') && (pt[3] == 'x'
+ || pt[3] == 'X')
+ && (pt[4] == '\0' || pt[4] == '(')) {
+ if ((sf = IsResourceInHex(f, filename, flags, openflags, into, map))) {
+ fclose(f);
+ return (sf);
+ }
}
- sf = IsResourceFork(f,0,filename,flags,openflags,into,map);
+ sf = IsResourceFork(f, 0, filename, flags, openflags, into, map);
fclose(f);
#if __Mac
- if ( sf==NULL )
- sf = HasResourceFork(filename,flags,openflags,into,map);
+ if (sf == NULL)
+ sf = HasResourceFork(filename, flags, openflags, into, map);
#endif
-return( sf );
+ return (sf);
}
-static SplineFont *FindResourceFile(char *filename,int flags,enum openflags openflags,
- SplineFont *into,EncMap *map) {
+static SplineFont *FindResourceFile(char *filename, int flags,
+ enum openflags openflags, SplineFont * into,
+ EncMap * map)
+{
char *spt, *pt, *dpt;
char buffer[1400];
SplineFont *sf;
- if ( (sf = IsResourceInFile(filename,flags,openflags,into,map)))
-return( sf );
+ if ((sf = IsResourceInFile(filename, flags, openflags, into, map)))
+ return (sf);
/* Well, look in the resource fork directory (if it exists), the resource */
/* fork is placed there in a seperate file on (some) non-Mac disks */
- strcpy(buffer,filename);
- spt = strrchr(buffer,'/');
- if ( spt==NULL ) { spt = buffer; pt = filename; }
- else { ++spt; pt = filename + (spt-buffer); }
- strcpy(spt,"resource.frk/");
- strcat(spt,pt);
- if ( (sf=IsResourceInFile(buffer,flags,openflags,into,map)))
-return( sf );
+ strcpy(buffer, filename);
+ spt = strrchr(buffer, '/');
+ if (spt == NULL) {
+ spt = buffer;
+ pt = filename;
+ } else {
+ ++spt;
+ pt = filename + (spt - buffer);
+ }
+ strcpy(spt, "resource.frk/");
+ strcat(spt, pt);
+ if ((sf = IsResourceInFile(buffer, flags, openflags, into, map)))
+ return (sf);
/* however the resource fork does not appear to do long names properly */
/* names are always lower case 8.3, do some simple things to check */
- spt = strrchr(buffer,'/')+1;
- for ( pt=spt; *pt; ++pt )
- if ( isupper( *pt ))
- *pt = tolower( *pt );
- dpt = strchr(spt,'.');
- if ( dpt==NULL ) dpt = spt+strlen(spt);
- if ( dpt-spt>8 || strlen(dpt)>4 ) {
- char exten[8];
- strncpy(exten,dpt,7);
- exten[4] = '\0'; /* it includes the dot */
- if ( dpt-spt>6 )
- dpt = spt+6;
- *dpt++ = '~';
- *dpt++ = '1';
- strcpy(dpt,exten);
+ spt = strrchr(buffer, '/') + 1;
+ for (pt = spt; *pt; ++pt)
+ if (isupper(*pt))
+ *pt = tolower(*pt);
+ dpt = strchr(spt, '.');
+ if (dpt == NULL)
+ dpt = spt + strlen(spt);
+ if (dpt - spt > 8 || strlen(dpt) > 4) {
+ char exten[8];
+ strncpy(exten, dpt, 7);
+ exten[4] = '\0'; /* it includes the dot */
+ if (dpt - spt > 6)
+ dpt = spt + 6;
+ *dpt++ = '~';
+ *dpt++ = '1';
+ strcpy(dpt, exten);
+ }
+ return (IsResourceInFile(buffer, flags, openflags, into, map));
+}
+
+
+static char *createtmpfile(char *filename)
+{
+ char *p, *tempname;
+ p = strrchr(filename,'/');
+ if (p != NULL) {
+ filename = p+1;
+ }
+ assert(strlen(filename)>=5);
+ tempname = malloc(strlen(filename)+2);
+ if (tempname == NULL) {
+ LogError(_("Out of memory\n"));
+ exit(1);
+ }
+ strcpy(tempname,filename);
+ strcpy(tempname+strlen(tempname)-5,"XXXXXX"); /* dfont -> XXXXXX */
+
+#ifdef HAVE_MKSTEMP
+ int i = mkstemp(tempname);
+ if (i) {
+ close(i);
}
-return( IsResourceInFile(buffer,flags,openflags,into,map));
+#else
+ mktemp(tempname);
+#endif
+ return tempname;
}
-SplineFont *SFReadMacBinary(char *filename,int flags,enum openflags openflags) {
- SplineFont *sf = FindResourceFile(filename,flags,openflags,NULL,NULL);
+static char *SearchTtfResourcesFile(FILE * f, long rlistpos, int subcnt,
+ long rdata_pos, long name_list,
+ char *filename, char *fontname)
+{
+ long here;
+ long roff;
+ int rname = -1;
+ int ch1, ch2;
+ int len, i, rlen, ilen;
+ /* The sfnt resource is just a copy of the ttf file */
+ char *buffer = NULL;
+ int max = 0;
+ FILE *ttf;
+ char *sf = NULL;
+ int which = 0;
+ char **names;
+ (void)name_list;
+ fseek(f, rlistpos, SEEK_SET);
+ if (subcnt > 1) {
+ names = gcalloc(subcnt + 1, sizeof(char *));
+ for (i = 0; i < subcnt; ++i) {
+ /* resource id = */ getushort(f);
+ /* rname = (short) */ getushort(f);
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
+ here = ftell(f);
+ names[i] = TTFGetPSFontName(f, roff + 4, roff + 4);
+ if (names[i] == NULL) {
+ char buffer[32];
+ sprintf(buffer, "Nameless%d", i);
+ names[i] = copy(buffer);
+ }
+ fseek(f, here, SEEK_SET);
+ }
+ if (1) {
+ char *find = fontname;
+ for (which = subcnt - 1; which >= 0; --which)
+ if (strcmp(names[which], find) == 0)
+ break;
+ if (which == -1) {
+ char *end;
+ which = strtol(find, &end, 10);
+ if (*end != '\0')
+ which = -1;
+ }
+ if (which == -1) {
+ ff_post_error(_("Not in Collection"), _("%s is not in %.100s"),
+ find, filename);
+ }
+ } else {
+ which = 0;
+ }
+ for (i = 0; i < subcnt; ++i)
+ free(names[i]);
+ free(names);
+ fseek(f, rlistpos, SEEK_SET);
+ }
+
+ for (i = 0; i < subcnt; ++i) {
+ /* resource id = */ getushort(f);
+ rname = (short) getushort(f);
+ /* flags = */ getc(f);
+ ch1 = getc(f);
+ ch2 = getc(f);
+ roff = rdata_pos + ((ch1 << 16) | (ch2 << 8) | getc(f));
+ /* mbz = */ getlong(f);
+ if (i != which)
+ continue;
+ here = ftell(f);
+
+ sf = createtmpfile(filename);
+ ttf = fopen(sf, "wb");
+ if (ttf == NULL) {
+ LogError(_("Can't open temporary file for truetype output.\n"));
+ continue;
+ }
+
+ fseek(f, roff, SEEK_SET);
+ ilen = rlen = getlong(f);
+ if (rlen > 16 * 1024)
+ ilen = 16 * 1024;
+ if (ilen > max) {
+ free(buffer);
+ max = ilen;
+ if (max < 0x800)
+ max = 0x800;
+ buffer = malloc(max);
+ }
+ for (len = 0; len < rlen;) {
+ int temp = ilen;
+ if (rlen - len < ilen)
+ temp = rlen - len;
+ temp = fread(buffer, 1, temp, f);
+ if (temp == EOF)
+ break;
+ fwrite(buffer, 1, temp, ttf);
+ len += temp;
+ }
+ fclose(ttf);
+ }
+ free(buffer);
+ return sf;
+}
+
+static char *IsResourceForkFile(FILE * f, char *filename, char *fontname)
+{
+ /* If it is a good resource fork then the first 16 bytes are repeated */
+ /* at the location specified in bytes 4-7 */
+ /* We include an offset because if we are looking at a mac binary file */
+ /* the resource fork will actually start somewhere in the middle of the */
+ /* file, not at the beginning */
+ unsigned char buffer[16], buffer2[16];
+ long rdata_pos, map_pos, type_list, name_list, rpos;
+ int32 rdata_len, map_len;
+ uint32 fond_pos;
+ unsigned long tag;
+ int i, cnt, subcnt;
+ char *sf = NULL;
+ fond_pos = 0;
+ fseek(f, 0, SEEK_SET);
+ if (fread(buffer, 1, 16, f) != 16)
+ return (NULL);
+ rdata_pos =
+ ((buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]);
+ map_pos =
+ ((buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7]);
+ rdata_len =
+ ((buffer[8] << 24) | (buffer[9] << 16) | (buffer[10] << 8) |
+ buffer[11]);
+ map_len =
+ ((buffer[12] << 24) | (buffer[13] << 16) | (buffer[14] << 8) |
+ buffer[15]);
+ if (rdata_pos + rdata_len != map_pos || rdata_len == 0)
+ return (NULL);
+ fseek(f, map_pos, SEEK_SET);
+ buffer2[15] = buffer[15] + 1; /* make it be different */
+ if (fread(buffer2, 1, 16, f) != 16)
+ return (NULL);
+ for (i = 0; i < 16; ++i)
+ if (buffer2[i] != 0)
+ break;
+ if (i != 16) {
+ for (i = 0; i < 16; ++i)
+ if (buffer[i] != buffer2[i])
+ return (NULL);
+ }
+ getlong(f); /* skip the handle to the next resource map */
+ getushort(f); /* skip the file resource number */
+ getushort(f); /* skip the attributes */
+ type_list = map_pos + getushort(f);
+ name_list = map_pos + getushort(f);
+ fseek(f, type_list, SEEK_SET);
+ cnt = getushort(f) + 1;
+ for (i = 0; i < cnt; ++i) {
+ tag = getlong(f);
+ subcnt = getushort(f) + 1;
+ rpos = type_list + getushort(f);
+ sf = NULL;
+ if (tag == CHR('s', 'f', 'n', 't')) {
+ sf = SearchTtfResourcesFile(f, rpos, subcnt, rdata_pos, name_list,
+ filename, fontname);
+ }
+ if (sf != NULL)
+ return (sf);
+ }
+ return NULL;
+}
+
+
+/* filename "/opt/tex/texmf-fonts/fonts/data/LucidaGrande.dfont",
+ fontname "Lucida Grande Bold"
+ */
+char *FindResourceTtfFont(char *filename, char *fontname)
+{
+ char *sf = NULL;
+ FILE *f = fopen(filename, "rb");
+ if (f == NULL)
+ return (NULL);
+ sf = IsResourceForkFile(f, filename, fontname);
+ fclose(f);
+ return sf;
+}
- if ( sf==NULL )
- LogError( _("Couldn't find a font file named %s\n"), filename );
- else if ( sf==(SplineFont *) (-1) ) {
- LogError( _("%s is a mac resource file but contains no postscript or truetype fonts\n"), filename );
- sf = NULL;
+SplineFont *SFReadMacBinary(char *filename, int flags, enum openflags openflags)
+{
+ SplineFont *sf = FindResourceFile(filename, flags, openflags, NULL, NULL);
+
+ if (sf == NULL)
+ LogError(_("Couldn't find a font file named %s\n"), filename);
+ else if (sf == (SplineFont *) (-1)) {
+ LogError(_
+ ("%s is a mac resource file but contains no postscript or truetype fonts\n"),
+ filename);
+ sf = NULL;
}
-return( sf );
+ return (sf);
}
-char **NamesReadMacBinary(char *filename) {
-return( (char **) FindResourceFile(filename,ttf_onlynames,0,NULL,NULL));
+char **NamesReadMacBinary(char *filename)
+{
+ return ((char **) FindResourceFile(filename, ttf_onlynames, 0, NULL, NULL));
}
/* should try to optimize this */
-SplineFont *SFReadMacBinaryInfo(char *filename,int flags,enum openflags openflags) {
- SplineFont *sf = FindResourceFile(filename,flags,openflags,NULL,NULL);
-
- if ( sf==NULL )
- LogError( _("Couldn't find a font file named %s\n"), filename );
- else if ( sf==(SplineFont *) (-1) ) {
- LogError( _("%s is a mac resource file but contains no postscript or truetype fonts\n"), filename );
- sf = NULL;
+SplineFont *SFReadMacBinaryInfo(char *filename, int flags,
+ enum openflags openflags)
+{
+ SplineFont *sf = FindResourceFile(filename, flags, openflags, NULL, NULL);
+
+ if (sf == NULL)
+ LogError(_("Couldn't find a font file named %s\n"), filename);
+ else if (sf == (SplineFont *) (-1)) {
+ LogError(_
+ ("%s is a mac resource file but contains no postscript or truetype fonts\n"),
+ filename);
+ sf = NULL;
}
-return( sf );
+ return (sf);
}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c
index d3199f05ee7..3eb886c352f 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/nouiutil.c
@@ -42,7 +42,7 @@ static void NOUI_IError(const char *format,...) {
static void NOUI__LogError(const char *format,va_list ap) {
char buffer[400], *str;
vsnprintf(buffer,sizeof(buffer),format,ap);
- str = utf82def_copy(buffer);
+ str = (char *)buffer;
fprintf(stderr,"%s",str);
if ( str[strlen(str)-1]!='\n' )
putc('\n',stderr);
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
index 1f75c22cddc..9ccd1d393dd 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
@@ -33,11 +33,19 @@
#include <gwidget.h>
#include "ttf.h"
+extern char *AdobeStandardEncoding[], *AdobeExpertEncoding[];
+extern const char *ttfstandardnames[];
+extern int ask_user_for_cmap;
+extern char *SaveTablesPref;
+
#ifdef LUA_FF_LIB
SplineFont *_SFReadTTFInfo(FILE *ttf, int flags,enum openflags openflags, char *filename,struct fontdict *fd);
void THPatchSplineChar(SplineChar *sc);
#endif
+int THtest_duplicate_glyph_names = 0;
+int THread_ttf_glyph_data = 0;
+
char *SaveTablesPref;
int ask_user_for_cmap = false;
@@ -579,6 +587,57 @@ return( NULL );
return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang));
}
+
+char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
+ int i,num;
+ int32 tag, length, stringoffset;
+ int name, len, off;
+ int32 nameoffset = 0;
+
+ fseek(ttf,offset,SEEK_SET);
+ /* version = */ getlong(ttf);
+ num = getushort(ttf);
+ /* srange = */ getushort(ttf);
+ /* esel = */ getushort(ttf);
+ /* rshift = */ getushort(ttf);
+ for ( i=0; i<num; ++i ) {
+ tag = getlong(ttf);
+ /* checksum = */ getlong(ttf);
+ nameoffset = off2+getlong(ttf);
+ length = getlong(ttf);
+ if ( tag==CHR('n','a','m','e'))
+ break;
+ }
+ if ( i==num )
+ return( NULL );
+
+ fseek(ttf,nameoffset,SEEK_SET);
+ /* format = */ getushort(ttf);
+ num = getushort(ttf);
+ stringoffset = nameoffset+getushort(ttf);
+
+ for ( i=0; i<num; ++i ) {
+ /* plat */ getushort(ttf);
+ /* spec */ getushort(ttf);
+ /* lang */ getushort(ttf);
+ name = getushort(ttf);
+ len = getushort(ttf);
+ off = getushort(ttf);
+ if (name == 6) {
+ char *str = malloc(len+1);
+ if (str) {
+ fseek (ttf, stringoffset+off, SEEK_SET);
+ if(fread(str,1,len,ttf)==(size_t)len) {
+ str[len] = '\0';
+ return str;
+ }
+ free(str);
+ }
+ }
+ }
+ return NULL;
+}
+
static int PickTTFFont(FILE *ttf,char *filename,char **chosenname) {
int32 *offsets, cnt, i, choice, j;
char **names;
@@ -660,7 +719,6 @@ return( choice );
}
static void ParseSaveTablesPref(struct ttfinfo *info) {
- extern char *SaveTablesPref;
char *pt, *spt;
int cnt;
@@ -2185,26 +2243,23 @@ return( sc );
sc->xmax = getushort(ttf);
sc->ymax = getushort(ttf);
sc->lsidebearing = sc->xmin;
-#else
- /* xmin = */ sc->lsidebearing = getushort(ttf);
- /* ymin = */ getushort(ttf);
- /* xmax = */ getushort(ttf);
- /* ymax = */ /* sc->lsidebearing = */ getushort(ttf); /* what was this for? */
#endif
- if ( path_cnt>=0 )
+ if (THread_ttf_glyph_data) {
+ if ( path_cnt>=0 )
readttfsimpleglyph(ttf,info,sc,path_cnt);
- else
+ else
readttfcompositglyph(ttf,info,sc,info->glyph_start+end);
- if ( start>end ) {
+ if ( start>end ) {
LogError(_("Bad glyph (%d), disordered 'loca' table (start comes after end)\n"), gid );
info->bad_glyph_data = true;
- } else if ( ftell(ttf)>info->glyph_start+end ) {
+ } else if ( ftell(ttf)>(long)(info->glyph_start+end) ) {
LogError(_("Bad glyph (%d), its definition extends beyond the space allowed for it\n"), gid );
info->bad_glyph_data = true;
+ }
+
+ /* find the bb */
+ THPatchSplineChar(sc);
}
-
- /* find the bb */
- THPatchSplineChar(sc);
return( sc );
}
@@ -3284,7 +3339,6 @@ return( strings[sid-nStdStrings]);
static void readcffenc(FILE *ttf,struct topdicts *dict,struct ttfinfo *info,
char **strings, int scnt) {
int format, cnt, i, j, pos, first, last, dupenc, sid;
- extern char *AdobeStandardEncoding[], *AdobeExpertEncoding[];
const char *name;
EncMap *map;
@@ -3722,7 +3776,7 @@ static void cfffigure(struct ttfinfo *info, struct topdicts *dict,
info->chars = gcalloc(info->glyph_cnt,sizeof(SplineChar *));
for ( i=0; i<info->glyph_cnt; ++i ) {
- info->chars[i] = PSCharStringToSplines(
+ info->chars[i] = PSCharStringToBB(
dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,
subrs,gsubrs,FFgetsid(dict->charset[i],strings,scnt,info));
info->chars[i]->vwidth = info->emsize;
@@ -3805,7 +3859,7 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
cid = dict->charset[i];
/*encmap->map[cid] = cid;*/
uni = CID2NameUni(map,cid,buffer,sizeof(buffer));
- info->chars[i] = PSCharStringToSplines(
+ info->chars[i] = PSCharStringToBB(
dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,
subrs,gsubrs,buffer);
info->chars[i]->vwidth = sf->ascent+sf->descent;
@@ -4129,6 +4183,7 @@ static int umodenc(int enc,int modtype, struct ttfinfo *info) {
return( -1 );
if ( modtype<=1 /* Unicode */ ) {
/* No conversion needed, already unicode */;
+#ifdef FROM_CJK_ICONV
} else if ( modtype==2 /* SJIS */ ) {
if ( enc<=127 ) {
/* Latin */
@@ -4186,6 +4241,10 @@ return( -1 );
enc = unicode_from_johab[enc-0x8400];
else if ( enc>0x100 )
enc = badencoding(info);
+#else
+ } else {
+ enc = badencoding(info);
+#endif
}
if ( enc==0 )
enc = -1;
@@ -4464,7 +4523,6 @@ static void readttfencodings(FILE *ttf,struct ttfinfo *info, int justinuse) {
Encoding *temp;
EncMap *map;
struct cmap_encs *cmap_encs, desired_cmaps[2], *dcmap;
- extern int ask_user_for_cmap;
fseek(ttf,info->encoding_start,SEEK_SET);
version = getushort(ttf);
@@ -5093,7 +5151,6 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) {
const char *name;
char buffer[30];
uint16 *indexes;
- extern const char *ttfstandardnames[];
int notdefwarned = false;
int anynames = false;
@@ -5211,7 +5268,7 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) {
name = NULL;
} else {
name = StdGlyphName(buffer,info->chars[i]->unicodeenc,info->uni_interp,NULL);
- if ( anynames ) {
+ if (THtest_duplicate_glyph_names && anynames ) {
for ( j=0; j<info->glyph_cnt; ++j ) {
if ( info->chars[j]!=NULL && j!=i && info->chars[j]->name!=NULL ) {
if ( strcmp(info->chars[j]->name,name)==0 ) {
@@ -5942,56 +5999,6 @@ return;
map->backmap[map->map[i]] = i;
}
-void TTF_PSDupsDefault(SplineFont *sf) {
- struct ttflangname *english;
- char versionbuf[40];
-
- /* Ok, if we've just loaded a ttf file then we've got a bunch of langnames*/
- /* we copied some of them (copyright, family, fullname, etc) into equiv */
- /* postscript entries in the sf. If we then use FontInfo and change the */
- /* obvious postscript entries we are left with the old ttf entries. If */
- /* we generate a ttf file and then load it the old values pop up. */
- /* Solution: Anything we can generate by default should be set to NULL */
- for ( english=sf->names; english!=NULL && english->lang!=0x409; english=english->next );
- if ( english==NULL )
-return;
- if ( english->names[ttf_family]!=NULL &&
- strcmp(english->names[ttf_family],sf->familyname)==0 ) {
- free(english->names[ttf_family]);
- english->names[ttf_family]=NULL;
- }
- if ( english->names[ttf_copyright]!=NULL &&
- strcmp(english->names[ttf_copyright],sf->copyright)==0 ) {
- free(english->names[ttf_copyright]);
- english->names[ttf_copyright]=NULL;
- }
- if ( english->names[ttf_fullname]!=NULL &&
- strcmp(english->names[ttf_fullname],sf->fullname)==0 ) {
- free(english->names[ttf_fullname]);
- english->names[ttf_fullname]=NULL;
- }
- if ( sf->subfontcnt!=0 || sf->version!=NULL ) {
- if ( sf->subfontcnt!=0 )
- sprintf( versionbuf, "Version %f", sf->cidversion );
- else
- sprintf(versionbuf,"Version %.20s ", sf->version);
- if ( english->names[ttf_version]!=NULL &&
- strcmp(english->names[ttf_version],versionbuf)==0 ) {
- free(english->names[ttf_version]);
- english->names[ttf_version]=NULL;
- }
- }
- if ( english->names[ttf_subfamily]!=NULL &&
- strcmp(english->names[ttf_subfamily],SFGetModifiers(sf))==0 ) {
- free(english->names[ttf_subfamily]);
- english->names[ttf_subfamily]=NULL;
- }
-
- /* User should not be allowed any access to this one, not ever */
- free(english->names[ttf_postscriptname]);
- english->names[ttf_postscriptname]=NULL;
-}
-
static SplineFont *SFFillFromTTF(struct ttfinfo *info) {
SplineFont *sf, *_sf;
int i,k;
@@ -6175,21 +6182,6 @@ static SplineFont *SFFillFromTTF(struct ttfinfo *info) {
sf->subfonts[i]->hasvmetrics = sf->hasvmetrics;
}
}
- TTF_PSDupsDefault(sf);
-#if 0
- if ( info->gsub_start==0 && info->mort_start==0 && info->morx_start==0 ) {
- /* Get default ligature values, etc. */
- k=0;
- do {
- _sf = k<sf->subfontcnt?sf->subfonts[k]:sf;
- for ( i=0; i<sf->glyphcnt; ++i ) {
- if ( _sf->glyphs[i]!=NULL ) /* Might be null in ttc files */
- SCLigDefault(_sf->glyphs[i]);
- }
- ++k;
- } while ( k<sf->subfontcnt );
- }
-#endif
/* I thought the languages were supposed to be ordered, but it seems */
/* that is not always the case. Order everything, just in case */
@@ -6382,11 +6374,13 @@ return( SFFillFromTTFInfo(&info));
SplineFont *SFReadTTFInfo(char *filename, int flags, enum openflags openflags) {
FILE *ttf;
SplineFont *sf;
- char *temp=filename, *pt, *lparen;
+ char *temp=filename, *pt, *lparen, *rparen;
pt = strrchr(filename,'/');
if ( pt==NULL ) pt = filename;
- if ( (lparen=strchr(pt,'('))!=NULL && strchr(lparen,')')!=NULL ) {
+ if ( (lparen = strrchr(pt,'('))!=NULL &&
+ (rparen = strrchr(lparen,')'))!=NULL &&
+ rparen[1]=='\0' ) {
temp = copy(filename);
pt = temp + (lparen-filename);
*pt = '\0';
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c
index 8b86752fc20..fa466564027 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c
@@ -316,7 +316,10 @@ static uint16 *getClassDefTable(FILE *ttf, int classdef_offset, struct ttfinfo *
} else if ( ftell(ttf)+2*glyphcnt > g_bounds ) {
LogError( _("Class definition sub-table extends beyond end of table\n") );
info->bad_ot = true;
- glyphcnt = (g_bounds-ftell(ttf))/2;
+ if (g_bounds<ftell(ttf))
+ glyphcnt = 0;
+ else
+ glyphcnt = (g_bounds-ftell(ttf))/2;
}
for ( i=0; i<glyphcnt; ++i )
glist[start+i] = getushort(ttf);
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/psread.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/psread.c
index c5e4958d0f5..cb3b0676699 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/psread.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/psread.c
@@ -36,6 +36,10 @@
# include <ieeefp.h> /* Solaris defines isnan in ieeefp rather than math.h */
#endif
+int THdo_hint_guessing = 0;
+int THdo_set_reversing = 0;
+int THdo_catagorize = 0;
+
typedef struct _io {
char *macro, *start;
FILE *ps, *fog;
@@ -2673,7 +2677,7 @@ static void EntityDefaultStrokeFill(Entity *ent) {
static SplinePointList *SplinesFromEntityChar(EntityChar *ec,int *flags,int is_stroked) {
Entity *ent, *next;
- SplinePointList *head=NULL, *last, *new, *nlast, *temp, *each, *transed;
+ SplinePointList *head=NULL, *last=NULL, *new, *nlast=NULL, *temp, *each, *transed;
StrokeInfo si;
real inversetrans[6];
/*SplineSet *spl;*/
@@ -4072,7 +4076,8 @@ SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *conte
done:
if ( pcsp!=0 )
LogError( _("end of subroutine reached with no return in %s\n"), name );
- SCCatagorizePoints(ret);
+ if (THdo_catagorize)
+ SCCatagorizePoints(ret);
ret->hstem = HintsAppend(ret->hstem,activeh); activeh=NULL;
ret->vstem = HintsAppend(ret->vstem,activev); activev=NULL;
@@ -4097,27 +4102,699 @@ SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *conte
SplineMake3(cur->last,cur->first);
cur->last = cur->first;
}
-
/* Oh, I see. PS and TT disagree on which direction to use, so Fontographer*/
/* chose the TT direction and we must reverse postscript */
- for ( cur = ret->layers[ly_fore].splines; cur!=NULL; cur = cur->next )
+ if (THdo_set_reversing) {
+ for ( cur = ret->layers[ly_fore].splines; cur!=NULL; cur = cur->next )
SplineSetReverse(cur);
+ }
if ( ret->hstem==NULL && ret->vstem==NULL )
ret->manualhints = false;
if ( !is_type2 && context->instance_count!=0 ) {
UnblendFree(ret->hstem);
UnblendFree(ret->vstem);
}
- ret->hstem = HintCleanup(ret->hstem,true,context->instance_count);
- ret->vstem = HintCleanup(ret->vstem,true,context->instance_count);
- SCGuessHHintInstancesList(ret,ly_fore);
- SCGuessVHintInstancesList(ret,ly_fore);
- ret->hconflicts = StemListAnyConflicts(ret->hstem);
- ret->vconflicts = StemListAnyConflicts(ret->vstem);
- if ( context->instance_count==1 && !ret->hconflicts && !ret->vconflicts )
+ if (THdo_hint_guessing) {
+ ret->hstem = HintCleanup(ret->hstem,true,context->instance_count);
+ ret->vstem = HintCleanup(ret->vstem,true,context->instance_count);
+ SCGuessHHintInstancesList(ret,ly_fore);
+ SCGuessVHintInstancesList(ret,ly_fore);
+ ret->hconflicts = StemListAnyConflicts(ret->hstem);
+ ret->vconflicts = StemListAnyConflicts(ret->vstem);
+ if ( context->instance_count==1 && !ret->hconflicts && !ret->vconflicts )
SCClearHintMasks(ret,ly_fore,false);
- HintsRenumber(ret);
+ HintsRenumber(ret);
+ }
if ( name!=NULL && strcmp(name,".notdef")!=0 )
ret->widthset = true;
return( ret );
}
+
+
+/* This finds the 'connect-the-dots' boundingbox of a Type2 charstring */
+/* It is a simplified version of PSCharStringToSplines, above */
+
+SplineChar *PSCharStringToBB(uint8 *type1, int len, struct pscontext *context,
+ struct pschars *subrs, struct pschars *gsubrs, const char *name) {
+ real stack[50]; int sp=0, v; /* Type1 stack is about 25 long, Type2 stack is 48 */
+ real transient[32];
+ SplineChar *ret = SplineCharCreate(2);
+
+ DBasePoint current, ll, ur;
+ real dx, dy, dx2, dy2, dx3, dy3, dx4, dy4, dx5, dy5, dx6=0, dy6;
+
+ int first = 1; /* to flag extra set width */
+ /* subroutines may be nested to a depth of 10 */
+ struct substate { unsigned char *type1; int len; int subnum; } pcstack[11];
+ int pcsp=0;
+
+ real pops[30];
+ int popsp=0;
+ int base, polarity;
+
+ struct pschars *s;
+ int hint_cnt = 0;
+
+ int last_was_b1=false, old_last_was_b1;
+
+ ret->name = copy( name );
+ ret->unicodeenc = -1;
+ ret->width = (int16) 0x8000;
+ if ( name==NULL ) name = "unnamed";
+ ret->manualhints = true;
+ if ( !context->is_type2 ) {
+ LogError( _("Quick boundingbox mode only does CFF charstrings, not Type1 (font %s)\n"), name );
+ return (ret);
+ }
+
+ current.x = current.y = 0;
+ ll.x = ll.y = (int16) 0x7FFF;
+ ur.x = ur.y = (int16) -0x7FFF;
+
+ while ( len>0 ) {
+ if ( sp>48 ) {
+ LogError( _("Stack got too big in %s\n"), name );
+ sp = 48;
+ }
+ base = 0;
+ --len;
+ if ( (v = *type1++)>=32 ) {
+ if ( v<=246) {
+ stack[sp++] = v - 139;
+ } else if ( v<=250 ) {
+ stack[sp++] = (v-247)*256 + *type1++ + 108;
+ --len;
+ } else if ( v<=254 ) {
+ stack[sp++] = -(v-251)*256 - *type1++ - 108;
+ --len;
+ } else {
+ int val = (*type1<<24) | (type1[1]<<16) | (type1[2]<<8) | type1[3];
+ stack[sp++] = val;
+ type1 += 4;
+ len -= 4;
+ stack[sp-1] /= 65536.;
+ }
+ } else if ( v==28 ) {
+ stack[sp++] = (short) ((type1[0]<<8) | type1[1]);
+ type1 += 2;
+ len -= 2;
+ /* In the Dict tables of CFF, a 5byte fixed value is prefixed by a */
+ /* 29 code. In Type2 strings the prefix is 255. */
+ } else if ( v==12 ) {
+ old_last_was_b1 = last_was_b1; last_was_b1 = false;
+ v = *type1++;
+ --len;
+ switch ( v ) {
+ case 0: /* dotsection */
+ sp = 0;
+ break;
+ case 1: /* vstem3 */ /* specifies three v hints zones at once */
+ if ( sp<6 ) LogError( _("Stack underflow on vstem3 in %s\n"), name );
+ /* according to the standard, if there is a vstem3 there can't */
+ /* be any vstems, so there can't be any confusion about hint order */
+ /* so we don't need to worry about unblended stuff */
+ hint_cnt+=3;
+ sp = 0;
+ break;
+ case 2: /* hstem3 */ /* specifies three h hints zones at once */
+ if ( sp<6 ) LogError( _("Stack underflow on hstem3 in %s\n"), name );
+ hint_cnt+=3;
+ sp = 0;
+ break;
+ case 6: /* seac */ /* build accented characters */
+ seac:
+ if ( sp<5 ) LogError( _("Stack underflow on seac in %s\n"), name );
+ /* stack[0] must be the lsidebearing of the accent. I'm not sure why */
+ sp = 0;
+ break;
+ case 7: /* sbw */ /* generalized width/sidebearing command */
+ if ( sp<4 ) LogError( _("Stack underflow on sbw in %s\n"), name );
+ ret->lsidebearing = stack[0];
+ /* stack[1] is lsidebearing y (only for vertical writing styles, CJK) */
+ ret->width = stack[2];
+ /* stack[3] is height (for vertical writing styles, CJK) */
+ sp = 0;
+ break;
+ case 5: case 9: case 14: case 26:
+ if ( sp<1 ) LogError( _("Stack underflow on unary operator in %s\n"), name );
+ switch ( v ) {
+ case 5: stack[sp-1] = (stack[sp-1]==0); break; /* not */
+ case 9: if ( stack[sp-1]<0 ) stack[sp-1]= -stack[sp-1]; break; /* abs */
+ case 14: stack[sp-1] = -stack[sp-1]; break; /* neg */
+ case 26: stack[sp-1] = sqrt(stack[sp-1]); break; /* sqrt */
+ }
+ break;
+ case 3: case 4: case 10: case 11: case 12: case 15: case 24:
+ if ( sp<2 ) LogError( _("Stack underflow on binary operator in %s\n"), name );
+ else switch ( v ) {
+ case 3: /* and */
+ stack[sp-2] = (stack[sp-1]!=0 && stack[sp-2]!=0);
+ break;
+ case 4: /* and */
+ stack[sp-2] = (stack[sp-1]!=0 || stack[sp-2]!=0);
+ break;
+ case 10: /* add */
+ stack[sp-2] += stack[sp-1];
+ break;
+ case 11: /* sub */
+ stack[sp-2] -= stack[sp-1];
+ break;
+ case 12: /* div */
+ stack[sp-2] /= stack[sp-1];
+ break;
+ case 24: /* mul */
+ stack[sp-2] *= stack[sp-1];
+ break;
+ case 15: /* eq */
+ stack[sp-2] = (stack[sp-1]==stack[sp-2]);
+ break;
+ }
+ --sp;
+ break;
+ case 22: /* ifelse */
+ if ( sp<4 ) LogError( _("Stack underflow on ifelse in %s\n"), name );
+ else {
+ if ( stack[sp-2]>stack[sp-1] )
+ stack[sp-4] = stack[sp-3];
+ sp -= 3;
+ }
+ break;
+ case 23: /* random */
+ /* This function returns something (0,1]. It's not clear to me*/
+ /* if rand includes 0 and RAND_MAX or not, but this approach */
+ /* should work no matter what */
+ do {
+ stack[sp] = (rand()/(RAND_MAX-1));
+ } while ( stack[sp]==0 || stack[sp]>1 );
+ ++sp;
+ break;
+ case 20: /* put */
+ if ( sp<2 ) LogError( _("Too few items on stack for put in %s\n"), name );
+ else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) LogError( _("Reference to transient memory out of bounds in put in %s\n"), name );
+ else {
+ transient[(int)stack[sp-1]] = stack[sp-2];
+ sp -= 2;
+ }
+ break;
+ case 21: /* get */
+ if ( sp<1 ) LogError( _("Too few items on stack for get in %s\n"), name );
+ else if ( stack[sp-1]<0 || stack[sp-1]>=32 ) LogError( _("Reference to transient memory out of bounds in put in %s\n"), name );
+ else
+ stack[sp-1] = transient[(int)stack[sp-1]];
+ break;
+ case 17: /* pop */
+ /* pops something from the postscript stack and pushes it on ours */
+ /* used to get a return value from an othersubr call */
+ /* Bleah. Adobe wants the pops to return the arguments if we */
+ /* don't understand the call. What use is the subroutine then?*/
+ if ( popsp<=0 )
+ LogError( _("Pop stack underflow on pop in %s\n"), name );
+ else
+ stack[sp++] = pops[--popsp];
+ break;
+ case 18: /* drop */
+ if ( sp>0 ) --sp;
+ break;
+ case 27: /* dup */
+ if ( sp>=1 ) {
+ stack[sp] = stack[sp-1];
+ ++sp;
+ }
+ break;
+ case 28: /* exch */
+ if ( sp>=2 ) {
+ real temp = stack[sp-1];
+ stack[sp-1] = stack[sp-2]; stack[sp-2] = temp;
+ }
+ break;
+ case 29: /* index */
+ if ( sp>=1 ) {
+ int index = stack[--sp];
+ if ( index<0 || sp<index+1 )
+ LogError( _("Index out of range in %s\n"), name );
+ else {
+ stack[sp] = stack[sp-index-1];
+ ++sp;
+ }
+ }
+ break;
+ case 30: /* roll */
+ if ( sp>=2 ) {
+ int j = stack[sp-1], N=stack[sp-2];
+ if ( N>sp || j>=N || j<0 || N<0 )
+ LogError( _("roll out of range in %s\n"), name );
+ else if ( j==0 || N==0 )
+ /* No op */;
+ else {
+ real *temp = galloc(N*sizeof(real));
+ int i;
+ for ( i=0; i<N; ++i )
+ temp[i] = stack[sp-N+i];
+ for ( i=0; i<N; ++i )
+ stack[sp-N+i] = temp[(i+j)%N];
+ free(temp);
+ }
+ }
+ break;
+ case 33: /* setcurrentpoint */
+ if ( sp<2 ) LogError( _("Stack underflow on setcurrentpoint in %s\n"), name );
+ else {
+ current.x = stack[0];
+ current.y = stack[1];
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ }
+ sp = 0;
+ break;
+ case 34: /* hflex */
+ case 35: /* flex */
+ case 36: /* hflex1 */
+ case 37: /* flex1 */
+ dy = dy3 = dy4 = dy5 = dy6 = 0;
+ dx = stack[base++];
+ if ( v!=34 )
+ dy = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dx3 = stack[base++];
+ if ( v!=34 && v!=36 )
+ dy3 = stack[base++];
+ dx4 = stack[base++];
+ if ( v!=34 && v!=36 )
+ dy4 = stack[base++];
+ dx5 = stack[base++];
+ if ( v==34 )
+ dy5 = -dy2;
+ else
+ dy5 = stack[base++];
+ switch ( v ) {
+ real xt, yt;
+ case 35: /* flex */
+ dx6 = stack[base++];
+ dy6 = stack[base++];
+ break;
+ case 34: /* hflex */
+ dx6 = stack[base++];
+ break;
+ case 36: /* hflex1 */
+ dx6 = stack[base++];
+ dy6 = -dy-dy2-dy5;
+ break;
+ case 37: /* flex1 */
+ xt = dx+dx2+dx3+dx4+dx5;
+ yt = dy+dy2+dy3+dy4+dy5;
+ if ( xt<0 ) xt= -xt;
+ if ( yt<0 ) yt= -yt;
+ if ( xt>yt ) {
+ dx6 = stack[base++];
+ dy6 = -dy-dy2-dy3-dy4-dy5;
+ } else {
+ dy6 = stack[base++];
+ dx6 = -dx-dx2-dx3-dx4-dx5;
+ }
+ break;
+ }
+ current.x = current.x+dx; current.y = current.y+dy;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx2; current.y = current.y+dy2;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx3; current.y = current.y+dy3;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+
+ current.x = current.x+dx4; current.y = current.y+dy4;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx5; current.y = current.y+dy5;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx6; current.y = current.y+dy6;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ sp = 0;
+ break;
+ default:
+ LogError( _("Uninterpreted opcode 12,%d in %s\n"), v, name );
+ break;
+ }
+ } else { last_was_b1 = false; switch ( v ) {
+ case 1: /* hstem */
+ case 18: /* hstemhm */
+ base = 0;
+ if ( (sp&1) && ret->width == (int16) 0x8000 )
+ ret->width = stack[0];
+ if ( sp&1 )
+ base=1;
+ if ( sp-base<2 )
+ LogError( _("Stack underflow on hstem in %s\n"), name );
+ /* stack[0] is absolute y for start of horizontal hint */
+ /* (actually relative to the y specified as lsidebearing y in sbw*/
+ /* stack[1] is relative y for height of hint zone */
+
+
+ while ( sp-base>=2 ) {
+ hint_cnt++;
+ base+=2;
+ }
+ sp = 0;
+ break;
+ case 19: /* hintmask */
+ case 20: /* cntrmask */
+ /* If there's anything on the stack treat it as a vstem hint */
+ case 3: /* vstem */
+ case 23: /* vstemhm */
+ base = 0;
+ if ( first || v==3 || v==23 ) {
+ if ( (sp&1) && ret->width == (int16) 0x8000 ) {
+ ret->width = stack[0];
+ }
+ if ( sp&1 )
+ base=1;
+ if ( sp-base<2 && v!=19 && v!=20 )
+ LogError( _("Stack underflow on vstem in %s\n"), name );
+ /* stack[0] is absolute x for start of vertical hint */
+ /* (actually relative to the x specified as lsidebearing in h/sbw*/
+ /* stack[1] is relative x for height of hint zone */
+
+
+ while ( sp-base>=2 ) {
+ hint_cnt++;
+ base+=2;
+ }
+ sp = 0;
+ }
+ if ( v==19 || v==20 ) { /* hintmask, cntrmask */
+ unsigned bytes = (hint_cnt+7)/8;
+ if ( bytes>sizeof(HintMask) ) bytes = sizeof(HintMask);
+ if ( bytes!=(unsigned)hint_cnt/8 ) {
+ int mask = 0xff>>(hint_cnt&7);
+ if ( type1[bytes-1]&mask )
+ LogError( _("Hint mask (or counter mask) with too many hints in %s\n"), name );
+ }
+ type1 += bytes;
+ len -= bytes;
+ }
+ break;
+ case 14: /* endchar */
+ /* endchar is allowed to terminate processing even within a subroutine */
+ if ( (sp&1) && ret->width == (int16) 0x8000 )
+ ret->width = stack[0];
+ pcsp = 0;
+ if ( sp==4 ) {
+ /* In Type2 strings endchar has a depreciated function of doing */
+ /* a seac (which doesn't exist at all). Except enchar takes */
+ /* 4 args and seac takes 5. Bleah */
+ stack[4] = stack[3]; stack[3] = stack[2]; stack[2] = stack[1]; stack[1] = stack[0];
+ stack[0] = 0;
+ sp = 5;
+ goto seac;
+ } else if ( sp==5 ) {
+ /* same as above except also specified a width */
+ stack[0] = 0;
+ goto seac;
+ }
+ /* the docs say that endchar must be the last command in a char */
+ goto done;
+ break;
+ case 13: /* hsbw (set left sidebearing and width) */
+ if ( sp<2 ) LogError( _("Stack underflow on hsbw in %s\n"), name );
+ ret->lsidebearing = stack[0];
+ current.x = stack[0]; /* sets the current point too */
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ ret->width = stack[1];
+ sp = 0;
+ break;
+ case 9: /* closepath */
+ sp = 0;
+ break;
+ case 21: /* rmoveto */
+ case 22: /* hmoveto */
+ case 4: /* vmoveto */
+ if (( (v==21 && sp==3) || (v!=21 && sp==2)) && ret->width == (int16) 0x8000 )
+ /* Character's width may be specified on the first moveto */
+ ret->width = stack[0];
+ if ( v==21 && sp>2 ) {
+ stack[0] = stack[sp-2]; stack[1] = stack[sp-1];
+ sp = 2;
+ } else if ( v!=21 && sp>1 ) {
+ stack[0] = stack[sp-1];
+ sp = 1;
+ }
+ /* fall through */
+ case 5: /* rlineto */
+ case 6: /* hlineto */
+ case 7: /* vlineto */
+ polarity = 0;
+ base = 0;
+ while ( base<sp ) {
+ dx = dy = 0;
+ if ( v==5 || v==21 ) {
+ if ( sp<base+2 ) {
+ LogError( _("Stack underflow on rlineto/rmoveto in %s\n"), name );
+ break;
+ }
+ dx = stack[base++];
+ dy = stack[base++];
+ } else if ( (v==6 && !(polarity&1)) || (v==7 && (polarity&1)) || v==22 ) {
+ if ( sp<=base ) {
+ LogError( _("Stack underflow on hlineto/hmoveto in %s\n"), name );
+ break;
+ }
+ dx = stack[base++];
+ } else /*if ( (v==7 && !(parity&1)) || (v==6 && (parity&1) || v==4 )*/ {
+ if ( sp<=base ) {
+ LogError( _("Stack underflow on vlineto/vmoveto in %s\n"), name );
+ break;
+ }
+ dy = stack[base++];
+ }
+ ++polarity;
+ current.x = current.x+dx; current.y = current.y+dy;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ if ( v==4 || v==21 || v==22 ) {
+ first = 0;
+ break;
+ } else {
+ first = 0;
+ }
+ }
+ sp = 0;
+ break;
+ case 25: /* rlinecurve */
+ base = 0;
+ while ( sp>base+6 ) {
+ current.x = current.x+stack[base++]; current.y = current.y+stack[base++];
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ first = 0;
+ }
+ case 24: /* rcurveline */
+ case 8: /* rrcurveto */
+ case 31: /* hvcurveto */
+ case 30: /* vhcurveto */
+ case 27: /* hhcurveto */
+ case 26: /* vvcurveto */
+ polarity = 0;
+ while ( sp>base+2 ) {
+ dx = dy = dx2 = dy2 = dx3 = dy3 = 0;
+ if ( v==8 || v==25 || v==24 ) {
+ if ( sp<6+base ) {
+ LogError( _("Stack underflow on rrcurveto in %s\n"), name );
+ base = sp;
+ } else {
+ dx = stack[base++];
+ dy = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dx3 = stack[base++];
+ dy3 = stack[base++];
+ }
+ } else if ( v==27 ) { /* hhcurveto */
+ if ( sp<4+base ) {
+ LogError( _("Stack underflow on hhcurveto in %s\n"), name );
+ base = sp;
+ } else {
+ if ( (sp-base)&1 ) dy = stack[base++];
+ dx = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dx3 = stack[base++];
+ }
+ } else if ( v==26 ) { /* vvcurveto */
+ if ( sp<4+base ) {
+ LogError( _("Stack underflow on hhcurveto in %s\n"), name );
+ base = sp;
+ } else {
+ if ( (sp-base)&1 ) dx = stack[base++];
+ dy = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dy3 = stack[base++];
+ }
+ } else if ( (v==31 && !(polarity&1)) || (v==30 && (polarity&1)) ) {
+ if ( sp<4+base ) {
+ LogError( _("Stack underflow on hvcurveto in %s\n"), name );
+ base = sp;
+ } else {
+ dx = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dy3 = stack[base++];
+ if ( sp==base+1 )
+ dx3 = stack[base++];
+ }
+ } else /*if ( (v==30 && !(polarity&1)) || (v==31 && (polarity&1)) )*/ {
+ if ( sp<4+base ) {
+ LogError( _("Stack underflow on vhcurveto in %s\n"), name );
+ base = sp;
+ } else {
+ dy = stack[base++];
+ dx2 = stack[base++];
+ dy2 = stack[base++];
+ dx3 = stack[base++];
+ if ( sp==base+1 )
+ dy3 = stack[base++];
+ }
+ }
+ ++polarity;
+ current.x = current.x+dx; current.y = current.y+dy;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx2; current.y = current.y+dy2;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ current.x = current.x+dx3; current.y = current.y+dy3;
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ }
+ if ( v==24 ) {
+ current.x = current.x+stack[base++]; current.y = current.y+stack[base++];
+ if (ll.y>current.y) ll.y = current.y;
+ if (ur.y<current.y) ur.y = current.y;
+ if (ll.x>current.x) ll.x = current.x;
+ if (ur.x<current.x) ur.x = current.x;
+ }
+ sp = 0;
+ break;
+ case 29: /* callgsubr */
+ case 10: /* callsubr */
+ /* stack[sp-1] contains the number of the subroutine to call */
+ if ( sp<1 ) {
+ LogError( _("Stack underflow on callsubr in %s\n"), name );
+ break;
+ } else if ( pcsp>10 ) {
+ LogError( _("Too many subroutine calls in %s\n"), name );
+ break;
+ }
+ s=subrs; if ( v==29 ) s = gsubrs;
+ if ( s!=NULL ) stack[sp-1] += s->bias;
+ /* Type2 subrs have a bias that must be added to the subr-number */
+ /* Type1 subrs do not. We set the bias on them to 0 */
+ if ( s==NULL || stack[sp-1]>=s->cnt || stack[sp-1]<0 ||
+ s->values[(int) stack[sp-1]]==NULL )
+ LogError( _("Subroutine number out of bounds in %s\n"), name );
+ else {
+ pcstack[pcsp].type1 = type1;
+ pcstack[pcsp].len = len;
+ pcstack[pcsp].subnum = stack[sp-1];
+ ++pcsp;
+ type1 = s->values[(int) stack[sp-1]];
+ len = s->lens[(int) stack[sp-1]];
+ }
+ if ( --sp<0 ) sp = 0;
+ break;
+ case 11: /* return */
+ /* return from a subr outine */
+ if ( pcsp<1 ) LogError( _("return when not in subroutine in %s\n"), name );
+ else {
+ --pcsp;
+ type1 = pcstack[pcsp].type1;
+ len = pcstack[pcsp].len;
+ }
+ break;
+ case 16: { /* blend -- obsolete type 2 multiple master operator */
+ int cnt,i,j;
+ if ( context->instance_count==0 )
+ LogError( _("Attempt to use a multiple master subroutine in a non-mm font.\n") );
+ else if ( sp<1 || sp<context->instance_count*stack[sp-1]+1 )
+ LogError( _("Too few items on stack for blend in %s\n"), name );
+ else {
+ if ( !context->blend_warn ) {
+ LogError( _("Use of obsolete blend operator.\n") );
+ context->blend_warn = true;
+ }
+ cnt = stack[sp-1];
+ sp -= context->instance_count*stack[sp-1]+1;
+ for ( i=0; i<cnt; ++i ) {
+ for ( j=1; j<context->instance_count; ++j )
+ stack[sp+i] += context->blend_values[j]*stack[sp+
+ cnt+ i*(context->instance_count-1)+ j-1];
+ }
+ /* there will always be fewer pushes than there were pops */
+ /* so I don't bother to check the stack */
+ sp += cnt;
+ }
+ }
+ break;
+ default:
+ LogError( _("Uninterpreted opcode %d in %s\n"), v, name );
+ break;
+ }}
+ }
+done:
+ if ( pcsp!=0 )
+ LogError( _("end of subroutine reached with no return in %s\n"), name );
+
+ if ( name!=NULL && strcmp(name,".notdef")!=0 )
+ ret->widthset = true;
+ if (ur.x == -0x7FFF) ur.x = 0;
+ if (ur.y == -0x7FFF) ur.y = 0;
+ if (ll.x == 0x7FFF) ll.x = 0;
+ if (ll.y == 0x7FFF) ll.y = 0;
+ if (ll.x>ur.x) ll.x = ur.x;
+ if (ll.y>ur.y) ll.y = ur.y;
+
+
+ ret->xmin = rint(ll.x);
+ ret->ymin = rint(ll.y);
+ ret->xmax = rint(ur.x);
+ ret->ymax = rint(ur.y);
+ /* free the curves */
+ if (ret->layers!=NULL && ret->layers[ly_fore].splines != NULL) {
+ SplinePointListsFree(ret->layers[ly_fore].splines);
+ ret->layers[ly_fore].splines=NULL;
+ }
+ if (ret->layers[ly_fore].refs!=NULL) {
+ RefCharsFree(ret->layers[ly_fore].refs);
+ ret->layers[ly_fore].refs = NULL;
+ }
+ return( ret );
+}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
index 1fa40c46072..9f0ed92305f 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.c
@@ -498,7 +498,7 @@ return( _ReadSplineFont(NULL,filename,openflags));
SplineFont *ReadSplineFontInfo(char *filename,enum openflags openflags) {
SplineFont *sf, *sf_ptr;
char **fontlist;
- char *pt =NULL, *strippedname=filename, *paren=NULL, *fullname=filename;
+ char *pt =NULL, *strippedname=filename, *paren=NULL, *rparen=NULL, *fullname=filename;
FILE *foo = NULL;
int checked = 0;
char s[512] = {0};
@@ -508,9 +508,14 @@ return( NULL );
pt = strrchr(filename,'/');
if ( pt==NULL ) pt = filename;
- if ( (paren=strchr(pt,'('))!=NULL && strchr(paren,')')!=NULL ) {
- strippedname = copy(filename);
- strippedname[paren-filename] = '\0';
+ /* Someone gave me a font "Nafees Nastaleeq(Updated).ttf" and complained */
+ /* that ff wouldn't open it */
+ /* Now someone will complain about "Nafees(Updated).ttc(fo(ob)ar)" */
+ if ( (paren = strrchr(pt,'('))!=NULL &&
+ (rparen = strrchr(paren,')'))!=NULL &&
+ rparen[1]=='\0' ) {
+ strippedname = copy(filename);
+ strippedname[paren-filename] = '\0';
}
sf = NULL;
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h
index fa989d61543..a15b6b75325 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h
@@ -1866,8 +1866,11 @@ struct findsel;
struct charprocs;
struct enc;
-extern void *chunkalloc(int size);
-extern void chunkfree(void *, int size);
+/* extern void *chunkalloc(int size); */
+/* extern void chunkfree(void *, int size); */
+
+#define chunkalloc(size) gcalloc(1,size)
+#define chunkfree(item,size) free(item)
extern char *strconcat(const char *str, const char *str2);
extern char *strconcat3(const char *str, const char *str2, const char *str3);
@@ -1946,7 +1949,6 @@ extern long mactime(void);
extern int WriteSVGFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer);
extern int WriteUFOFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer);
extern void SfListFree(struct sflist *sfs);
-extern void TTF_PSDupsDefault(SplineFont *sf);
extern void DefaultTTFEnglishNames(struct ttflangname *dummy, SplineFont *sf);
extern void TeXDefaultParams(SplineFont *sf);
extern int AlreadyMSSymbolArea(SplineFont *sf,EncMap *map);
@@ -2506,6 +2508,7 @@ extern SplineFont *_SFDRead(char *filename,FILE *sfd);
extern SplineFont *SFDirRead(char *filename);
extern SplineChar *SFDReadOneChar(SplineFont *sf,const char *name);
extern char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2);
+extern char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2);
extern void TTFLoadBitmaps(FILE *ttf,struct ttfinfo *info, int onlyone);
enum ttfflags { ttf_onlystrikes=1, ttf_onlyonestrike=2, ttf_onlykerns=4, ttf_onlynames=8 };
extern SplineFont *_SFReadTTF(FILE *ttf,int flags,enum openflags openflags,
@@ -2601,6 +2604,8 @@ struct pscontext {
extern int UnblendedCompare(real u1[MmMax], real u2[MmMax], int cnt);
extern SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *context,
struct pschars *subrs, struct pschars *gsubrs, const char *name);
+extern SplineChar *PSCharStringToBB(uint8 *type1, int len, struct pscontext *context,
+ struct pschars *subrs, struct pschars *gsubrs, const char *name);
extern void MatMultiply(real m1[6], real m2[6], real to[6]);
extern int NameToEncoding(SplineFont *sf,EncMap *map,const char *uname);
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c
index 43626aec6dc..ce80d837f87 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splineutil2.c
@@ -1377,7 +1377,7 @@ Spline *SplineAddExtrema(Spline *s,int always,real lenbound, real offsetbound,
uint8 rmfrom[4], rmto[4];
int p, i,j, p_s, mini;
SplinePoint *sp;
- real len;
+ real len = 0; /* Init variable to silence compiler warnings */
if ( !always ) {
real xlen, ylen;
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c
index e5722cfc27d..559867543f2 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottfaat.c
@@ -95,6 +95,8 @@ return( false );
if ( features->ismac || OTTagToMacFeature(features->featuretag,&ft,&fs))
return( true );
}
+ default: /* handle this to silence compiler warnings */
+ break;
}
return( false );
}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h
index fd2247f7e1b..cfeaf7a24d5 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/chardata.h
@@ -72,7 +72,3 @@ extern struct charmap2 johab_from_unicode;
extern const unichar_t unicode_from_gb2312[];
extern struct charmap2 gb2312_from_unicode;
-/* a mask for each character saying what charset(s) it may be found in */
-extern const unsigned long * const unicode_backtrans[];
-
-extern const unichar_t *const * const unicode_alternates[];
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h
index a5e21e87dc9..22e0a55a189 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/inc/ustring.h
@@ -105,7 +105,6 @@ extern char *utf8_2_latin1_copy(const char *utf8buf);
extern int utf8_strlen(const char *utf8_str); /* how many characters in the string */
extern int utf82u_strlen(const char *utf8_str); /* how many long would this be in shorts (UCS2) */
extern char *def2utf8_copy(const char *from);
-extern char *utf82def_copy(const char *ufrom);
extern char *utf8_strchr(const char *utf8_str, int search_char);
extern unichar_t *utf82u_strncpy(unichar_t *ubuf,const char *utf8buf,int len);
@@ -117,11 +116,8 @@ extern char *u2utf8_strcpy(char *utf8buf,const unichar_t *ubuf);
extern char *u2utf8_copy(const unichar_t *ubuf);
extern char *u2utf8_copyn(const unichar_t *ubuf,int len);
extern unichar_t *encoding2u_strncpy(unichar_t *uto, const char *from, int n, enum encoding cs);
-extern char *u2encoding_strncpy(char *to, const unichar_t *ufrom, int n, enum encoding cs);
extern unichar_t *def2u_strncpy(unichar_t *uto, const char *from, int n);
-extern char *u2def_strncpy(char *to, const unichar_t *ufrom, int n);
extern unichar_t *def2u_copy(const char *from);
-extern char *u2def_copy(const unichar_t *ufrom);
extern int u_sprintf(unichar_t *str, const unichar_t *format, ... );
extern int u_snprintf(unichar_t *str, int len, const unichar_t *format, ... );
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c
index 88757af288c..731eafe7430 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c
@@ -1,3 +1,21 @@
+/* ffdummies.c
+
+ Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
+
+ This file is part of LuaTeX.
+
+ LuaTeX is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ LuaTeX is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
/* some dummy functions and variables so that a few ff source files can be ignored */
@@ -9,154 +27,195 @@
#include <basics.h>
#include <ustring.h>
+static const char _svn_version[] =
+ "$Id: ffdummies.c 3360 2010-01-12 21:12:15Z hhenkel $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/luafontloader/src/ffdummies.c $";
+
char **gww_errors = NULL;
int gww_error_count = 0;
-void gwwv_errors_free (void) {
- int i;
- if (gww_error_count>0) {
- for (i=0;i<gww_error_count;i++) {
- free(gww_errors[i]);
- }
- free(gww_errors);
- gww_error_count = 0;
- gww_errors = NULL;
- }
+void gwwv_errors_free(void)
+{
+ int i;
+ if (gww_error_count > 0) {
+ for (i = 0; i < gww_error_count; i++) {
+ free(gww_errors[i]);
+ }
+ free(gww_errors);
+ gww_error_count = 0;
+ gww_errors = NULL;
+ }
}
-
-static void LUAUI_IError(const char *format,...) {
+__attribute__ ((format(printf, 1, 0)))
+static void LUAUI_IError(const char *format, ...)
+{
va_list ap;
- va_start(ap,format);
- fprintf(stderr, "Internal Error: " );
- vfprintf(stderr,format,ap);
+ size_t l;
+ char buffer[400], *str;
+ l = strlen("Internal Error: ");
+ snprintf(buffer, sizeof(buffer), "Internal Error: ");
+ va_start(ap, format);
+ vsnprintf(buffer+l, sizeof(buffer)-l, format, ap);
va_end(ap);
+ str = xstrdup((char *) buffer);
+ gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *));
+ if (gww_errors == NULL) {
+ perror("memory allocation failed");
+ exit(EXIT_FAILURE);
+ }
+ gww_errors[gww_error_count] = str;
+ gww_error_count++;
+ gww_errors[gww_error_count] = NULL;
}
-static void LUAUI__LogError(const char *format,va_list ap) {
+__attribute__ ((format(printf, 1, 0)))
+static void LUAUI__LogError(const char *format, va_list ap)
+{
char buffer[400], *str;
- vsnprintf(buffer,sizeof(buffer),format,ap);
- str = utf82def_copy(buffer);
- gww_errors = realloc(gww_errors, (gww_error_count+2)*sizeof(char *));
- if (gww_errors==NULL) {
- perror("memory allocation failed");
- exit(EXIT_FAILURE);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
+ str = xstrdup((char *) buffer);
+ gww_errors = realloc(gww_errors, (gww_error_count + 2) * sizeof(char *));
+ if (gww_errors == NULL) {
+ perror("memory allocation failed");
+ exit(EXIT_FAILURE);
}
- gww_errors[gww_error_count ] = str ;
- gww_error_count ++;
- gww_errors[gww_error_count ] = NULL;
+ gww_errors[gww_error_count] = str;
+ gww_error_count++;
+ gww_errors[gww_error_count] = NULL;
}
/* this is not static because it is used by gwwiconv.c */
-void LUAUI_LogError(const char *format,...) {
+__attribute__ ((format(printf, 1, 2)))
+void LUAUI_LogError(const char *format, ...)
+{
va_list ap;
- va_start(ap,format);
- LUAUI__LogError(format,ap);
+ va_start(ap, format);
+ LUAUI__LogError(format, ap);
va_end(ap);
}
-static void LUAUI_post_notice(const char *title,const char *statement,...) {
+__attribute__ ((format(printf, 2, 3)))
+static void LUAUI_post_notice(const char *title, const char *statement, ...)
+{
va_list ap;
- (void)title;
- va_start(ap,statement);
- LUAUI__LogError(statement,ap);
+ (void) title;
+ va_start(ap, statement);
+ LUAUI__LogError(statement, ap);
va_end(ap);
}
-static void LUAUI_post_error(const char *title,const char *statement,...) {
+__attribute__ ((format(printf, 2, 3)))
+static void LUAUI_post_error(const char *title, const char *statement, ...)
+{
va_list ap;
- (void)title;
- va_start(ap,statement);
- LUAUI__LogError(statement,ap);
+ (void) title;
+ va_start(ap, statement);
+ LUAUI__LogError(statement, ap);
va_end(ap);
}
static int LUAUI_ask(const char *title, const char **answers,
- int def, int cancel,const char *question,...) {
- (void)title;
- (void)answers;
- (void)cancel;
- (void)question;
-return( def );
+ int def, int cancel, const char *question, ...)
+{
+ (void) title;
+ (void) answers;
+ (void) cancel;
+ (void) question;
+ return (def);
}
-static int LUAUI_choose(const char *title, const char **choices,int cnt, int def,
- const char *question,...) {
- (void)title;
- (void)choices;
- (void)cnt;
- (void)question;
-return( def );
+static int LUAUI_choose(const char *title, const char **choices, int cnt,
+ int def, const char *question, ...)
+{
+ (void) title;
+ (void) choices;
+ (void) cnt;
+ (void) question;
+ return (def);
}
-static int LUAUI_choose_multiple(char *title, const char **choices,char *sel,
- int cnt, char *buts[2], const char *question,...) {
- (void)title;
- (void)choices;
- (void)sel;
- (void)cnt;
- (void)buts;
- (void)question;
-return( -1 );
+static int LUAUI_choose_multiple(char *title, const char **choices, char *sel,
+ int cnt, char *buts[2], const char *question,
+ ...)
+{
+ (void) title;
+ (void) choices;
+ (void) sel;
+ (void) cnt;
+ (void) buts;
+ (void) question;
+ return (-1);
}
static char *LUAUI_ask_string(const char *title, const char *def,
- const char *question,...) {
- (void)title;
- (void)def;
- (void)question;
-return( (char *) def );
+ const char *question, ...)
+{
+ (void) title;
+ (void) def;
+ (void) question;
+ return ((char *) def);
}
static char *LUAUI_open_file(const char *title, const char *defaultfile,
- const char *initial_filter) {
- (void)title;
- (void)initial_filter;
- (void)defaultfile;
-return( NULL );
+ const char *initial_filter)
+{
+ (void) title;
+ (void) initial_filter;
+ (void) defaultfile;
+ return (NULL);
}
static char *LUAUI_saveas_file(const char *title, const char *defaultfile,
- const char *initial_filter) {
- (void)title;
- (void)initial_filter;
-return( copy(defaultfile) );
+ const char *initial_filter)
+{
+ (void) title;
+ (void) initial_filter;
+ return (copy(defaultfile));
}
-static void LUAUI_progress_start(int delay, const char *title, const char *line1,
- const char *line2, int tot, int stages) {
- (void)delay;
- (void)title;
- (void)line1;
- (void)line2;
- (void)tot;
- (void)stages;
+static void LUAUI_progress_start(int delay, const char *title,
+ const char *line1, const char *line2, int tot,
+ int stages)
+{
+ (void) delay;
+ (void) title;
+ (void) line1;
+ (void) line2;
+ (void) tot;
+ (void) stages;
}
-static void LUAUI_void_void_noop(void) {
+static void LUAUI_void_void_noop(void)
+{
}
-static void LUAUI_void_int_noop(int useless) {
- (void)useless;
+static void LUAUI_void_int_noop(int useless)
+{
+ (void) useless;
}
-static int LUAUI_int_int_noop(int useless) {
- (void)useless;
-return( true );
+static int LUAUI_int_int_noop(int useless)
+{
+ (void) useless;
+ return (true);
}
-static void LUAUI_void_str_noop(const char * useless) {
- (void)useless;
+static void LUAUI_void_str_noop(const char *useless)
+{
+ (void) useless;
}
-static int LUAUI_alwaystrue(void) {
-return( true );
+static int LUAUI_alwaystrue(void)
+{
+ return (true);
}
-static int LUAUI_DefaultStrokeFlags(void) {
-return( sf_correctdir );
+static int LUAUI_DefaultStrokeFlags(void)
+{
+ return (sf_correctdir);
}
struct ui_interface luaui_interface = {
@@ -168,7 +227,7 @@ struct ui_interface luaui_interface = {
LUAUI_choose,
LUAUI_choose_multiple,
LUAUI_ask_string,
- LUAUI_ask_string, /* password */
+ LUAUI_ask_string, /* password */
LUAUI_open_file,
LUAUI_saveas_file,
@@ -197,60 +256,71 @@ struct ui_interface luaui_interface = {
/* some bits and pieces */
-int URLFromFile(char *url,FILE *from) {
- (void)url;
- (void)from;
- return false;
+int URLFromFile(char *url, FILE * from)
+{
+ (void) url;
+ (void) from;
+ return false;
}
/* print.c */
-int pagewidth = 0, pageheight=0; /* In points */
-char *printlazyprinter=NULL;
-char *printcommand=NULL;
+int pagewidth = 0, pageheight = 0; /* In points */
+char *printlazyprinter = NULL;
+char *printcommand = NULL;
int printtype = 0;
-void ScriptPrint(FontViewBase *fv,int type,int32 *pointsizes,char *samplefile,
- unichar_t *sample, char *outputfile) {
- (void)fv;
- (void)type;
- (void)pointsizes;
- (void)samplefile;
- (void)sample;
- (void)outputfile;
+void ScriptPrint(FontViewBase * fv, int type, int32 * pointsizes,
+ char *samplefile, unichar_t * sample, char *outputfile)
+{
+ (void) fv;
+ (void) type;
+ (void) pointsizes;
+ (void) samplefile;
+ (void) sample;
+ (void) outputfile;
}
-int PdfDumpGlyphResources(void *pi, SplineChar *sc) {
- (void)pi;
- (void)sc;
- return 0;
+int PdfDumpGlyphResources(void *pi, SplineChar * sc)
+{
+ (void) pi;
+ (void) sc;
+ return 0;
}
/* autotrace.c */
-int autotrace_ask=0, mf_ask=0, mf_clearbackgrounds=0, mf_showerrors=0;
+int autotrace_ask = 0, mf_ask = 0, mf_clearbackgrounds = 0, mf_showerrors = 0;
char *mf_args = NULL;
-int preferpotrace=0;
+int preferpotrace = 0;
-void *GetAutoTraceArgs(void) {
-return NULL;
+void *GetAutoTraceArgs(void)
+{
+ return NULL;
}
-void SetAutoTraceArgs(void *a) {
- (void)a;
+void SetAutoTraceArgs(void *a)
+{
+ (void) a;
}
-void FVAutoTrace(FontViewBase *fv,int ask) {
- (void)fv; (void)ask;
+void FVAutoTrace(FontViewBase * fv, int ask)
+{
+ (void) fv;
+ (void) ask;
}
-SplineFont *SFFromMF(char *filename) {
- (void)filename;
-return NULL;
+SplineFont *SFFromMF(char *filename)
+{
+ (void) filename;
+ return NULL;
}
/* http.c */
-FILE *URLToTempFile(char *url,void *_lock) {
- (void)_lock; (void)url;
- ff_post_error(_("Could not parse URL"),_("FontForge only handles ftp and http URLs at the moment"));
-return( NULL );
+FILE *URLToTempFile(char *url, void *_lock)
+{
+ (void) _lock;
+ (void) url;
+ ff_post_error(_("Could not parse URL"),
+ _("FontForge only handles ftp and http URLs at the moment"));
+ return (NULL);
}
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
index 8462ae9b2e5..8b7d2bd9415 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
@@ -1,5 +1,23 @@
+/* luafflib.c
+
+ Copyright 2007-2009 Taco Hoekwater <taco@luatex.org>
+
+ This file is part of LuaTeX.
+
+ LuaTeX is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ LuaTeX is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
+
/**
-* $Id $
* @desc Support interface for fontforge 20070607
* @version 1.0
* @author Taco Hoekwater
@@ -13,340 +31,362 @@
#include "pfaedit.h"
#include "ustring.h"
+static const char _svn_version[] =
+ "$Id: luafflib.c 3456 2010-03-07 09:12:36Z taco $ "
+ "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.60.0/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c $";
+
extern char **gww_errors;
extern int gww_error_count;
-extern void gwwv_errors_free (void);
+extern void gwwv_errors_free(void);
extern struct ui_interface luaui_interface;
-extern int readbinfile(FILE *f, unsigned char **b, int *s);
+extern int readbinfile(FILE * f, unsigned char **b, int *s);
#define FONT_METATABLE "fontloader.splinefont"
#define LUA_OTF_VERSION "0.3"
-static char *possub_type_enum[] = {
- "null", "position", "pair", "substitution",
- "alternate", "multiple", "ligature", "lcaret",
- "kerning", "vkerning", "anchors", "contextpos",
- "contextsub", "chainpos", "chainsub","reversesub",
- "max", "kernback", "vkernback", NULL };
+static char *possub_type_enum[] = {
+ "null", "position", "pair", "substitution",
+ "alternate", "multiple", "ligature", "lcaret",
+ "kerning", "vkerning", "anchors", "contextpos",
+ "contextsub", "chainpos", "chainsub", "reversesub",
+ "max", "kernback", "vkernback", NULL
+};
#define LAST_POSSUB_TYPE_ENUM 18
#define eight_nulls() NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-static char *asm_type_enum[] = {
- "indic", "context", "lig", NULL, "simple", "insert", NULL, NULL,
- eight_nulls(),
- NULL, "kern" };
-
-static char *otf_lookup_type_enum[] = {
- "gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate",
- "gsub_ligature", "gsub_context", "gsub_contextchain", NULL,
- "gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF*/
- "gpos_start", "gpos_single", "gpos_pair", "gpos_cursive",
- "gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context",
- "gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(),eight_nulls(),
- eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF*/
+static char *asm_type_enum[] = {
+ "indic", "context", "lig", NULL, "simple", "insert", NULL, NULL,
+ eight_nulls(),
+ NULL, "kern"
+};
+
+static char *otf_lookup_type_enum[] = {
+ "gsub_start", "gsub_single", "gsub_multiple", "gsub_alternate",
+ "gsub_ligature", "gsub_context", "gsub_contextchain", NULL,
+ "gsub_reversecontextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*0x00F */
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), NULL, NULL, NULL, NULL, NULL, "morx_indic", "morx_context", "morx_insert", /* 0x0FF */
+ "gpos_start", "gpos_single", "gpos_pair", "gpos_cursive",
+ "gpos_mark2base", "gpos_mark2ligature", "gpos_mark2mark", "gpos_context",
+ "gpos_contextchain", NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 0x10F */
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), eight_nulls(),
+ eight_nulls(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, "kern_statemachine", /* 0x1FF */
};
-static char *anchor_type_enum[] = {
- "mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL };
+static char *anchor_type_enum[] = {
+ "mark", "basechar", "baselig", "basemark", "centry", "cexit", "max", NULL
+};
#define MAX_ANCHOR_TYPE 7
-static char *anchorclass_type_enum[] = {
- "mark", "mkmk", "curs", "mklg", NULL };
+static char *anchorclass_type_enum[] = {
+ "mark", "mkmk", "curs", "mklg", NULL
+};
-static char *glyph_class_enum[] = {
- "automatic", "none" ,"base", "ligature","mark", "component", NULL };
+static char *glyph_class_enum[] = {
+ "automatic", "none", "base", "ligature", "mark", "component", NULL
+};
-static char *ttfnames_enum[ttf_namemax] = {
+static char *ttfnames_enum[ttf_namemax] = {
"copyright", "family", "subfamily", "uniqueid",
"fullname", "version", "postscriptname", "trademark",
"manufacturer", "designer", "descriptor", "venderurl",
"designerurl", "license", "licenseurl", "idontknow",
"preffamilyname", "prefmodifiers", "compatfull", "sampletext",
- "cidfindfontname", "wwsfamily", "wwssubfamily" };
+ "cidfindfontname", "wwsfamily", "wwssubfamily"
+};
-static char *fpossub_format_enum [] = {
- "glyphs", "class","coverage","reversecoverage" , NULL};
+static char *fpossub_format_enum[] = {
+ "glyphs", "class", "coverage", "reversecoverage", NULL
+};
-static char *tex_type_enum[4] = { "unset", "text", "math", "mathext"};
+static char *tex_type_enum[4] = { "unset", "text", "math", "mathext" };
/* has an offset of 1, ui_none = 0. */
static char *uni_interp_enum[9] = {
- "unset", "none", "adobe", "greek", "japanese",
- "trad_chinese", "simp_chinese", "korean", "ams" };
-
+ "unset", "none", "adobe", "greek", "japanese",
+ "trad_chinese", "simp_chinese", "korean", "ams"
+};
+
#define check_isfont(L,b) (SplineFont **)luaL_checkudata(L,b,FONT_METATABLE)
-void handle_generic_pst (lua_State *L, struct generic_pst *pst); /* forward */
-void handle_generic_fpst (lua_State *L, struct generic_fpst *fpst); /* forward */
-void handle_generic_asm (lua_State *L, struct generic_asm *sm) ;
-void handle_kernclass (lua_State *L, struct kernclass *kerns);
-void handle_anchorclass (lua_State *L, struct anchorclass *anchor);
-void handle_splinefont(lua_State *L, struct splinefont *sf) ;
+void handle_generic_pst(lua_State * L, struct generic_pst *pst); /* forward */
+void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst); /* forward */
+void handle_generic_asm(lua_State * L, struct generic_asm *sm);
+void handle_kernclass(lua_State * L, struct kernclass *kerns);
+void handle_anchorclass(lua_State * L, struct anchorclass *anchor);
+void handle_splinefont(lua_State * L, struct splinefont *sf);
+
+
+void lua_ff_pushfont(lua_State * L, SplineFont * sf)
+{
+ SplineFont **a;
+ if (sf == NULL) {
+ lua_pushnil(L);
+ } else {
+ a = lua_newuserdata(L, sizeof(SplineFont *));
+ *a = sf;
+ luaL_getmetatable(L, FONT_METATABLE);
+ lua_setmetatable(L, -2);
+ }
+ return;
+}
-void
-lua_ff_pushfont(lua_State *L, SplineFont *sf) {
- SplineFont **a;
- if (sf==NULL) {
- lua_pushnil(L);
- } else {
- a = lua_newuserdata(L,sizeof(SplineFont *));
- *a = sf;
- luaL_getmetatable(L,FONT_METATABLE);
- lua_setmetatable(L,-2);
- }
- return;
-}
-
-
-static int
-ff_open (lua_State *L) {
- SplineFont *sf;
- const char *fontname;
- FILE *l;
- char s[511];
- size_t len;
- int args,i ;
- int openflags = 1;
- fontname = luaL_checkstring(L,1);
- /* test fontname for existance */
- if ((l = fopen(fontname,"r"))) {
- fclose(l);
- } else {
- lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname);
- lua_error(L);
- }
- args = lua_gettop(L);
- if (args>=2 && lua_isstring(L,2)) {
- if (*(fontname+strlen(fontname))!=')') {
- /* possibly fails for embedded parens in the font name */
- snprintf(s,511,"%s(%s)", fontname, lua_tolstring(L,2,&len));
- if (len==0) {
- snprintf(s,511,"%s", fontname);
- }
- }
- } else {
- snprintf(s,511,"%s", fontname);
- }
- if (strlen(s)>0) {
- gww_error_count=0;
- sf = ReadSplineFont((char *)s,openflags);
- if (sf==NULL) {
- lua_pushfstring(L,"font loading failed for %s\n", s);
- if (gww_error_count>0) {
- for (i=0;i<gww_error_count;i++) {
- lua_pushstring(L,gww_errors[i]);
- lua_concat(L,2);
- }
- gwwv_errors_free();
- }
- lua_error(L);
- } else {
- FVAppend(_FontViewCreate(sf));
- lua_ff_pushfont(L,sf);
- if (gww_error_count>0) {
- lua_newtable(L);
- for (i=0;i<gww_error_count;i++) {
- lua_pushstring(L,gww_errors[i]);
- lua_rawseti(L,-2,(i+1));
- }
- gwwv_errors_free();
- } else {
- lua_pushnil(L);
- }
- }
- } else {
- lua_pushfstring(L,"font loading failed: empty string given\n", fontname);
- lua_error(L);
- }
- return 2;
-}
-
-
-static int
-ff_close (lua_State *L) {
- SplineFont **sf;
- /*fputs("ff_close called",stderr);*/
- sf = check_isfont(L,1);
- if (*sf!=NULL) {
- SplineFontFree(*sf);
- *sf = NULL;
- }
- return 0;
-}
-
-static int
-ff_apply_featurefile (lua_State *L) {
- SplineFont **sf;
- char *fname;
- sf = check_isfont(L,1);
- fname = (char *)luaL_checkstring(L,2);
- SFApplyFeatureFilename(*sf,fname);
- return 0;
-}
-
-static int
-ff_apply_afmfile (lua_State *L) {
- SplineFont **sf;
- char *fname;
- sf = check_isfont(L,1);
- fname = (char *)luaL_checkstring(L,2);
- CheckAfmOfPostscript(*sf,fname,(*sf)->map);
-
- return 0;
-}
-
-
-
-static void
-dump_intfield (lua_State *L, char *name, long int field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushnumber(L,field);
- lua_rawset(L,-3);
-}
-
-static void
-dump_realfield (lua_State *L, char *name, real field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushnumber(L,field);
- lua_rawset(L,-3);
+static int ff_open(lua_State * L)
+{
+ SplineFont *sf;
+ const char *fontname;
+ FILE *l;
+ char s[511];
+ size_t len;
+ int args, i;
+ int openflags = 1;
+ fontname = luaL_checkstring(L, 1);
+ /* test fontname for existance */
+ if ((l = fopen(fontname, "r"))) {
+ fclose(l);
+ } else {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed for %s (read error)\n",
+ fontname);
+ return 2;
+ }
+ args = lua_gettop(L);
+ if (args >= 2 && lua_isstring(L, 2)) {
+ if (*(fontname + strlen(fontname)) != ')') {
+ /* possibly fails for embedded parens in the font name */
+ snprintf(s, 511, "%s(%s)", fontname, lua_tolstring(L, 2, &len));
+ if (len == 0) {
+ snprintf(s, 511, "%s", fontname);
+ }
+ }
+ } else {
+ snprintf(s, 511, "%s", fontname);
+ }
+ if (strlen(s) > 0) {
+ gww_error_count = 0;
+ sf = ReadSplineFont((char *) s, openflags);
+ if (sf == NULL) {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed for %s\n", s);
+ if (gww_error_count > 0) {
+ for (i = 0; i < gww_error_count; i++) {
+ lua_pushstring(L, gww_errors[i]);
+ lua_concat(L, 2);
+ }
+ gwwv_errors_free();
+ }
+ } else {
+ FVAppend(_FontViewCreate(sf));
+ lua_ff_pushfont(L, sf);
+ if (gww_error_count > 0) {
+ lua_newtable(L);
+ for (i = 0; i < gww_error_count; i++) {
+ lua_pushstring(L, gww_errors[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ gwwv_errors_free();
+ } else {
+ lua_pushnil(L);
+ }
+ }
+ } else {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed: empty string given\n",
+ fontname);
+ }
+ return 2;
+}
+
+
+static int ff_close(lua_State * L)
+{
+ SplineFont **sf;
+ /*fputs("ff_close called",stderr); */
+ sf = check_isfont(L, 1);
+ if (*sf != NULL) {
+ if ((*sf)->fv) { // condition might be improved
+ FontViewClose((*sf)->fv);
+ } else {
+ EncMapFree((*sf)->map);
+ SplineFontFree(*sf);
+ }
+ *sf = NULL;
+ }
+ return 0;
+}
+
+static int ff_apply_featurefile(lua_State * L)
+{
+ SplineFont **sf;
+ char *fname;
+ sf = check_isfont(L, 1);
+ fname = (char *) luaL_checkstring(L, 2);
+ SFApplyFeatureFilename(*sf, fname);
+ return 0;
+}
+
+static int ff_apply_afmfile(lua_State * L)
+{
+ SplineFont **sf;
+ char *fname;
+ sf = check_isfont(L, 1);
+ fname = (char *) luaL_checkstring(L, 2);
+ CheckAfmOfPostscript(*sf, fname, (*sf)->map);
+
+ return 0;
+}
+
+
+
+static void dump_intfield(lua_State * L, char *name, long int field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushnumber(L, field);
+ lua_rawset(L, -3);
+}
+
+static void dump_realfield(lua_State * L, char *name, real field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushnumber(L, field);
+ lua_rawset(L, -3);
}
#define dump_cond_intfield(a,b,c) if ((c)!=0) { dump_intfield ((a),(b),(c)); }
-static void
-dump_stringfield (lua_State *L, char *name, char *field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushstring(L,field);
- lua_rawset(L,-3);
+static void dump_stringfield(lua_State * L, char *name, char *field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushstring(L, field);
+ lua_rawset(L, -3);
}
-static void
-dump_char_ref (lua_State *L, struct splinechar *spchar) {
- lua_checkstack(L,2);
- lua_pushstring(L,"char");
- lua_pushstring(L,spchar->name);
- lua_rawset(L,-3);
+static void dump_char_ref(lua_State * L, struct splinechar *spchar)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, "char");
+ lua_pushstring(L, spchar->name);
+ lua_rawset(L, -3);
}
-static void
-dump_lstringfield (lua_State *L, char *name, char *field, int len) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushlstring(L,field,len);
- lua_rawset(L,-3);
+static void dump_lstringfield(lua_State * L, char *name, char *field, int len)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushlstring(L, field, len);
+ lua_rawset(L, -3);
}
-static void
-dump_enumfield (lua_State *L, char *name, int fid, char **fields) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushstring(L,fields[fid]);
- lua_rawset(L,-3);
+static void dump_enumfield(lua_State * L, char *name, int fid, char **fields)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushstring(L, fields[fid]);
+ lua_rawset(L, -3);
}
-static void
-dump_floatfield (lua_State *L, char *name, double field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushnumber(L,field);
- lua_rawset(L,-3);
+static void dump_floatfield(lua_State * L, char *name, double field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushnumber(L, field);
+ lua_rawset(L, -3);
}
-static char tag_string [5] = {0};
+static char tag_string[5] = { 0 };
-static char *make_tag_string (unsigned int field) {
- tag_string[0] = (field&0xFF000000) >> 24;
- tag_string[1] = (field&0x00FF0000) >> 16;
- tag_string[2] = (field&0x0000FF00) >> 8;
- tag_string[3] = (field&0x000000FF);
- return (char *)tag_string;
+static char *make_tag_string(unsigned int field)
+{
+ tag_string[0] = (field & 0xFF000000) >> 24;
+ tag_string[1] = (field & 0x00FF0000) >> 16;
+ tag_string[2] = (field & 0x0000FF00) >> 8;
+ tag_string[3] = (field & 0x000000FF);
+ return (char *) tag_string;
}
-static char featbuf[32] = {0};
+static char featbuf[32] = { 0 };
-static char *make_mactag_string (unsigned int field) {
- sprintf( featbuf, "<%d,%d>", field>>16, field&0xffff );
- return (char *)featbuf;
+static char *make_mactag_string(unsigned int field)
+{
+ sprintf(featbuf, "<%d,%d>", field >> 16, field & 0xffff);
+ return (char *) featbuf;
}
-static void
-dump_tag (lua_State *L, char *name, unsigned int field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushlstring(L,make_tag_string(field),4);
- lua_rawset(L,-3);
+static void dump_tag(lua_State * L, char *name, unsigned int field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushlstring(L, make_tag_string(field), 4);
+ lua_rawset(L, -3);
}
-static void
-dump_mactag (lua_State *L, char *name, unsigned int field) {
- lua_checkstack(L,2);
- lua_pushstring(L,name);
- lua_pushstring(L,make_mactag_string(field));
- lua_rawset(L,-3);
+static void dump_mactag(lua_State * L, char *name, unsigned int field)
+{
+ lua_checkstack(L, 2);
+ lua_pushstring(L, name);
+ lua_pushstring(L, make_mactag_string(field));
+ lua_rawset(L, -3);
}
-void
-dump_subtable_name (lua_State *L, char *name, struct lookup_subtable *s) {
- /* this is likely a backref */
- if (s==NULL)
- return;
- lua_checkstack(L,2);
- if (s->next == NULL) {
- dump_stringfield(L,name,s->subtable_name);
- } else {
- /* can this really happen ? */
- int i = 0;
- lua_newtable(L);
- while (s!=NULL) {
- lua_pushstring(L, s->subtable_name);
- lua_rawseti(L, -2, ++i);
- s = s->next;
+void dump_subtable_name(lua_State * L, char *name, struct lookup_subtable *s)
+{
+ /* this is likely a backref */
+ if (s == NULL)
+ return;
+ lua_checkstack(L, 2);
+ if (s->next == NULL) {
+ dump_stringfield(L, name, s->subtable_name);
+ } else {
+ /* can this really happen ? */
+ int i = 0;
+ lua_newtable(L);
+ while (s != NULL) {
+ lua_pushstring(L, s->subtable_name);
+ lua_rawseti(L, -2, ++i);
+ s = s->next;
+ }
+ lua_setfield(L, -2, name);
}
- lua_setfield(L, -2, name);
- }
}
@@ -363,188 +403,221 @@ dump_subtable_name (lua_State *L, char *name, struct lookup_subtable *s) {
next = next->next; \
} }
-void
-do_handle_scriptlanglist (lua_State *L, struct scriptlanglist *sl) {
- int k;
- dump_tag(L,"script", sl->script);
-
- lua_checkstack(L,3);
- lua_newtable(L);
- for (k=0;k<MAX_LANG;k++) {
- if (sl->langs[k] != 0) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,make_tag_string(sl->langs[k]));
- lua_rawset(L,-3);
- }
- }
-
- if (sl->lang_cnt>=MAX_LANG) {
- for (k=MAX_LANG;k<sl->lang_cnt;k++) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,make_tag_string(sl->morelangs[k-MAX_LANG]));
- lua_rawset(L,-3);
- }
- }
- lua_setfield(L,-2,"langs");
-}
+#define NESTED_TABLE_SF(a,b,c,d) { \
+ int k = 1; \
+ next = b; \
+ while (next != NULL) { \
+ lua_checkstack(L,2); \
+ lua_pushnumber(L,k); k++; \
+ lua_createtable(L,0,d); \
+ a(L, next, c); \
+ lua_rawset(L,-3); \
+ next = next->next; \
+ } }
-void
-handle_scriptlanglist (lua_State *L, struct scriptlanglist *sll) {
- struct scriptlanglist *next;
- NESTED_TABLE(do_handle_scriptlanglist,sll,4);
+
+void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl)
+{
+ int k;
+ dump_tag(L, "script", sl->script);
+
+ lua_checkstack(L, 3);
+ lua_newtable(L);
+ for (k = 0; k < MAX_LANG; k++) {
+ if (sl->langs[k] != 0) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushstring(L, make_tag_string(sl->langs[k]));
+ lua_rawset(L, -3);
+ }
+ }
+
+ if (sl->lang_cnt >= MAX_LANG) {
+ for (k = MAX_LANG; k < sl->lang_cnt; k++) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushstring(L, make_tag_string(sl->morelangs[k - MAX_LANG]));
+ lua_rawset(L, -3);
+ }
+ }
+ lua_setfield(L, -2, "langs");
}
-void
-do_handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) {
- if (features->ismac) {
- dump_mactag (L,"tag",features->featuretag);
- } else {
- dump_tag (L,"tag",features->featuretag);
- }
- lua_newtable(L);
- handle_scriptlanglist(L, features->scripts);
- lua_setfield(L,-2,"scripts");
- dump_cond_intfield (L,"ismac",features->ismac);
-}
+void handle_scriptlanglist(lua_State * L, struct scriptlanglist *sll)
+{
+ struct scriptlanglist *next;
+ NESTED_TABLE(do_handle_scriptlanglist, sll, 4);
+}
void
-handle_featurescriptlanglist (lua_State *L, struct featurescriptlanglist *features) {
- struct featurescriptlanglist *next;
- NESTED_TABLE(do_handle_featurescriptlanglist,features,3);
+do_handle_featurescriptlanglist(lua_State * L,
+ struct featurescriptlanglist *features)
+{
+ if (features->ismac) {
+ dump_mactag(L, "tag", features->featuretag);
+ } else {
+ dump_tag(L, "tag", features->featuretag);
+ }
+ lua_newtable(L);
+ handle_scriptlanglist(L, features->scripts);
+ lua_setfield(L, -2, "scripts");
+ dump_cond_intfield(L, "ismac", features->ismac);
}
-void
-do_handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) {
+void
+handle_featurescriptlanglist(lua_State * L,
+ struct featurescriptlanglist *features)
+{
+ struct featurescriptlanglist *next;
+ NESTED_TABLE(do_handle_featurescriptlanglist, features, 3);
+}
- dump_stringfield(L,"name", subtable->subtable_name);
- dump_stringfield(L,"suffix", subtable->suffix);
+void do_handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable)
+{
- /* struct otlookup *lookup; */ /* this is the parent */
+ dump_stringfield(L, "name", subtable->subtable_name);
+ dump_stringfield(L, "suffix", subtable->suffix);
- /* dump_intfield (L,"unused", subtable->unused); */
- /* The next one is true if there is no fpst, false otherwise */
- /*
- dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern);
- */
- dump_cond_intfield (L,"anchor_classes", subtable->anchor_classes);
- dump_cond_intfield (L,"vertical_kerning", subtable->vertical_kerning);
+ /* struct otlookup *lookup; *//* this is the parent */
- if (subtable->kc != NULL) {
- lua_newtable(L);
- handle_kernclass(L, subtable->kc);
- lua_setfield(L,-2, "kernclass");
- }
+ /* dump_intfield (L,"unused", subtable->unused); */
+ /* The next one is true if there is no fpst, false otherwise */
+ /*
+ dump_intfield (L,"per_glyph_pst_or_kern",subtable->per_glyph_pst_or_kern);
+ */
+ dump_cond_intfield(L, "anchor_classes", subtable->anchor_classes);
+ dump_cond_intfield(L, "vertical_kerning", subtable->vertical_kerning);
+ if (subtable->kc != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, subtable->kc);
+ lua_setfield(L, -2, "kernclass");
+ }
#if 0
- if (subtable->fpst != NULL) {
- /* lua_newtable(L); */
- handle_generic_fpst(L, subtable->fpst);
- /* lua_setfield(L,-2, "fpst"); */
- }
+ if (subtable->fpst != NULL) {
+ /* lua_newtable(L); */
+ handle_generic_fpst(L, subtable->fpst);
+ /* lua_setfield(L,-2, "fpst"); */
+ }
#endif
- if (subtable->sm != NULL) {
- lua_newtable(L);
- handle_generic_asm(L, subtable->sm);
- lua_setfield(L,-2, "sm");
- }
- /* int subtable_offset; */ /* used by OTF file generation */
- /* int32 *extra_subtables; */ /* used by OTF file generation */
+ if (subtable->sm != NULL) {
+ lua_newtable(L);
+ handle_generic_asm(L, subtable->sm);
+ lua_setfield(L, -2, "sm");
+ }
+ /* int subtable_offset; *//* used by OTF file generation */
+ /* int32 *extra_subtables; *//* used by OTF file generation */
}
-void
-handle_lookup_subtable (lua_State *L, struct lookup_subtable *subtable) {
- struct lookup_subtable *next;
- NESTED_TABLE(do_handle_lookup_subtable,subtable,2);
+void handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable)
+{
+ struct lookup_subtable *next;
+ NESTED_TABLE(do_handle_lookup_subtable, subtable, 2);
}
-void
-do_handle_lookup (lua_State *L, struct otlookup *lookup ) {
+void do_handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf)
+{
+ int mc;
+
+ dump_enumfield(L, "type", lookup->lookup_type, otf_lookup_type_enum);
+
+ lua_newtable(L);
+ if (lookup->lookup_flags & pst_r2l) {
+ lua_pushstring(L, "r2l");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ if (lookup->lookup_flags & pst_ignorebaseglyphs) {
+ lua_pushstring(L, "ignorebaseglyphs");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ if (lookup->lookup_flags & pst_ignoreligatures) {
+ lua_pushstring(L, "ignoreligatures");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ if (lookup->lookup_flags & pst_ignorecombiningmarks) {
+ lua_pushstring(L, "ignorecombiningmarks");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ mc = (lookup->lookup_flags >> 8);
+ if (mc > 0 && mc < sf->mark_class_cnt && sf->mark_class_names[mc] != NULL) {
+ lua_pushstring(L, "mark_class");
+ lua_pushstring(L, sf->mark_class_names[mc]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "flags");
- dump_enumfield (L,"type", lookup->lookup_type, otf_lookup_type_enum);
- lua_newtable(L);
- if (lookup->lookup_flags & pst_r2l) {
- lua_pushstring(L,"r2l"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- if (lookup->lookup_flags & pst_ignorebaseglyphs) {
- lua_pushstring(L,"ignorebaseglyphs"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- if (lookup->lookup_flags & pst_ignoreligatures) {
- lua_pushstring(L,"ignoreligatures"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- if (lookup->lookup_flags & pst_ignorecombiningmarks) {
- lua_pushstring(L,"ignorecombiningmarks"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"flags");
+ dump_stringfield(L, "name", lookup->lookup_name);
- dump_stringfield (L,"name", lookup->lookup_name);
+ if (lookup->features != NULL) {
+ lua_newtable(L);
+ handle_featurescriptlanglist(L, lookup->features);
+ lua_setfield(L, -2, "features");
+ }
- if (lookup->features != NULL) {
- lua_newtable(L);
- handle_featurescriptlanglist(L,lookup->features);
- lua_setfield(L,-2,"features");
- }
+ if (lookup->subtables != NULL) {
+ lua_newtable(L);
+ handle_lookup_subtable(L, lookup->subtables);
+ lua_setfield(L, -2, "subtables");
+ }
- if (lookup->subtables != NULL) {
- lua_newtable(L);
- handle_lookup_subtable(L,lookup->subtables);
- lua_setfield(L,-2,"subtables");
- }
-
- /* dump_intfield (L,"unused", lookup->unused); */
- /* dump_intfield (L,"empty", lookup->empty); */
- /* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */
- /* dump_intfield (L,"needs_extension", lookup->needs_extension); */
- /* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */
- /* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */
- /* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */
- /* dump_intfield (L,"ticked", lookup->ticked); */
- /* dump_intfield (L,"subcnt", lookup->subcnt); */
- /* dump_intfield (L,"lookup_index", lookup->lookup_index); */ /* identical to array index */
- /* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */
- /* dump_intfield (L,"lookup_length", lookup->lookup_length); */
- /* dump_stringfield(L,"tempname", lookup->tempname); */
+ /* dump_intfield (L,"unused", lookup->unused); */
+ /* dump_intfield (L,"empty", lookup->empty); */
+ /* dump_intfield (L,"store_in_afm", lookup->store_in_afm); */
+ /* dump_intfield (L,"needs_extension", lookup->needs_extension); */
+ /* dump_intfield (L,"temporary_kern", lookup->temporary_kern); */
+ /* dump_intfield (L,"def_lang_checked", lookup->def_lang_checked); */
+ /* dump_intfield (L,"def_lang_found", lookup->def_lang_found); */
+ /* dump_intfield (L,"ticked", lookup->ticked); */
+ /* dump_intfield (L,"subcnt", lookup->subcnt); */
+ /* dump_intfield (L,"lookup_index", lookup->lookup_index); *//* identical to array index */
+ /* dump_intfield (L,"lookup_offset", lookup->lookup_offset); */
+ /* dump_intfield (L,"lookup_length", lookup->lookup_length); */
+ /* dump_stringfield(L,"tempname", lookup->tempname); */
}
-void
-handle_lookup (lua_State *L, struct otlookup *lookup ) {
- struct otlookup *next;
- NESTED_TABLE(do_handle_lookup,lookup,18); /* 18 is a guess */
+void handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont * sf)
+{
+ struct otlookup *next;
+ NESTED_TABLE_SF(do_handle_lookup, lookup, sf, 18); /* 18 is a guess */
}
-void
-do_handle_kernpair (lua_State *L, struct kernpair *kp) {
+void do_handle_kernpair(lua_State * L, struct kernpair *kp)
+{
- if (kp->sc != NULL)
- dump_char_ref(L, kp->sc);
- dump_intfield(L,"off", kp->off);
- /* uint16 kcid; */ /* temporary value */
- dump_subtable_name(L, "lookup", kp->subtable);
+ if (kp->sc != NULL)
+ dump_char_ref(L, kp->sc);
+ dump_intfield(L, "off", kp->off);
+ /* uint16 kcid; *//* temporary value */
+ dump_subtable_name(L, "lookup", kp->subtable);
}
-void
-handle_kernpair (lua_State *L, struct kernpair *kp) {
- struct kernpair *next;
- NESTED_TABLE(do_handle_kernpair,kp,4);
+void handle_kernpair(lua_State * L, struct kernpair *kp)
+{
+ struct kernpair *next;
+ NESTED_TABLE(do_handle_kernpair, kp, 4);
}
-void
-handle_splinecharlist (lua_State *L, struct splinecharlist *scl) {
+void handle_splinecharlist(lua_State * L, struct splinecharlist *scl)
+{
- struct splinecharlist *next = scl;
- int k = 1;
- lua_checkstack(L,10);
- while( next != NULL) {
- if (next->sc != NULL) {
- lua_pushnumber(L,k); k++;
- lua_pushstring(L,next->sc->name);
- lua_rawset(L,-3);
+ struct splinecharlist *next = scl;
+ int k = 1;
+ lua_checkstack(L, 10);
+ while (next != NULL) {
+ if (next->sc != NULL) {
+ lua_pushnumber(L, k);
+ k++;
+ lua_pushstring(L, next->sc->name);
+ lua_rawset(L, -3);
+ }
+ next = next->next;
}
- next = next->next;
- }
}
@@ -556,750 +629,801 @@ handle_splinecharlist (lua_State *L, struct splinecharlist *scl) {
/* variant shape. The specifics depend on the selector and script */
/* fid is currently unused, but may, someday, be used to do ttcs */
/* NOTE: GlyphInfo displays vs==-1 as vs==0, and fixes things up */
-void
-handle_altuni (lua_State *L, struct altuni *au) {
- struct altuni *next = au;
- int k = 1;
- lua_checkstack(L,3);
- while( next != NULL) {
- lua_newtable(L);
- dump_intfield(L, "unicode", next->unienc);
- if (next->vs != -1)
- dump_intfield(L, "variant", next->vs);
- /* dump_intfield(L, "fid", next->fid); */
- lua_rawseti(L, -2, k++);
- next = next->next;
- }
+void handle_altuni(lua_State * L, struct altuni *au)
+{
+ struct altuni *next = au;
+ int k = 1;
+ lua_checkstack(L, 3);
+ while (next != NULL) {
+ lua_newtable(L);
+ dump_intfield(L, "unicode", next->unienc);
+ if (next->vs != -1)
+ dump_intfield(L, "variant", next->vs);
+ /* dump_intfield(L, "fid", next->fid); */
+ lua_rawseti(L, -2, k++);
+ next = next->next;
+ }
}
#define interesting_vr(a) (((a)->xoff!=0) || ((a)->yoff!=0) || ((a)->h_adv_off!=0) || ((a)->v_adv_off!=0))
-void handle_vr (lua_State *L, struct vr *pos) {
+void handle_vr(lua_State * L, struct vr *pos)
+{
- dump_cond_intfield(L,"x", pos->xoff);
- dump_cond_intfield(L,"y", pos->yoff);
- dump_cond_intfield(L,"h", pos->h_adv_off);
- dump_cond_intfield(L,"v", pos->v_adv_off);
+ dump_cond_intfield(L, "x", pos->xoff);
+ dump_cond_intfield(L, "y", pos->yoff);
+ dump_cond_intfield(L, "h", pos->h_adv_off);
+ dump_cond_intfield(L, "v", pos->v_adv_off);
}
-void
-do_handle_generic_pst (lua_State *L, struct generic_pst *pst) {
- int k;
- if (pst->type>LAST_POSSUB_TYPE_ENUM) {
- dump_tag(L,"type", pst->type);
- } else {
- dump_enumfield(L,"type", pst->type, possub_type_enum);
- }
- /* unsigned int ticked: 1;*/
- /* unsigned int temporary: 1;*/ /* Used in afm ligature closure */
- /* struct lookup_subtable *subtable; */ /* handled by caller */
-
- lua_checkstack(L,4);
- lua_pushstring(L,"specification");
- lua_createtable(L,0,4);
- if (pst->type == pst_position) {
- handle_vr (L, &pst->u.pos);
- } else if (pst->type == pst_pair) {
- dump_stringfield(L,"paired",pst->u.pair.paired);
- if (pst->u.pair.vr != NULL) {
- lua_pushstring(L,"offsets");
- lua_createtable(L,2,0);
- if (interesting_vr(pst->u.pair.vr)) {
- lua_createtable(L,0,4);
- handle_vr (L, pst->u.pair.vr);
- lua_rawseti(L,-2,1);
- }
- if (interesting_vr(pst->u.pair.vr+1)) {
- lua_createtable(L,0,4);
- handle_vr (L, pst->u.pair.vr+1);
- lua_rawseti(L,-2,2);
- }
- lua_rawset(L,-3);
- }
- } else if (pst->type == pst_substitution) {
- dump_stringfield(L,"variant",pst->u.subs.variant);
- } else if (pst->type == pst_alternate) {
- dump_stringfield(L,"components",pst->u.mult.components);
- } else if (pst->type == pst_multiple) {
- dump_stringfield(L,"components",pst->u.alt.components);
- } else if (pst->type == pst_ligature) {
- dump_stringfield(L,"components",pst->u.lig.components);
- if (pst->u.lig.lig != NULL) {
- dump_char_ref(L,pst->u.lig.lig);
- }
- } else if (pst->type == pst_lcaret) {
- for (k=0;k<pst->u.lcaret.cnt;k++) {
- lua_pushnumber(L,(k+1));
- lua_pushnumber(L,pst->u.lcaret.carets[k]);
- lua_rawset(L,-3);
- }
- }
- lua_rawset(L,-3);
+void do_handle_generic_pst(lua_State * L, struct generic_pst *pst)
+{
+ int k;
+ if (pst->type > LAST_POSSUB_TYPE_ENUM) {
+ dump_tag(L, "type", pst->type);
+ } else {
+ dump_enumfield(L, "type", pst->type, possub_type_enum);
+ }
+ /* unsigned int ticked: 1; */
+ /* unsigned int temporary: 1; *//* Used in afm ligature closure */
+ /* struct lookup_subtable *subtable; *//* handled by caller */
+
+ lua_checkstack(L, 4);
+ lua_pushstring(L, "specification");
+ lua_createtable(L, 0, 4);
+ if (pst->type == pst_position) {
+ handle_vr(L, &pst->u.pos);
+ } else if (pst->type == pst_pair) {
+ dump_stringfield(L, "paired", pst->u.pair.paired);
+ if (pst->u.pair.vr != NULL) {
+ lua_pushstring(L, "offsets");
+ lua_createtable(L, 2, 0);
+ if (interesting_vr(pst->u.pair.vr)) {
+ lua_createtable(L, 0, 4);
+ handle_vr(L, pst->u.pair.vr);
+ lua_rawseti(L, -2, 1);
+ }
+ if (interesting_vr(pst->u.pair.vr + 1)) {
+ lua_createtable(L, 0, 4);
+ handle_vr(L, pst->u.pair.vr + 1);
+ lua_rawseti(L, -2, 2);
+ }
+ lua_rawset(L, -3);
+ }
+ } else if (pst->type == pst_substitution) {
+ dump_stringfield(L, "variant", pst->u.subs.variant);
+ } else if (pst->type == pst_alternate) {
+ dump_stringfield(L, "components", pst->u.mult.components);
+ } else if (pst->type == pst_multiple) {
+ dump_stringfield(L, "components", pst->u.alt.components);
+ } else if (pst->type == pst_ligature) {
+ dump_stringfield(L, "components", pst->u.lig.components);
+ if (pst->u.lig.lig != NULL) {
+ dump_char_ref(L, pst->u.lig.lig);
+ }
+ } else if (pst->type == pst_lcaret) {
+ for (k = 0; k < pst->u.lcaret.cnt; k++) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushnumber(L, pst->u.lcaret.carets[k]);
+ lua_rawset(L, -3);
+ }
+ }
+ lua_rawset(L, -3);
}
-void
-handle_generic_pst (lua_State *L, struct generic_pst *pst) {
- struct generic_pst *next;
- int k;
- int l = 1;
- next = pst;
- /* most likely everything arrives in proper order. But to prevent
- * surprises, better do this is the proper way
- */
- while (next != NULL) {
- if (next->subtable !=NULL &&
- next->subtable->subtable_name !=NULL) {
- lua_checkstack(L,3); /* just in case */
- lua_getfield(L,-1,next->subtable->subtable_name);
- if (!lua_istable(L,-1)) {
- lua_pop(L,1);
- lua_newtable(L);
- lua_setfield(L,-2,next->subtable->subtable_name);
- lua_getfield(L,-1,next->subtable->subtable_name);
- }
- k = lua_objlen(L,-1) + 1;
- lua_pushnumber(L,k);
- lua_createtable(L,0,4);
- do_handle_generic_pst(L, next);
- lua_rawset(L,-3);
- next = next->next;
- lua_pop(L,1); /* pop the subtable */
- } else {
- /* Found a pst without subtable, or without subtable name */
- lua_pushnumber(L,l); l++;
- lua_createtable(L,0,4);
- do_handle_generic_pst(L, next);
- lua_rawset(L,-3);
- next = next->next;
- }
- }
+void handle_generic_pst(lua_State * L, struct generic_pst *pst)
+{
+ struct generic_pst *next;
+ int k;
+ int l = 1;
+ next = pst;
+ /* most likely everything arrives in proper order. But to prevent
+ * surprises, better do this is the proper way
+ */
+ while (next != NULL) {
+ if (next->subtable != NULL && next->subtable->subtable_name != NULL) {
+ lua_checkstack(L, 3); /* just in case */
+ lua_getfield(L, -1, next->subtable->subtable_name);
+ if (!lua_istable(L, -1)) {
+ lua_pop(L, 1);
+ lua_newtable(L);
+ lua_setfield(L, -2, next->subtable->subtable_name);
+ lua_getfield(L, -1, next->subtable->subtable_name);
+ }
+ k = lua_objlen(L, -1) + 1;
+ lua_pushnumber(L, k);
+ lua_createtable(L, 0, 4);
+ do_handle_generic_pst(L, next);
+ lua_rawset(L, -3);
+ next = next->next;
+ lua_pop(L, 1); /* pop the subtable */
+ } else {
+ /* Found a pst without subtable, or without subtable name */
+ lua_pushnumber(L, l);
+ l++;
+ lua_createtable(L, 0, 4);
+ do_handle_generic_pst(L, next);
+ lua_rawset(L, -3);
+ next = next->next;
+ }
+ }
}
-void
-do_handle_liglist (lua_State *L, struct liglist *ligofme) {
- lua_checkstack(L,2);
- if(ligofme->lig != NULL) {
- lua_createtable(L,0,6);
- handle_generic_pst (L,ligofme->lig);
- lua_setfield(L,-2,"lig");
- }
- dump_char_ref(L,ligofme->first);
- if (ligofme->components != NULL) {
- lua_newtable(L);
- handle_splinecharlist (L,ligofme->components);
- lua_setfield(L,-2,"components");
- }
- dump_intfield(L,"ccnt",ligofme->ccnt);
+void do_handle_liglist(lua_State * L, struct liglist *ligofme)
+{
+ lua_checkstack(L, 2);
+ if (ligofme->lig != NULL) {
+ lua_createtable(L, 0, 6);
+ handle_generic_pst(L, ligofme->lig);
+ lua_setfield(L, -2, "lig");
+ }
+ dump_char_ref(L, ligofme->first);
+ if (ligofme->components != NULL) {
+ lua_newtable(L);
+ handle_splinecharlist(L, ligofme->components);
+ lua_setfield(L, -2, "components");
+ }
+ dump_intfield(L, "ccnt", ligofme->ccnt);
}
-void
-handle_liglist (lua_State *L, struct liglist *ligofme) {
- struct liglist *next;
- NESTED_TABLE(do_handle_liglist,ligofme,3);
+void handle_liglist(lua_State * L, struct liglist *ligofme)
+{
+ struct liglist *next;
+ NESTED_TABLE(do_handle_liglist, ligofme, 3);
}
-void
-do_handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) {
+void do_handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
+{
- if (anchor->anchor==NULL) {
- return;
- }
- if (anchor->type>=0 && anchor->type <= MAX_ANCHOR_TYPE ) {
- lua_pushstring(L,anchor_type_enum[anchor->type]);
- } else {
- lua_pushstring(L,"Anchorpoint has an unknown type!");
- lua_error(L);
- }
- /* unsigned int selected: 1; */
- /* unsigned int ticked: 1; */
-
- lua_rawget(L,-2);
- if (!lua_istable(L,-1)) {
- /* create the table first */
- lua_pop(L,1);
- lua_pushstring(L,anchor_type_enum[anchor->type]);
- lua_pushvalue(L,-1);
- lua_newtable(L);
- lua_rawset(L,-4);
- lua_rawget(L,-2);
- }
- /* now the 'type' table is top of stack */
- if (anchor->type==at_baselig) {
- lua_pushstring(L,anchor->anchor->name);
- lua_rawget(L,-2);
- if (!lua_istable(L,-1)) {
- /* create the table first */
- lua_pop(L,1);
- lua_pushstring(L,anchor->anchor->name);
- lua_pushvalue(L,-1);
- lua_newtable(L);
- lua_rawset(L,-4);
- lua_rawget(L,-2);
+ if (anchor->anchor == NULL) {
+ return;
}
- lua_newtable(L);
- dump_intfield(L,"x", anchor->me.x);
- dump_intfield(L,"y", anchor->me.y);
- if (anchor->has_ttf_pt)
- dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index);
- dump_intfield(L,"lig_index", anchor->lig_index);
- lua_rawseti(L,-2,(anchor->lig_index+1));
- lua_pop(L,1);
- } else {
- lua_pushstring(L,anchor->anchor->name);
- lua_newtable(L);
- dump_intfield(L,"x", anchor->me.x);
- dump_intfield(L,"y", anchor->me.y);
- if (anchor->has_ttf_pt)
- dump_intfield(L,"ttf_pt_index", anchor->ttf_pt_index);
- dump_intfield(L,"lig_index", anchor->lig_index);
- lua_rawset(L,-3);
- }
- lua_pop(L,1);
+ if (anchor->type >= 0 && anchor->type <= MAX_ANCHOR_TYPE) {
+ lua_pushstring(L, anchor_type_enum[anchor->type]);
+ } else {
+ lua_pushstring(L, "Anchorpoint has an unknown type!");
+ lua_error(L);
+ }
+ /* unsigned int selected: 1; */
+ /* unsigned int ticked: 1; */
+
+ lua_rawget(L, -2);
+ if (!lua_istable(L, -1)) {
+ /* create the table first */
+ lua_pop(L, 1);
+ lua_pushstring(L, anchor_type_enum[anchor->type]);
+ lua_pushvalue(L, -1);
+ lua_newtable(L);
+ lua_rawset(L, -4);
+ lua_rawget(L, -2);
+ }
+ /* now the 'type' table is top of stack */
+ if (anchor->type == at_baselig) {
+ lua_pushstring(L, anchor->anchor->name);
+ lua_rawget(L, -2);
+ if (!lua_istable(L, -1)) {
+ /* create the table first */
+ lua_pop(L, 1);
+ lua_pushstring(L, anchor->anchor->name);
+ lua_pushvalue(L, -1);
+ lua_newtable(L);
+ lua_rawset(L, -4);
+ lua_rawget(L, -2);
+ }
+ lua_newtable(L);
+ dump_intfield(L, "x", anchor->me.x);
+ dump_intfield(L, "y", anchor->me.y);
+ if (anchor->has_ttf_pt)
+ dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index);
+ dump_intfield(L, "lig_index", anchor->lig_index);
+ lua_rawseti(L, -2, (anchor->lig_index + 1));
+ lua_pop(L, 1);
+ } else {
+ lua_pushstring(L, anchor->anchor->name);
+ lua_newtable(L);
+ dump_intfield(L, "x", anchor->me.x);
+ dump_intfield(L, "y", anchor->me.y);
+ if (anchor->has_ttf_pt)
+ dump_intfield(L, "ttf_pt_index", anchor->ttf_pt_index);
+ dump_intfield(L, "lig_index", anchor->lig_index);
+ lua_rawset(L, -3);
+ }
+ lua_pop(L, 1);
}
-void
-handle_anchorpoint (lua_State *L, struct anchorpoint *anchor) {
- struct anchorpoint *next;
- next = anchor;
- while (next != NULL) {
- do_handle_anchorpoint(L, next);
- next = next->next;
- }
+void handle_anchorpoint(lua_State * L, struct anchorpoint *anchor)
+{
+ struct anchorpoint *next;
+ next = anchor;
+ while (next != NULL) {
+ do_handle_anchorpoint(L, next);
+ next = next->next;
+ }
}
-void
-handle_glyphvariants (lua_State *L, struct glyphvariants *vars) {
- int i ;
- dump_stringfield(L, "variants", vars->variants);
- dump_intfield (L, "italic_correction", vars->italic_correction);
- lua_newtable(L);
- for (i=0; i< vars->part_cnt; i++) {
- lua_newtable(L);
- dump_stringfield(L, "component", vars->parts[i].component);
- dump_intfield(L, "extender", vars->parts[i].is_extender);
- dump_intfield(L, "start", vars->parts[i].startConnectorLength);
- dump_intfield(L, "end", vars->parts[i].endConnectorLength);
- dump_intfield(L, "advance", vars->parts[i].fullAdvance);
- lua_rawseti(L,-2,(i+1));
- }
- lua_setfield(L, -2, "parts");
-}
-
-void handle_mathkernvertex (lua_State *L, struct mathkernvertex *mkv) {
- int i;
- for (i=0; i<mkv->cnt;i++) {
- lua_newtable(L);
- dump_intfield(L, "height", mkv->mkd[i].height );
- dump_intfield(L, "kern", mkv->mkd[i].kern );
- lua_rawseti(L,-2, (i+1));
- }
-}
-
-void handle_mathkern (lua_State *L, struct mathkern *mk) {
- lua_newtable(L);
- handle_mathkernvertex(L, &(mk->top_right));
- lua_setfield(L, -2, "top_right");
- lua_newtable(L);
- handle_mathkernvertex(L, &(mk->top_left));
- lua_setfield(L, -2, "top_left");
- lua_newtable(L);
- handle_mathkernvertex(L, &(mk->bottom_right));
- lua_setfield(L, -2, "bottom_right");
- lua_newtable(L);
- handle_mathkernvertex(L, &(mk->bottom_left));
- lua_setfield(L, -2, "bottom_left");
-}
-
-
-
-void
-handle_splinechar (lua_State *L,struct splinechar *glyph, int hasvmetrics) {
- DBounds bb;
- if (glyph->xmax==0 && glyph->ymax==0 && glyph->xmin==0 && glyph->ymin==0) {
- SplineCharFindBounds(glyph,&bb);
- glyph->xmin = bb.minx;
- glyph->ymin = bb.miny;
- glyph->xmax = bb.maxx;
- glyph->ymax = bb.maxy;
- }
- dump_stringfield(L,"name", glyph->name);
- dump_intfield(L,"unicode", glyph->unicodeenc);
- lua_createtable(L,4,0);
- lua_pushnumber(L,1); lua_pushnumber(L,glyph->xmin); lua_rawset(L,-3);
- lua_pushnumber(L,2); lua_pushnumber(L,glyph->ymin); lua_rawset(L,-3);
- lua_pushnumber(L,3); lua_pushnumber(L,glyph->xmax); lua_rawset(L,-3);
- lua_pushnumber(L,4); lua_pushnumber(L,glyph->ymax); lua_rawset(L,-3);
- lua_setfield(L,-2,"boundingbox");
- /*dump_intfield(L,"orig_pos", glyph->orig_pos);*/
- if (hasvmetrics)
- dump_intfield(L,"vwidth", glyph->vwidth);
- dump_intfield(L,"width", glyph->width);
-
- if (glyph->lsidebearing != glyph->xmin) {
- dump_cond_intfield(L,"lsidebearing", glyph->lsidebearing);
- }
- /* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */
-
- /* Layer layers[2]; */ /* TH Not used */
- /* int layer_cnt; */ /* TH Not used */
- /* StemInfo *hstem; */ /* TH Not used */
- /* StemInfo *vstem; */ /* TH Not used */
- /* DStemInfo *dstem; */ /* TH Not used */
-
- /* MinimumDistance *md; */ /* TH Not used */
- /* struct charviewbase *views; */ /* TH Not used */
- /* struct charinfo *charinfo; */ /* TH ? (charinfo.c) */
- /* struct splinefont *parent; */ /* TH Not used */
-
- if (glyph->glyph_class>0) {
- dump_enumfield(L,"class", glyph->glyph_class, glyph_class_enum);
- }
- /* TH: internal fontforge stuff
- dump_intfield(L,"changed", glyph->changed);
- dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted);
- dump_intfield(L,"manualhints", glyph->manualhints);
- dump_intfield(L,"ticked", glyph->ticked);
- dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave);
- dump_intfield(L,"widthset", glyph->widthset);
- dump_intfield(L,"vconflicts", glyph->vconflicts);
- dump_intfield(L,"hconflicts", glyph->hconflicts);
- dump_intfield(L,"searcherdummy", glyph->searcherdummy);
- dump_intfield(L,"changed_since_search", glyph->changed_since_search);
- dump_intfield(L,"wasopen", glyph->wasopen);
- dump_intfield(L,"namechanged", glyph->namechanged);
- dump_intfield(L,"blended", glyph->blended);
- dump_intfield(L,"ticked2", glyph->ticked2);
- dump_intfield(L,"unused_so_far", glyph->unused_so_far);
- dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards);
- dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date);
- dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums);
- unsigned int vs_open: 1;
- unsigned int unlink_rm_ovrlp_save_undo: 1;
- unsigned int inspiro: 1;
- unsigned int lig_caret_cnt_fixed: 1;
-
-
- uint8 *ttf_instrs;
- int16 ttf_instrs_len;
- int16 countermask_cnt;
- HintMask *countermasks;
- */
-
- if (glyph->kerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L,glyph->kerns);
- lua_setfield(L,-2,"kerns");
- }
- if (glyph->vkerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L,glyph->vkerns);
- lua_setfield(L,-2,"vkerns");
- }
-
- if (glyph->dependents != NULL) {
- lua_newtable(L);
- handle_splinecharlist(L,glyph->dependents);
- lua_setfield(L,-2,"dependents");
-
- }
- if (glyph->possub != NULL) {
- lua_newtable(L);
- handle_generic_pst(L,glyph->possub);
- lua_setfield(L,-2,"lookups");
- }
-
- if (glyph->ligofme != NULL) {
- lua_newtable(L);
- handle_liglist(L,glyph->ligofme);
- lua_setfield(L,-2,"ligatures");
- }
-
- if (glyph->comment != NULL)
- dump_stringfield(L,"comment", glyph->comment);
-
- /* Color color; */ /* dont care */
-
- if (glyph->anchor != NULL) {
- lua_newtable(L);
- handle_anchorpoint(L,glyph->anchor);
- lua_setfield(L,-2,"anchors");
- }
-
- if (glyph->altuni != NULL) {
- lua_newtable(L);
- handle_altuni(L, glyph->altuni);
- lua_setfield(L,-2,"altuni");
- }
-
- if (glyph->tex_height != TEX_UNDEF)
- dump_intfield(L,"tex_height", glyph->tex_height);
- if (glyph->tex_depth != TEX_UNDEF)
- dump_intfield(L,"tex_depth", glyph->tex_depth);
-
- dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape);
- if (glyph->italic_correction != TEX_UNDEF)
- dump_intfield(L, "italic_correction", glyph->italic_correction);
- if (glyph->top_accent_horiz != TEX_UNDEF)
- dump_intfield(L, "top_accent", glyph->top_accent_horiz);
-
- if (glyph->vert_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->vert_variants);
- lua_setfield(L,-2,"vert_variants");
- }
- if (glyph->horiz_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->horiz_variants);
- lua_setfield(L,-2,"horiz_variants");
- }
- if (glyph->mathkern != NULL) {
+void handle_glyphvariants(lua_State * L, struct glyphvariants *vars)
+{
+ int i;
+ dump_stringfield(L, "variants", vars->variants);
+ dump_intfield(L, "italic_correction", vars->italic_correction);
lua_newtable(L);
- handle_mathkern(L, glyph->mathkern);
- lua_setfield(L,-2,"mathkern");
- }
-}
-
-char *panose_values_0[] = { "Any", "No Fit", "Text and Display", "Script", "Decorative", "Pictorial" };
-
-char *panose_values_1[] = { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove", "Obtuse Square Cove",
- "Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans",
- "Obtuse Sans", "Perp Sans", "Flared", "Rounded" } ;
-
-char *panose_values_2[] = { "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
- "Medium", "Demi", "Bold", "Heavy", "Black", "Nord" } ;
-
-char *panose_values_3[] = { "Any", "No Fit", "Old Style", "Modern", "Even Width",
- "Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced" };
-
-char *panose_values_4[] = { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
- "Medium", "Medium High", "High", "Very High" };
-
-char *panose_values_5[] = { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional","Gradual/Vertical",
- "Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal", "Instant/Vertical" };
-
-char *panose_values_6[] = {"Any","No Fit","Straight Arms/Horizontal","Straight Arms/Wedge","Straight Arms/Vertical",
- "Straight Arms/Single Serif","Straight Arms/Double Serif","Non-Straight Arms/Horizontal",
- "Non-Straight Arms/Wedge","Non-Straight Arms/Vertical","Non-Straight Arms/Single Serif",
- "Non-Straight Arms/Double Serif" };
-
-char *panose_values_7[] = { "Any", "No Fit","Normal/Contact","Normal/Weighted","Normal/Boxed","Normal/Flattened",
- "Normal/Rounded","Normal/Off Center","Normal/Square","Oblique/Contact","Oblique/Weighted",
- "Oblique/Boxed","Oblique/Flattened","Oblique/Rounded","Oblique/Off Center","Oblique/Square" };
-
-char *panose_values_8[] = { "Any","No Fit","Standard/Trimmed","Standard/Pointed","Standard/Serifed","High/Trimmed",
- "High/Pointed","High/Serifed","Constant/Trimmed","Constant/Pointed","Constant/Serifed",
- "Low/Trimmed","Low/Pointed","Low/Serifed"};
-
-char *panose_values_9[] = { "Any","No Fit", "Constant/Small", "Constant/Standard",
- "Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large" };
-
-
-void
-handle_pfminfo (lua_State *L, struct pfminfo pfm) {
-
- dump_intfield (L, "pfmset", pfm.pfmset);
- dump_intfield (L, "winascent_add", pfm.winascent_add);
- dump_intfield (L, "windescent_add", pfm.windescent_add);
- dump_intfield (L, "hheadascent_add", pfm.hheadascent_add);
- dump_intfield (L, "hheaddescent_add", pfm.hheaddescent_add);
- dump_intfield (L, "typoascent_add", pfm.typoascent_add);
- dump_intfield (L, "typodescent_add", pfm.typodescent_add);
- dump_intfield (L, "subsuper_set", pfm.subsuper_set);
- dump_intfield (L, "panose_set", pfm.panose_set);
- dump_intfield (L, "hheadset", pfm.hheadset);
- dump_intfield (L, "vheadset", pfm.vheadset);
- dump_intfield (L, "pfmfamily", pfm.pfmfamily);
- dump_intfield (L, "weight", pfm.weight);
- dump_intfield (L, "width", pfm.width);
- dump_intfield (L, "avgwidth", pfm.avgwidth);
- dump_intfield (L, "firstchar", pfm.firstchar);
- dump_intfield (L, "lastchar", pfm.lastchar);
- lua_createtable(L,0,10);
- dump_enumfield(L,"familytype", pfm.panose[0], panose_values_0);
- dump_enumfield(L,"serifstyle", pfm.panose[1], panose_values_1);
- dump_enumfield(L,"weight", pfm.panose[2], panose_values_2);
- dump_enumfield(L,"proportion", pfm.panose[3], panose_values_3);
- dump_enumfield(L,"contrast", pfm.panose[4], panose_values_4);
- dump_enumfield(L,"strokevariation", pfm.panose[5], panose_values_5);
- dump_enumfield(L,"armstyle", pfm.panose[6], panose_values_6);
- dump_enumfield(L,"letterform", pfm.panose[7], panose_values_7);
- dump_enumfield(L,"midline", pfm.panose[8], panose_values_8);
- dump_enumfield(L,"xheight", pfm.panose[9], panose_values_9);
- lua_setfield (L,-2,"panose");
-
- dump_intfield (L, "fstype", pfm.fstype);
- dump_intfield (L, "linegap", pfm.linegap);
- dump_intfield (L, "vlinegap", pfm.vlinegap);
- dump_intfield (L, "hhead_ascent", pfm.hhead_ascent);
- dump_intfield (L, "hhead_descent", pfm.hhead_descent);
- dump_intfield (L, "hhead_descent", pfm.hhead_descent);
- dump_intfield (L, "os2_typoascent", pfm.os2_typoascent );
- dump_intfield (L, "os2_typodescent", pfm.os2_typodescent );
- dump_intfield (L, "os2_typolinegap", pfm.os2_typolinegap );
- dump_intfield (L, "os2_winascent", pfm.os2_winascent );
- dump_intfield (L, "os2_windescent", pfm.os2_windescent );
- dump_intfield (L, "os2_subxsize", pfm.os2_subxsize );
- dump_intfield (L, "os2_subysize", pfm.os2_subysize );
- dump_intfield (L, "os2_subxoff", pfm.os2_subxoff );
- dump_intfield (L, "os2_subyoff", pfm.os2_subyoff );
- dump_intfield (L, "os2_supxsize", pfm.os2_supxsize );
- dump_intfield (L, "os2_supysize", pfm.os2_supysize );
- dump_intfield (L, "os2_supxoff", pfm.os2_supxoff );
- dump_intfield (L, "os2_supyoff", pfm.os2_supyoff );
- dump_intfield (L, "os2_strikeysize", pfm.os2_strikeysize );
- dump_intfield (L, "os2_strikeypos", pfm.os2_strikeypos );
- dump_lstringfield (L, "os2_vendor", pfm.os2_vendor, 4);
- dump_intfield (L, "os2_family_class", pfm.os2_family_class);
- dump_intfield (L, "os2_xheight", pfm.os2_xheight);
- dump_intfield (L, "os2_capheight", pfm.os2_capheight);
- dump_intfield (L, "os2_defaultchar", pfm.os2_defaultchar);
- dump_intfield (L, "os2_breakchar", pfm.os2_breakchar);
- if (pfm.hascodepages) {
- lua_newtable(L);
- lua_pushnumber(L, pfm.codepages[0]); lua_rawseti(L,-2,1);
- lua_pushnumber(L, pfm.codepages[1]); lua_rawseti(L,-2,2);
- lua_setfield(L,-2,"codepages");
- }
- if (pfm.hasunicoderanges) {
+ for (i = 0; i < vars->part_cnt; i++) {
+ lua_newtable(L);
+ dump_stringfield(L, "component", vars->parts[i].component);
+ dump_intfield(L, "extender", vars->parts[i].is_extender);
+ dump_intfield(L, "start", vars->parts[i].startConnectorLength);
+ dump_intfield(L, "end", vars->parts[i].endConnectorLength);
+ dump_intfield(L, "advance", vars->parts[i].fullAdvance);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "parts");
+}
+
+void handle_mathkernvertex(lua_State * L, struct mathkernvertex *mkv)
+{
+ int i;
+ for (i = 0; i < mkv->cnt; i++) {
+ lua_newtable(L);
+ dump_intfield(L, "height", mkv->mkd[i].height);
+ dump_intfield(L, "kern", mkv->mkd[i].kern);
+ lua_rawseti(L, -2, (i + 1));
+ }
+}
+
+void handle_mathkern(lua_State * L, struct mathkern *mk)
+{
lua_newtable(L);
- lua_pushnumber(L, pfm.unicoderanges[0]); lua_rawseti(L,-2,1);
- lua_pushnumber(L, pfm.unicoderanges[1]); lua_rawseti(L,-2,2);
- lua_pushnumber(L, pfm.unicoderanges[2]); lua_rawseti(L,-2,3);
- lua_pushnumber(L, pfm.unicoderanges[3]); lua_rawseti(L,-2,4);
- lua_setfield(L,-2,"unicoderanges");
- }
-}
-
-
-void
-do_handle_enc (lua_State *L, struct enc *enc) {
- int i;
-
- dump_stringfield(L,"enc_name", enc->enc_name);
- dump_intfield (L,"char_cnt", enc->char_cnt);
-
- lua_checkstack(L,4);
- if (enc->char_cnt && enc->unicode != NULL) {
- lua_createtable(L,enc->char_cnt,1);
- for (i=0;i<enc->char_cnt;i++) {
- lua_pushnumber(L,i);
- lua_pushnumber(L,enc->unicode[i]);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"unicode");
- }
-
- if (enc->char_cnt && enc->psnames != NULL) {
- lua_createtable(L,enc->char_cnt,1);
- for (i=0;i<enc->char_cnt;i++) {
- lua_pushnumber(L,i);
- lua_pushstring(L,enc->psnames[i]);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"psnames");
- }
- dump_intfield (L,"builtin", enc->builtin );
- dump_intfield (L,"hidden", enc->hidden );
- dump_intfield (L,"only_1byte", enc->only_1byte );
- dump_intfield (L,"has_1byte", enc->has_1byte );
- dump_intfield (L,"has_2byte", enc->has_2byte );
- dump_cond_intfield (L,"is_unicodebmp", enc->is_unicodebmp );
- dump_cond_intfield (L,"is_unicodefull", enc->is_unicodefull );
- dump_cond_intfield (L,"is_custom", enc->is_custom );
- dump_cond_intfield (L,"is_original", enc->is_original );
- dump_cond_intfield (L,"is_compact", enc->is_compact );
- dump_cond_intfield (L,"is_japanese", enc->is_japanese );
- dump_cond_intfield (L,"is_korean", enc->is_korean );
- dump_cond_intfield (L,"is_tradchinese", enc->is_tradchinese );
- dump_cond_intfield (L,"is_simplechinese", enc->is_simplechinese);
-
- if (enc->iso_2022_escape_len > 0) {
- dump_lstringfield (L,"iso_2022_escape", enc->iso_2022_escape, enc->iso_2022_escape_len);
- }
- dump_intfield (L,"low_page", enc->low_page);
- dump_intfield(L,"high_page", enc->high_page);
-
- dump_stringfield(L,"iconv_name", enc->iconv_name);
-
- dump_intfield (L,"char_max", enc->char_max);
-}
-
-void
-handle_enc (lua_State *L, struct enc *enc) {
- struct enc *next;
- NESTED_TABLE(do_handle_enc,enc,24);
-}
-
-void
-handle_encmap (lua_State *L, struct encmap *map, int notdef_loc) {
- int i;
- dump_intfield(L,"enccount", map->enccount) ;
- dump_intfield(L,"encmax", map->encmax) ;
- dump_intfield(L,"backmax", map->backmax) ;
- /*dump_intfield(L,"ticked", map->ticked) ;*/
- if (map->remap != NULL) {
+ handle_mathkernvertex(L, &(mk->top_right));
+ lua_setfield(L, -2, "top_right");
lua_newtable(L);
- dump_intfield(L,"firstenc", map->remap->firstenc) ;
- dump_intfield(L,"lastenc", map->remap->lastenc) ;
- dump_intfield(L,"infont", map->remap->infont) ;
- lua_setfield(L,-2,"remap");
- }
- lua_checkstack(L,4);
- if (map->encmax > 0 && map->map != NULL) {
- lua_createtable(L,map->encmax,1);
- for (i=0;i<map->encmax;i++) {
- if (map->map[i]!=-1) {
- int l = map->map[i];
- lua_pushnumber(L,i);
- if (l<notdef_loc)
- lua_pushnumber(L,(l+1));
- else
- lua_pushnumber(L,l);
- lua_rawset(L,-3);
- }
- }
- lua_setfield(L,-2,"map");
- }
-
- if (map->backmax > 0 && map->backmap != NULL) {
+ handle_mathkernvertex(L, &(mk->top_left));
+ lua_setfield(L, -2, "top_left");
lua_newtable(L);
- for (i=0;i<map->backmax;i++) {
- if (map->backmap[i]!=-1) { /* TODO: check this, because valgrind sometimes says
- "Conditional jump or move depends on uninitialised value(s)"
- needs a test file.
- */
- if (i<notdef_loc)
- lua_pushnumber(L,(i+1));
- else
- lua_pushnumber(L,i);
- lua_pushnumber(L,map->backmap[i]);
- lua_rawset(L,-3);
- }
- }
- lua_setfield(L,-2,"backmap");
- }
-
- if (map->enc != NULL) {
+ handle_mathkernvertex(L, &(mk->bottom_right));
+ lua_setfield(L, -2, "bottom_right");
lua_newtable(L);
- handle_enc(L,map->enc);
- lua_setfield(L,-2,"enc");
- }
+ handle_mathkernvertex(L, &(mk->bottom_left));
+ lua_setfield(L, -2, "bottom_left");
}
-static void
-handle_psdict (lua_State *L, struct psdict *private) {
- int k;
- if (private->keys != NULL && private->values != NULL) {
- for (k=0;k<private->next;k++) {
- lua_pushstring(L,private->keys[k]);
- lua_pushstring(L,private->values[k]);
- lua_rawset(L,-3);
- }
- }
+
+
+void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics)
+{
+ DBounds bb;
+ if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0
+ && glyph->ymin == 0) {
+ SplineCharFindBounds(glyph, &bb);
+ glyph->xmin = bb.minx;
+ glyph->ymin = bb.miny;
+ glyph->xmax = bb.maxx;
+ glyph->ymax = bb.maxy;
+ }
+ dump_stringfield(L, "name", glyph->name);
+ dump_intfield(L, "unicode", glyph->unicodeenc);
+ lua_createtable(L, 4, 0);
+ lua_pushnumber(L, 1);
+ lua_pushnumber(L, glyph->xmin);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 2);
+ lua_pushnumber(L, glyph->ymin);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 3);
+ lua_pushnumber(L, glyph->xmax);
+ lua_rawset(L, -3);
+ lua_pushnumber(L, 4);
+ lua_pushnumber(L, glyph->ymax);
+ lua_rawset(L, -3);
+ lua_setfield(L, -2, "boundingbox");
+ /*dump_intfield(L,"orig_pos", glyph->orig_pos); */
+ if (hasvmetrics)
+ dump_intfield(L, "vwidth", glyph->vwidth);
+ dump_intfield(L, "width", glyph->width);
+
+ if (glyph->lsidebearing != glyph->xmin) {
+ dump_cond_intfield(L, "lsidebearing", glyph->lsidebearing);
+ }
+ /* dump_intfield(L,"ttf_glyph", glyph->ttf_glyph); */
+
+ /* Layer layers[2]; *//* TH Not used */
+ /* int layer_cnt; *//* TH Not used */
+ /* StemInfo *hstem; *//* TH Not used */
+ /* StemInfo *vstem; *//* TH Not used */
+ /* DStemInfo *dstem; *//* TH Not used */
+
+ /* MinimumDistance *md; *//* TH Not used */
+ /* struct charviewbase *views; *//* TH Not used */
+ /* struct charinfo *charinfo; *//* TH ? (charinfo.c) */
+ /* struct splinefont *parent; *//* TH Not used */
+
+ if (glyph->glyph_class > 0) {
+ dump_enumfield(L, "class", glyph->glyph_class, glyph_class_enum);
+ }
+ /* TH: internal fontforge stuff
+ dump_intfield(L,"changed", glyph->changed);
+ dump_intfield(L,"changedsincelasthinted", glyph->changedsincelasthinted);
+ dump_intfield(L,"manualhints", glyph->manualhints);
+ dump_intfield(L,"ticked", glyph->ticked);
+ dump_intfield(L,"changed_since_autosave", glyph->changed_since_autosave);
+ dump_intfield(L,"widthset", glyph->widthset);
+ dump_intfield(L,"vconflicts", glyph->vconflicts);
+ dump_intfield(L,"hconflicts", glyph->hconflicts);
+ dump_intfield(L,"searcherdummy", glyph->searcherdummy);
+ dump_intfield(L,"changed_since_search", glyph->changed_since_search);
+ dump_intfield(L,"wasopen", glyph->wasopen);
+ dump_intfield(L,"namechanged", glyph->namechanged);
+ dump_intfield(L,"blended", glyph->blended);
+ dump_intfield(L,"ticked2", glyph->ticked2);
+ dump_intfield(L,"unused_so_far", glyph->unused_so_far);
+ dump_intfield(L,"numberpointsbackards", glyph->numberpointsbackards);
+ dump_intfield(L,"instructions_out_of_date", glyph->instructions_out_of_date);
+ dump_intfield(L,"complained_about_ptnums", glyph->complained_about_ptnums);
+ unsigned int vs_open: 1;
+ unsigned int unlink_rm_ovrlp_save_undo: 1;
+ unsigned int inspiro: 1;
+ unsigned int lig_caret_cnt_fixed: 1;
+
+
+ uint8 *ttf_instrs;
+ int16 ttf_instrs_len;
+ int16 countermask_cnt;
+ HintMask *countermasks;
+ */
+
+ if (glyph->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->kerns);
+ lua_setfield(L, -2, "kerns");
+ }
+ if (glyph->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->vkerns);
+ lua_setfield(L, -2, "vkerns");
+ }
+
+ if (glyph->dependents != NULL) {
+ lua_newtable(L);
+ handle_splinecharlist(L, glyph->dependents);
+ lua_setfield(L, -2, "dependents");
+
+ }
+ if (glyph->possub != NULL) {
+ lua_newtable(L);
+ handle_generic_pst(L, glyph->possub);
+ lua_setfield(L, -2, "lookups");
+ }
+
+ if (glyph->ligofme != NULL) {
+ lua_newtable(L);
+ handle_liglist(L, glyph->ligofme);
+ lua_setfield(L, -2, "ligatures");
+ }
+
+ if (glyph->comment != NULL)
+ dump_stringfield(L, "comment", glyph->comment);
+
+ /* Color color; *//* dont care */
+
+ if (glyph->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorpoint(L, glyph->anchor);
+ lua_setfield(L, -2, "anchors");
+ }
+
+ if (glyph->altuni != NULL) {
+ lua_newtable(L);
+ handle_altuni(L, glyph->altuni);
+ lua_setfield(L, -2, "altuni");
+ }
+
+ if (glyph->tex_height != TEX_UNDEF)
+ dump_intfield(L, "tex_height", glyph->tex_height);
+ if (glyph->tex_depth != TEX_UNDEF)
+ dump_intfield(L, "tex_depth", glyph->tex_depth);
+
+ dump_cond_intfield(L, "is_extended_shape", glyph->is_extended_shape);
+ if (glyph->italic_correction != TEX_UNDEF)
+ dump_intfield(L, "italic_correction", glyph->italic_correction);
+ if (glyph->top_accent_horiz != TEX_UNDEF)
+ dump_intfield(L, "top_accent", glyph->top_accent_horiz);
+
+ if (glyph->vert_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->vert_variants);
+ lua_setfield(L, -2, "vert_variants");
+ }
+ if (glyph->horiz_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->horiz_variants);
+ lua_setfield(L, -2, "horiz_variants");
+ }
+ if (glyph->mathkern != NULL) {
+ lua_newtable(L);
+ handle_mathkern(L, glyph->mathkern);
+ lua_setfield(L, -2, "mathkern");
+ }
}
-void
-do_handle_ttflangname (lua_State *L, struct ttflangname *names) {
- int k;
- dump_stringfield(L,"lang", (char *)MSLangString(names->lang)) ;
- lua_checkstack(L,4);
- lua_createtable(L,0,ttf_namemax);
- for (k=0;k<ttf_namemax;k++) {
- lua_pushstring(L,ttfnames_enum[k]);
- lua_pushstring(L,names->names[k]);
- lua_rawset(L,-3);
- }
- lua_setfield(L, -2 , "names");
+char *panose_values_0[] =
+ { "Any", "No Fit", "Text and Display", "Script", "Decorative",
+ "Pictorial"
+};
+
+char *panose_values_1[] =
+ { "Any", "No Fit", "Cove", "Obtuse Cove", "Square Cove",
+ "Obtuse Square Cove",
+ "Square", "Thin", "Bone", "Exaggerated", "Triangle", "Normal Sans",
+ "Obtuse Sans", "Perp Sans", "Flared", "Rounded"
+};
+
+char *panose_values_2[] =
+ { "Any", "No Fit", "Very Light", "Light", "Thin", "Book",
+ "Medium", "Demi", "Bold", "Heavy", "Black", "Nord"
+};
+
+char *panose_values_3[] =
+ { "Any", "No Fit", "Old Style", "Modern", "Even Width",
+ "Expanded", "Condensed", "Very Expanded", "Very Condensed", "Monospaced"
+};
+
+char *panose_values_4[] =
+ { "Any", "No Fit", "None", "Very Low", "Low", "Medium Low",
+ "Medium", "Medium High", "High", "Very High"
+};
+
+char *panose_values_5[] =
+ { "Any", "No Fit", "Gradual/Diagonal", "Gradual/Transitional",
+ "Gradual/Vertical",
+ "Gradual/Horizontal", "Rapid/Vertical", "Rapid/Horizontal",
+ "Instant/Vertical"
+};
+
+char *panose_values_6[] =
+ { "Any", "No Fit", "Straight Arms/Horizontal", "Straight Arms/Wedge",
+ "Straight Arms/Vertical",
+ "Straight Arms/Single Serif", "Straight Arms/Double Serif",
+ "Non-Straight Arms/Horizontal",
+ "Non-Straight Arms/Wedge", "Non-Straight Arms/Vertical",
+ "Non-Straight Arms/Single Serif",
+ "Non-Straight Arms/Double Serif"
+};
+
+char *panose_values_7[] =
+ { "Any", "No Fit", "Normal/Contact", "Normal/Weighted", "Normal/Boxed",
+ "Normal/Flattened",
+ "Normal/Rounded", "Normal/Off Center", "Normal/Square", "Oblique/Contact",
+ "Oblique/Weighted",
+ "Oblique/Boxed", "Oblique/Flattened", "Oblique/Rounded",
+ "Oblique/Off Center", "Oblique/Square"
+};
+
+char *panose_values_8[] =
+ { "Any", "No Fit", "Standard/Trimmed", "Standard/Pointed",
+ "Standard/Serifed", "High/Trimmed",
+ "High/Pointed", "High/Serifed", "Constant/Trimmed", "Constant/Pointed",
+ "Constant/Serifed",
+ "Low/Trimmed", "Low/Pointed", "Low/Serifed"
+};
+
+char *panose_values_9[] =
+ { "Any", "No Fit", "Constant/Small", "Constant/Standard",
+ "Constant/Large", "Ducking/Small", "Ducking/Standard", "Ducking/Large"
+};
+
+
+void handle_pfminfo(lua_State * L, struct pfminfo pfm)
+{
+
+ dump_intfield(L, "pfmset", pfm.pfmset);
+ dump_intfield(L, "winascent_add", pfm.winascent_add);
+ dump_intfield(L, "windescent_add", pfm.windescent_add);
+ dump_intfield(L, "hheadascent_add", pfm.hheadascent_add);
+ dump_intfield(L, "hheaddescent_add", pfm.hheaddescent_add);
+ dump_intfield(L, "typoascent_add", pfm.typoascent_add);
+ dump_intfield(L, "typodescent_add", pfm.typodescent_add);
+ dump_intfield(L, "subsuper_set", pfm.subsuper_set);
+ dump_intfield(L, "panose_set", pfm.panose_set);
+ dump_intfield(L, "hheadset", pfm.hheadset);
+ dump_intfield(L, "vheadset", pfm.vheadset);
+ dump_intfield(L, "pfmfamily", pfm.pfmfamily);
+ dump_intfield(L, "weight", pfm.weight);
+ dump_intfield(L, "width", pfm.width);
+ dump_intfield(L, "avgwidth", pfm.avgwidth);
+ dump_intfield(L, "firstchar", pfm.firstchar);
+ dump_intfield(L, "lastchar", pfm.lastchar);
+ lua_createtable(L, 0, 10);
+ dump_enumfield(L, "familytype", pfm.panose[0], panose_values_0);
+ dump_enumfield(L, "serifstyle", pfm.panose[1], panose_values_1);
+ dump_enumfield(L, "weight", pfm.panose[2], panose_values_2);
+ dump_enumfield(L, "proportion", pfm.panose[3], panose_values_3);
+ dump_enumfield(L, "contrast", pfm.panose[4], panose_values_4);
+ dump_enumfield(L, "strokevariation", pfm.panose[5], panose_values_5);
+ dump_enumfield(L, "armstyle", pfm.panose[6], panose_values_6);
+ dump_enumfield(L, "letterform", pfm.panose[7], panose_values_7);
+ dump_enumfield(L, "midline", pfm.panose[8], panose_values_8);
+ dump_enumfield(L, "xheight", pfm.panose[9], panose_values_9);
+ lua_setfield(L, -2, "panose");
+
+ dump_intfield(L, "fstype", pfm.fstype);
+ dump_intfield(L, "linegap", pfm.linegap);
+ dump_intfield(L, "vlinegap", pfm.vlinegap);
+ dump_intfield(L, "hhead_ascent", pfm.hhead_ascent);
+ dump_intfield(L, "hhead_descent", pfm.hhead_descent);
+ dump_intfield(L, "hhead_descent", pfm.hhead_descent);
+ dump_intfield(L, "os2_typoascent", pfm.os2_typoascent);
+ dump_intfield(L, "os2_typodescent", pfm.os2_typodescent);
+ dump_intfield(L, "os2_typolinegap", pfm.os2_typolinegap);
+ dump_intfield(L, "os2_winascent", pfm.os2_winascent);
+ dump_intfield(L, "os2_windescent", pfm.os2_windescent);
+ dump_intfield(L, "os2_subxsize", pfm.os2_subxsize);
+ dump_intfield(L, "os2_subysize", pfm.os2_subysize);
+ dump_intfield(L, "os2_subxoff", pfm.os2_subxoff);
+ dump_intfield(L, "os2_subyoff", pfm.os2_subyoff);
+ dump_intfield(L, "os2_supxsize", pfm.os2_supxsize);
+ dump_intfield(L, "os2_supysize", pfm.os2_supysize);
+ dump_intfield(L, "os2_supxoff", pfm.os2_supxoff);
+ dump_intfield(L, "os2_supyoff", pfm.os2_supyoff);
+ dump_intfield(L, "os2_strikeysize", pfm.os2_strikeysize);
+ dump_intfield(L, "os2_strikeypos", pfm.os2_strikeypos);
+ dump_lstringfield(L, "os2_vendor", pfm.os2_vendor, 4);
+ dump_intfield(L, "os2_family_class", pfm.os2_family_class);
+ dump_intfield(L, "os2_xheight", pfm.os2_xheight);
+ dump_intfield(L, "os2_capheight", pfm.os2_capheight);
+ dump_intfield(L, "os2_defaultchar", pfm.os2_defaultchar);
+ dump_intfield(L, "os2_breakchar", pfm.os2_breakchar);
+ if (pfm.hascodepages) {
+ lua_newtable(L);
+ lua_pushnumber(L, pfm.codepages[0]);
+ lua_rawseti(L, -2, 1);
+ lua_pushnumber(L, pfm.codepages[1]);
+ lua_rawseti(L, -2, 2);
+ lua_setfield(L, -2, "codepages");
+ }
+ if (pfm.hasunicoderanges) {
+ lua_newtable(L);
+ lua_pushnumber(L, pfm.unicoderanges[0]);
+ lua_rawseti(L, -2, 1);
+ lua_pushnumber(L, pfm.unicoderanges[1]);
+ lua_rawseti(L, -2, 2);
+ lua_pushnumber(L, pfm.unicoderanges[2]);
+ lua_rawseti(L, -2, 3);
+ lua_pushnumber(L, pfm.unicoderanges[3]);
+ lua_rawseti(L, -2, 4);
+ lua_setfield(L, -2, "unicoderanges");
+ }
}
-void
-handle_ttflangname (lua_State *L, struct ttflangname *names) {
- struct ttflangname *next;
- NESTED_TABLE(do_handle_ttflangname,names,2);
+void do_handle_enc(lua_State * L, struct enc *enc)
+{
+ int i;
+
+ dump_stringfield(L, "enc_name", enc->enc_name);
+ dump_intfield(L, "char_cnt", enc->char_cnt);
+
+ lua_checkstack(L, 4);
+ if (enc->char_cnt && enc->unicode != NULL) {
+ lua_createtable(L, enc->char_cnt, 1);
+ for (i = 0; i < enc->char_cnt; i++) {
+ lua_pushnumber(L, i);
+ lua_pushnumber(L, enc->unicode[i]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "unicode");
+ }
+
+ if (enc->char_cnt && enc->psnames != NULL) {
+ lua_createtable(L, enc->char_cnt, 1);
+ for (i = 0; i < enc->char_cnt; i++) {
+ lua_pushnumber(L, i);
+ lua_pushstring(L, enc->psnames[i]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "psnames");
+ }
+ dump_intfield(L, "builtin", enc->builtin);
+ dump_intfield(L, "hidden", enc->hidden);
+ dump_intfield(L, "only_1byte", enc->only_1byte);
+ dump_intfield(L, "has_1byte", enc->has_1byte);
+ dump_intfield(L, "has_2byte", enc->has_2byte);
+ dump_cond_intfield(L, "is_unicodebmp", enc->is_unicodebmp);
+ dump_cond_intfield(L, "is_unicodefull", enc->is_unicodefull);
+ dump_cond_intfield(L, "is_custom", enc->is_custom);
+ dump_cond_intfield(L, "is_original", enc->is_original);
+ dump_cond_intfield(L, "is_compact", enc->is_compact);
+ dump_cond_intfield(L, "is_japanese", enc->is_japanese);
+ dump_cond_intfield(L, "is_korean", enc->is_korean);
+ dump_cond_intfield(L, "is_tradchinese", enc->is_tradchinese);
+ dump_cond_intfield(L, "is_simplechinese", enc->is_simplechinese);
+
+ if (enc->iso_2022_escape_len > 0) {
+ dump_lstringfield(L, "iso_2022_escape", enc->iso_2022_escape,
+ enc->iso_2022_escape_len);
+ }
+ dump_intfield(L, "low_page", enc->low_page);
+ dump_intfield(L, "high_page", enc->high_page);
+
+ dump_stringfield(L, "iconv_name", enc->iconv_name);
+
+ dump_intfield(L, "char_max", enc->char_max);
}
+void handle_enc(lua_State * L, struct enc *enc)
+{
+ struct enc *next;
+ NESTED_TABLE(do_handle_enc, enc, 24);
+}
-void
-do_handle_anchorclass (lua_State *L, struct anchorclass *anchor) {
+void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
+{
+ int i;
+ dump_intfield(L, "enccount", map->enccount);
+ dump_intfield(L, "encmax", map->encmax);
+ dump_intfield(L, "backmax", map->backmax);
+ /*dump_intfield(L,"ticked", map->ticked) ; */
+ if (map->remap != NULL) {
+ lua_newtable(L);
+ dump_intfield(L, "firstenc", map->remap->firstenc);
+ dump_intfield(L, "lastenc", map->remap->lastenc);
+ dump_intfield(L, "infont", map->remap->infont);
+ lua_setfield(L, -2, "remap");
+ }
+ lua_checkstack(L, 4);
+ if (map->encmax > 0 && map->map != NULL) {
+ lua_createtable(L, map->encmax, 1);
+ for (i = 0; i < map->encmax; i++) {
+ if (map->map[i] != -1) {
+ int l = map->map[i];
+ lua_pushnumber(L, i);
+ if (l < notdef_loc)
+ lua_pushnumber(L, (l + 1));
+ else
+ lua_pushnumber(L, l);
+ lua_rawset(L, -3);
+ }
+ }
+ lua_setfield(L, -2, "map");
+ }
+
+ if (map->backmax > 0 && map->backmap != NULL) {
+ lua_newtable(L);
+ for (i = 0; i < map->backmax; i++) {
+ if (map->backmap[i] != -1) { /* TODO: check this, because valgrind sometimes says
+ "Conditional jump or move depends on uninitialised value(s)"
+ needs a test file.
+ */
+ if (i < notdef_loc)
+ lua_pushnumber(L, (i + 1));
+ else
+ lua_pushnumber(L, i);
+ lua_pushnumber(L, map->backmap[i]);
+ lua_rawset(L, -3);
+ }
+ }
+ lua_setfield(L, -2, "backmap");
+ }
- dump_stringfield(L,"name", anchor->name);
- dump_subtable_name (L, "lookup", anchor->subtable);
- dump_enumfield(L,"type", anchor->type, anchorclass_type_enum);
- /* uint8 has_base; */
- /* uint8 processed, has_mark, matches, ac_num; */
- /* uint8 ticked; */
+ if (map->enc != NULL) {
+ lua_newtable(L);
+ handle_enc(L, map->enc);
+ lua_setfield(L, -2, "enc");
+ }
}
-void
-handle_anchorclass (lua_State *L, struct anchorclass *anchor) {
- struct anchorclass *next;
- NESTED_TABLE(do_handle_anchorclass,anchor,10);
+static void handle_psdict(lua_State * L, struct psdict *private)
+{
+ int k;
+ if (private->keys != NULL && private->values != NULL) {
+ for (k = 0; k < private->next; k++) {
+ lua_pushstring(L, private->keys[k]);
+ lua_pushstring(L, private->values[k]);
+ lua_rawset(L, -3);
+ }
+ }
+}
+
+void do_handle_ttflangname(lua_State * L, struct ttflangname *names)
+{
+ int k;
+ dump_stringfield(L, "lang", (char *) MSLangString(names->lang));
+ lua_checkstack(L, 4);
+ lua_createtable(L, 0, ttf_namemax);
+ for (k = 0; k < ttf_namemax; k++) {
+ lua_pushstring(L, ttfnames_enum[k]);
+ lua_pushstring(L, names->names[k]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "names");
}
-void
-do_handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) {
- dump_tag(L,"tag", ttf_tab->tag);
- dump_intfield(L,"len", ttf_tab->len);
- dump_intfield(L,"maxlen", ttf_tab->maxlen);
- dump_lstringfield(L,"data", (char *)ttf_tab->data, ttf_tab->len);
+void handle_ttflangname(lua_State * L, struct ttflangname *names)
+{
+ struct ttflangname *next;
+ NESTED_TABLE(do_handle_ttflangname, names, 2);
}
-void
-handle_ttf_table (lua_State *L, struct ttf_table *ttf_tab) {
- struct ttf_table *next;
- NESTED_TABLE(do_handle_ttf_table,ttf_tab,4);
+
+void do_handle_anchorclass(lua_State * L, struct anchorclass *anchor)
+{
+
+ dump_stringfield(L, "name", anchor->name);
+ dump_subtable_name(L, "lookup", anchor->subtable);
+ dump_enumfield(L, "type", anchor->type, anchorclass_type_enum);
+ /* uint8 has_base; */
+ /* uint8 processed, has_mark, matches, ac_num; */
+ /* uint8 ticked; */
}
-void
-do_handle_kernclass (lua_State *L, struct kernclass *kerns) {
- int k;
-
- /*
- * dump_intfield(L,"first_cnt", kerns->first_cnt);
- * dump_intfield(L,"second_cnt", kerns->second_cnt);
- */
- lua_checkstack(L,4);
- lua_createtable(L,kerns->first_cnt,1);
- for (k=0;k<kerns->first_cnt;k++) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,kerns->firsts[k]);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"firsts");
-
- lua_createtable(L,kerns->second_cnt,1);
- for (k=0;k<kerns->second_cnt;k++) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,kerns->seconds[k]);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"seconds");
-
- dump_subtable_name(L, "lookup", kerns->subtable);
- /*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */
-
- lua_createtable(L,kerns->second_cnt*kerns->first_cnt,1);
- for (k=0;k<(kerns->second_cnt*kerns->first_cnt);k++) {
- if (kerns->offsets[k]!=0) {
- lua_pushnumber(L,(k+1));
- lua_pushnumber(L,kerns->offsets[k]);
- lua_rawset(L,-3);
- }
- }
- lua_setfield(L,-2,"offsets");
+void handle_anchorclass(lua_State * L, struct anchorclass *anchor)
+{
+ struct anchorclass *next;
+ NESTED_TABLE(do_handle_anchorclass, anchor, 10);
+}
+void do_handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab)
+{
+
+ dump_tag(L, "tag", ttf_tab->tag);
+ dump_intfield(L, "len", ttf_tab->len);
+ dump_intfield(L, "maxlen", ttf_tab->maxlen);
+ dump_lstringfield(L, "data", (char *) ttf_tab->data, ttf_tab->len);
}
-void
-handle_kernclass (lua_State *L, struct kernclass *kerns) {
- struct kernclass *next;
- NESTED_TABLE(do_handle_kernclass,kerns,8);
+void handle_ttf_table(lua_State * L, struct ttf_table *ttf_tab)
+{
+ struct ttf_table *next;
+ NESTED_TABLE(do_handle_ttf_table, ttf_tab, 4);
+}
+
+void do_handle_kernclass(lua_State * L, struct kernclass *kerns)
+{
+ int k;
+
+ /*
+ * dump_intfield(L,"first_cnt", kerns->first_cnt);
+ * dump_intfield(L,"second_cnt", kerns->second_cnt);
+ */
+ lua_checkstack(L, 4);
+ lua_createtable(L, kerns->first_cnt, 1);
+ for (k = 0; k < kerns->first_cnt; k++) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushstring(L, kerns->firsts[k]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "firsts");
+
+ lua_createtable(L, kerns->second_cnt, 1);
+ for (k = 0; k < kerns->second_cnt; k++) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushstring(L, kerns->seconds[k]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "seconds");
+
+ dump_subtable_name(L, "lookup", kerns->subtable);
+ /*dump_intfield(L,"kcid", kerns->kcid); *//* probably not needed */
+
+ lua_createtable(L, kerns->second_cnt * kerns->first_cnt, 1);
+ for (k = 0; k < (kerns->second_cnt * kerns->first_cnt); k++) {
+ if (kerns->offsets[k] != 0) {
+ lua_pushnumber(L, (k + 1));
+ lua_pushnumber(L, kerns->offsets[k]);
+ lua_rawset(L, -3);
+ }
+ }
+ lua_setfield(L, -2, "offsets");
+
+}
+
+void handle_kernclass(lua_State * L, struct kernclass *kerns)
+{
+ struct kernclass *next;
+ NESTED_TABLE(do_handle_kernclass, kerns, 8);
}
@@ -1335,200 +1459,209 @@ handle_kernclass (lua_State *L, struct kernclass *kerns) {
lua_setfield(L,-2,s); } }
-void handle_fpst_rule (lua_State *L, struct fpst_rule *rule, int format) {
- int k;
+void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format)
+{
+ int k;
- if (format == pst_glyphs) {
+ if (format == pst_glyphs) {
- lua_newtable(L);
- dump_stringfield(L,"names",rule->u.glyph.names);
- dump_stringfield(L,"back",rule->u.glyph.back);
- dump_stringfield(L,"fore",rule->u.glyph.fore);
- lua_setfield(L,-2,fpossub_format_enum[format]);
+ lua_newtable(L);
+ dump_stringfield(L, "names", rule->u.glyph.names);
+ dump_stringfield(L, "back", rule->u.glyph.back);
+ dump_stringfield(L, "fore", rule->u.glyph.fore);
+ lua_setfield(L, -2, fpossub_format_enum[format]);
- } else if (format == pst_class) {
-
- lua_newtable(L);
- DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt,rule->u.class.nclasses);
- DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt,rule->u.class.bclasses);
- DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt,rule->u.class.fclasses);
+ } else if (format == pst_class) {
+
+ lua_newtable(L);
+ DUMP_NUMBER_ARRAY("current", rule->u.class.ncnt,
+ rule->u.class.nclasses);
+ DUMP_NUMBER_ARRAY("before", rule->u.class.bcnt, rule->u.class.bclasses);
+ DUMP_NUMBER_ARRAY("after", rule->u.class.fcnt, rule->u.class.fclasses);
#if 0
- DUMP_NUMBER_ARRAY("allclasses", 0,rule->u.class.allclasses);
+ DUMP_NUMBER_ARRAY("allclasses", 0, rule->u.class.allclasses);
#endif
- lua_setfield(L,-2,fpossub_format_enum[format]);
+ lua_setfield(L, -2, fpossub_format_enum[format]);
- } else if (format == pst_coverage) {
+ } else if (format == pst_coverage) {
- lua_newtable(L);
- DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt,rule->u.coverage.ncovers);
- DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt,rule->u.coverage.bcovers);
- DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt,rule->u.coverage.fcovers);
- lua_setfield(L,-2,fpossub_format_enum[format]);
+ lua_newtable(L);
+ DUMP_STRING_ARRAY("current", rule->u.coverage.ncnt,
+ rule->u.coverage.ncovers);
+ DUMP_STRING_ARRAY("before", rule->u.coverage.bcnt,
+ rule->u.coverage.bcovers);
+ DUMP_STRING_ARRAY("after", rule->u.coverage.fcnt,
+ rule->u.coverage.fcovers);
+ lua_setfield(L, -2, fpossub_format_enum[format]);
- } else if (format == pst_reversecoverage) {
+ } else if (format == pst_reversecoverage) {
- lua_newtable(L);
- DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1,rule->u.rcoverage.ncovers);
- DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt,rule->u.rcoverage.bcovers);
- DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt,rule->u.rcoverage.fcovers);
- dump_stringfield(L,"replacements", rule->u.rcoverage.replacements);
- lua_setfield(L,-2,fpossub_format_enum[format]);
- } else {
- fprintf(stderr,"handle_fpst_rule(): Unknown rule format: %d\n",format);
- }
-
- if (rule->lookup_cnt>0) {
- lua_newtable(L);
- for (k=0;k<rule->lookup_cnt;k++) {
- lua_pushnumber(L,(rule->lookups[k].seq+1));
- if (rule->lookups[k].lookup!=NULL) {
- lua_pushstring(L,rule->lookups[k].lookup->lookup_name);
- } else {
- lua_pushnil(L);
- }
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"lookups");
- } else {
- /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n");*/
- }
-}
-
-void
-do_handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) {
- int k;
-
- if (fpst->type>LAST_POSSUB_TYPE_ENUM) {
- dump_intfield(L,"type", fpst->type);
- } else {
- dump_enumfield(L,"type", fpst->type, possub_type_enum);
- }
- dump_enumfield(L,"format", fpst->format, fpossub_format_enum);
-
- if (fpst->format==pst_class) {
- DUMP_EXACT_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass);
- DUMP_EXACT_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass);
- DUMP_EXACT_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass);
- } else {
- DUMP_STRING_ARRAY("current_class",fpst->nccnt,fpst->nclass);
- DUMP_STRING_ARRAY("before_class",fpst->bccnt,fpst->bclass);
- DUMP_STRING_ARRAY("after_class",fpst->fccnt,fpst->fclass);
- }
-
- lua_checkstack(L,4);
- if (fpst->rule_cnt>0) {
- lua_createtable(L,fpst->rule_cnt,1);
- for (k=0;k<fpst->rule_cnt;k++) {
- lua_pushnumber(L,(k+1));
- lua_newtable(L);
- handle_fpst_rule(L,&(fpst->rules[k]),fpst->format);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"rules");
- }
- /*dump_intfield (L,"ticked", fpst->ticked);*/
-}
-
-void
-handle_generic_fpst(lua_State *L, struct generic_fpst *fpst) {
- struct generic_fpst *next;
- int k = 1;
- lua_checkstack(L,3);
- if (fpst->subtable != NULL &&
- fpst->subtable->subtable_name != NULL) {
- lua_pushstring(L,fpst->subtable->subtable_name);
- } else {
- lua_pushnumber(L,k); k++;
- }
- lua_createtable(L,0,10);
- do_handle_generic_fpst(L,fpst);
- lua_rawset(L,-3);
- next = fpst->next;
- while (next != NULL) {
- lua_checkstack(L,3);
- if (next->subtable != NULL &&
- next->subtable->subtable_name != NULL) {
- lua_pushstring(L,next->subtable->subtable_name);
- } else {
- lua_pushnumber(L,k); k++;
- }
- lua_createtable(L,0,10);
- do_handle_generic_fpst(L, next);
- lua_rawset(L,-3);
- next = next->next;
- }
+ lua_newtable(L);
+ DUMP_STRING_ARRAY("current", rule->u.rcoverage.always1,
+ rule->u.rcoverage.ncovers);
+ DUMP_STRING_ARRAY("before", rule->u.rcoverage.bcnt,
+ rule->u.rcoverage.bcovers);
+ DUMP_STRING_ARRAY("after", rule->u.rcoverage.fcnt,
+ rule->u.rcoverage.fcovers);
+ dump_stringfield(L, "replacements", rule->u.rcoverage.replacements);
+ lua_setfield(L, -2, fpossub_format_enum[format]);
+ } else {
+ fprintf(stderr, "handle_fpst_rule(): Unknown rule format: %d\n",
+ format);
+ }
+
+ if (rule->lookup_cnt > 0) {
+ lua_newtable(L);
+ for (k = 0; k < rule->lookup_cnt; k++) {
+ lua_pushnumber(L, (rule->lookups[k].seq + 1));
+ if (rule->lookups[k].lookup != NULL) {
+ lua_pushstring(L, rule->lookups[k].lookup->lookup_name);
+ } else {
+ lua_pushnil(L);
+ }
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "lookups");
+ } else {
+ /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n"); */
+ }
}
-void
-do_handle_otfname (lua_State *L, struct otfname *oname) {
- dump_intfield(L,"lang", oname->lang);
- dump_stringfield(L,"name", oname->name);
+void do_handle_generic_fpst(lua_State * L, struct generic_fpst *fpst)
+{
+ int k;
+
+ if (fpst->type > LAST_POSSUB_TYPE_ENUM) {
+ dump_intfield(L, "type", fpst->type);
+ } else {
+ dump_enumfield(L, "type", fpst->type, possub_type_enum);
+ }
+ dump_enumfield(L, "format", fpst->format, fpossub_format_enum);
+
+ if (fpst->format == pst_class) {
+ DUMP_EXACT_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass);
+ DUMP_EXACT_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass);
+ DUMP_EXACT_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass);
+ } else {
+ DUMP_STRING_ARRAY("current_class", fpst->nccnt, fpst->nclass);
+ DUMP_STRING_ARRAY("before_class", fpst->bccnt, fpst->bclass);
+ DUMP_STRING_ARRAY("after_class", fpst->fccnt, fpst->fclass);
+ }
+
+ lua_checkstack(L, 4);
+ if (fpst->rule_cnt > 0) {
+ lua_createtable(L, fpst->rule_cnt, 1);
+ for (k = 0; k < fpst->rule_cnt; k++) {
+ lua_pushnumber(L, (k + 1));
+ lua_newtable(L);
+ handle_fpst_rule(L, &(fpst->rules[k]), fpst->format);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "rules");
+ }
+ /*dump_intfield (L,"ticked", fpst->ticked); */
+}
+
+void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst)
+{
+ struct generic_fpst *next;
+ int k = 1;
+ lua_checkstack(L, 3);
+ if (fpst->subtable != NULL && fpst->subtable->subtable_name != NULL) {
+ lua_pushstring(L, fpst->subtable->subtable_name);
+ } else {
+ lua_pushnumber(L, k);
+ k++;
+ }
+ lua_createtable(L, 0, 10);
+ do_handle_generic_fpst(L, fpst);
+ lua_rawset(L, -3);
+ next = fpst->next;
+ while (next != NULL) {
+ lua_checkstack(L, 3);
+ if (next->subtable != NULL && next->subtable->subtable_name != NULL) {
+ lua_pushstring(L, next->subtable->subtable_name);
+ } else {
+ lua_pushnumber(L, k);
+ k++;
+ }
+ lua_createtable(L, 0, 10);
+ do_handle_generic_fpst(L, next);
+ lua_rawset(L, -3);
+ next = next->next;
+ }
}
-void
-handle_otfname (lua_State *L, struct otfname *oname) {
- struct otfname *next;
- NESTED_TABLE(do_handle_otfname,oname,2);
+void do_handle_otfname(lua_State * L, struct otfname *oname)
+{
+ dump_intfield(L, "lang", oname->lang);
+ dump_stringfield(L, "name", oname->name);
}
-void
-do_handle_macname (lua_State *L, struct macname *featname) {
- dump_intfield(L,"enc", featname->enc);
- dump_intfield(L,"lang", featname->lang);
- dump_stringfield(L,"name", featname->name);
+void handle_otfname(lua_State * L, struct otfname *oname)
+{
+ struct otfname *next;
+ NESTED_TABLE(do_handle_otfname, oname, 2);
}
-void
-handle_macname (lua_State *L, struct macname *featname) {
- struct macname *next;
- NESTED_TABLE(do_handle_macname,featname,3);
+void do_handle_macname(lua_State * L, struct macname *featname)
+{
+ dump_intfield(L, "enc", featname->enc);
+ dump_intfield(L, "lang", featname->lang);
+ dump_stringfield(L, "name", featname->name);
}
-void
-do_handle_macsetting (lua_State *L, struct macsetting *settings) {
- dump_intfield(L,"setting", settings->setting);
- dump_intfield(L,"strid", settings->strid);
- dump_intfield(L,"initially_enabled", settings->initially_enabled);
- if (settings->setname != NULL) {
- lua_newtable(L);
- handle_macname(L,settings->setname);
- lua_setfield(L,-2,"setname");
- }
+void handle_macname(lua_State * L, struct macname *featname)
+{
+ struct macname *next;
+ NESTED_TABLE(do_handle_macname, featname, 3);
}
-void
-handle_macsetting (lua_State *L, struct macsetting *settings) {
- struct macsetting *next;
- NESTED_TABLE(do_handle_macsetting,settings,4);
+void do_handle_macsetting(lua_State * L, struct macsetting *settings)
+{
+ dump_intfield(L, "setting", settings->setting);
+ dump_intfield(L, "strid", settings->strid);
+ dump_intfield(L, "initially_enabled", settings->initially_enabled);
+ if (settings->setname != NULL) {
+ lua_newtable(L);
+ handle_macname(L, settings->setname);
+ lua_setfield(L, -2, "setname");
+ }
}
+void handle_macsetting(lua_State * L, struct macsetting *settings)
+{
+ struct macsetting *next;
+ NESTED_TABLE(do_handle_macsetting, settings, 4);
+}
-void
-do_handle_macfeat (lua_State *L, struct macfeat *features) {
- dump_intfield(L,"feature", features->feature);
- dump_intfield(L,"ismutex", features->ismutex);
- dump_intfield(L,"default_setting", features->default_setting);
- dump_intfield(L,"strid", features->strid);
+void do_handle_macfeat(lua_State * L, struct macfeat *features)
+{
- if (features->featname != NULL) {
- lua_newtable(L);
- handle_macname(L,features->featname);
- lua_setfield(L,-2,"featname");
- }
+ dump_intfield(L, "feature", features->feature);
+ dump_intfield(L, "ismutex", features->ismutex);
+ dump_intfield(L, "default_setting", features->default_setting);
+ dump_intfield(L, "strid", features->strid);
- if (features->settings != NULL) {
- lua_newtable(L);
- handle_macsetting(L,features->settings);
- lua_setfield(L,-2,"settings");
- }
+ if (features->featname != NULL) {
+ lua_newtable(L);
+ handle_macname(L, features->featname);
+ lua_setfield(L, -2, "featname");
+ }
+
+ if (features->settings != NULL) {
+ lua_newtable(L);
+ handle_macsetting(L, features->settings);
+ lua_setfield(L, -2, "settings");
+ }
}
-void
-handle_macfeat (lua_State *L, struct macfeat *features) {
- struct macfeat *next;
- NESTED_TABLE(do_handle_macfeat,features,6);
+void handle_macfeat(lua_State * L, struct macfeat *features)
+{
+ struct macfeat *next;
+ NESTED_TABLE(do_handle_macfeat, features, 6);
}
@@ -1564,818 +1697,875 @@ handle_macfeat (lua_State *L, struct macfeat *features) {
0x3fff value offset
*/
/* to be tested */
-void
-do_handle_generic_asm (lua_State *L, struct generic_asm *sm) {
- int i, k;
-
- dump_enumfield (L,"type", sm->type, asm_type_enum);
- /* backref */
- dump_subtable_name(L, "lookup", sm->subtable);
- /* uint8 ticked; */
- lua_newtable(L);
- if (sm->flags & asm_vert) {
- lua_pushstring(L,"vert"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- if (sm->flags & asm_descending) {
- lua_pushstring(L,"descending"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- if (sm->flags & asm_always) {
- lua_pushstring(L,"always"); lua_pushboolean(L,1); lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"flags");
-
- if (sm->class_cnt >0) {
+void do_handle_generic_asm(lua_State * L, struct generic_asm *sm)
+{
+ int i, k;
+
+ dump_enumfield(L, "type", sm->type, asm_type_enum);
+ /* backref */
+ dump_subtable_name(L, "lookup", sm->subtable);
+ /* uint8 ticked; */
lua_newtable(L);
- for (i=0; i<sm->class_cnt; i++) {
- if (sm->classes[i]!=NULL) {
- lua_pushstring(L,sm->classes[i]);
- lua_rawseti(L,-2,(i+1));
- }
- }
- lua_setfield(L,-2,"classes");
- }
- if (sm->state_cnt >0) {
- lua_newtable(L);
- for (i=0; i<(sm->class_cnt * sm->state_cnt); i++) {
- struct asm_state as = sm->state[i];
- dump_intfield(L,"next", as.next_state);
- dump_intfield(L,"flags", as.flags);
- if (sm->type==asm_context) {
- lua_newtable(L);
- if (as.u.context.mark_lookup!=NULL)
- dump_stringfield(L,"mark", as.u.context.mark_lookup->lookup_name); /* backref */
- if (as.u.context.cur_lookup!=NULL)
- dump_stringfield(L,"cur", as.u.context.cur_lookup->lookup_name); /* backref */
- lua_setfield(L,-2,"context");
- } else if (sm->type==asm_insert) {
- lua_newtable(L);
- lua_pushstring(L, as.u.insert.mark_ins);
- lua_setfield(L, -2, "mark");
- lua_pushstring(L, as.u.insert.cur_ins);
- lua_setfield(L, -2, "cur");
- lua_setfield(L,-2,"insert");
- } else if (sm->type==asm_kern) {
- lua_newtable(L);
- for (k=0;k<as.u.kern.kcnt;k++) {
- lua_pushnumber(L,as.u.kern.kerns[k]);
- lua_rawseti(L,-2, (k+1));
- }
- lua_setfield(L,-2,"kerns");
- }
- }
- lua_setfield(L,-2,"states");
- }
-}
-
-void
-handle_generic_asm (lua_State *L, struct generic_asm *sm) {
- struct generic_asm *next;
- NESTED_TABLE(do_handle_generic_asm,sm,6);
-}
-
-
-
-
-void handle_MATH (lua_State *L, struct MATH *MATH) {
- dump_intfield(L,"ScriptPercentScaleDown",MATH->ScriptPercentScaleDown);
- dump_intfield(L,"ScriptScriptPercentScaleDown",MATH->ScriptScriptPercentScaleDown);
- dump_intfield(L,"DelimitedSubFormulaMinHeight",MATH->DelimitedSubFormulaMinHeight);
- dump_intfield(L,"DisplayOperatorMinHeight",MATH->DisplayOperatorMinHeight);
- dump_intfield(L,"MathLeading",MATH->MathLeading);
- dump_intfield(L,"AxisHeight",MATH->AxisHeight);
- dump_intfield(L,"AccentBaseHeight",MATH->AccentBaseHeight);
- dump_intfield(L,"FlattenedAccentBaseHeight",MATH->FlattenedAccentBaseHeight);
- dump_intfield(L,"SubscriptShiftDown",MATH->SubscriptShiftDown);
- dump_intfield(L,"SubscriptTopMax",MATH->SubscriptTopMax);
- dump_intfield(L,"SubscriptBaselineDropMin",MATH->SubscriptBaselineDropMin);
- dump_intfield(L,"SuperscriptShiftUp",MATH->SuperscriptShiftUp);
- dump_intfield(L,"SuperscriptShiftUpCramped",MATH->SuperscriptShiftUpCramped);
- dump_intfield(L,"SuperscriptBottomMin",MATH->SuperscriptBottomMin);
- dump_intfield(L,"SuperscriptBaselineDropMax",MATH->SuperscriptBaselineDropMax);
- dump_intfield(L,"SubSuperscriptGapMin",MATH->SubSuperscriptGapMin);
- dump_intfield(L,"SuperscriptBottomMaxWithSubscript",MATH->SuperscriptBottomMaxWithSubscript);
- dump_intfield(L,"SpaceAfterScript",MATH->SpaceAfterScript);
- dump_intfield(L,"UpperLimitGapMin",MATH->UpperLimitGapMin);
- dump_intfield(L,"UpperLimitBaselineRiseMin",MATH->UpperLimitBaselineRiseMin);
- dump_intfield(L,"LowerLimitGapMin",MATH->LowerLimitGapMin);
- dump_intfield(L,"LowerLimitBaselineDropMin",MATH->LowerLimitBaselineDropMin);
- dump_intfield(L,"StackTopShiftUp",MATH->StackTopShiftUp);
- dump_intfield(L,"StackTopDisplayStyleShiftUp",MATH->StackTopDisplayStyleShiftUp);
- dump_intfield(L,"StackBottomShiftDown",MATH->StackBottomShiftDown);
- dump_intfield(L,"StackBottomDisplayStyleShiftDown",MATH->StackBottomDisplayStyleShiftDown);
- dump_intfield(L,"StackGapMin",MATH->StackGapMin);
- dump_intfield(L,"StackDisplayStyleGapMin",MATH->StackDisplayStyleGapMin);
- dump_intfield(L,"StretchStackTopShiftUp",MATH->StretchStackTopShiftUp);
- dump_intfield(L,"StretchStackBottomShiftDown",MATH->StretchStackBottomShiftDown);
- dump_intfield(L,"StretchStackGapAboveMin",MATH->StretchStackGapAboveMin);
- dump_intfield(L,"StretchStackGapBelowMin",MATH->StretchStackGapBelowMin);
- dump_intfield(L,"FractionNumeratorShiftUp",MATH->FractionNumeratorShiftUp);
- dump_intfield(L,"FractionNumeratorDisplayStyleShiftUp",MATH->FractionNumeratorDisplayStyleShiftUp);
- dump_intfield(L,"FractionDenominatorShiftDown",MATH->FractionDenominatorShiftDown);
- dump_intfield(L,"FractionDenominatorDisplayStyleShiftDown",MATH->FractionDenominatorDisplayStyleShiftDown);
- dump_intfield(L,"FractionNumeratorGapMin",MATH->FractionNumeratorGapMin);
- dump_intfield(L,"FractionNumeratorDisplayStyleGapMin",MATH->FractionNumeratorDisplayStyleGapMin);
- dump_intfield(L,"FractionRuleThickness",MATH->FractionRuleThickness);
- dump_intfield(L,"FractionDenominatorGapMin",MATH->FractionDenominatorGapMin);
- dump_intfield(L,"FractionDenominatorDisplayStyleGapMin",MATH->FractionDenominatorDisplayStyleGapMin);
- dump_intfield(L,"SkewedFractionHorizontalGap",MATH->SkewedFractionHorizontalGap);
- dump_intfield(L,"SkewedFractionVerticalGap",MATH->SkewedFractionVerticalGap);
- dump_intfield(L,"OverbarVerticalGap",MATH->OverbarVerticalGap);
- dump_intfield(L,"OverbarRuleThickness",MATH->OverbarRuleThickness);
- dump_intfield(L,"OverbarExtraAscender",MATH->OverbarExtraAscender);
- dump_intfield(L,"UnderbarVerticalGap",MATH->UnderbarVerticalGap);
- dump_intfield(L,"UnderbarRuleThickness",MATH->UnderbarRuleThickness);
- dump_intfield(L,"UnderbarExtraDescender",MATH->UnderbarExtraDescender);
- dump_intfield(L,"RadicalVerticalGap",MATH->RadicalVerticalGap);
- dump_intfield(L,"RadicalDisplayStyleVerticalGap",MATH->RadicalDisplayStyleVerticalGap);
- dump_intfield(L,"RadicalRuleThickness",MATH->RadicalRuleThickness);
- dump_intfield(L,"RadicalExtraAscender",MATH->RadicalExtraAscender);
- dump_intfield(L,"RadicalKernBeforeDegree",MATH->RadicalKernBeforeDegree);
- dump_intfield(L,"RadicalKernAfterDegree",MATH->RadicalKernAfterDegree);
- dump_intfield(L,"RadicalDegreeBottomRaisePercent",MATH->RadicalDegreeBottomRaisePercent);
- dump_intfield(L,"MinConnectorOverlap",MATH->MinConnectorOverlap);
+ if (sm->flags & asm_vert) {
+ lua_pushstring(L, "vert");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ if (sm->flags & asm_descending) {
+ lua_pushstring(L, "descending");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ if (sm->flags & asm_always) {
+ lua_pushstring(L, "always");
+ lua_pushboolean(L, 1);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "flags");
+
+ if (sm->class_cnt > 0) {
+ lua_newtable(L);
+ for (i = 0; i < sm->class_cnt; i++) {
+ if (sm->classes[i] != NULL) {
+ lua_pushstring(L, sm->classes[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ }
+ lua_setfield(L, -2, "classes");
+ }
+ if (sm->state_cnt > 0) {
+ lua_newtable(L);
+ for (i = 0; i < (sm->class_cnt * sm->state_cnt); i++) {
+ struct asm_state as = sm->state[i];
+ dump_intfield(L, "next", as.next_state);
+ dump_intfield(L, "flags", as.flags);
+ if (sm->type == asm_context) {
+ lua_newtable(L);
+ if (as.u.context.mark_lookup != NULL)
+ dump_stringfield(L, "mark", as.u.context.mark_lookup->lookup_name); /* backref */
+ if (as.u.context.cur_lookup != NULL)
+ dump_stringfield(L, "cur", as.u.context.cur_lookup->lookup_name); /* backref */
+ lua_setfield(L, -2, "context");
+ } else if (sm->type == asm_insert) {
+ lua_newtable(L);
+ lua_pushstring(L, as.u.insert.mark_ins);
+ lua_setfield(L, -2, "mark");
+ lua_pushstring(L, as.u.insert.cur_ins);
+ lua_setfield(L, -2, "cur");
+ lua_setfield(L, -2, "insert");
+ } else if (sm->type == asm_kern) {
+ lua_newtable(L);
+ for (k = 0; k < as.u.kern.kcnt; k++) {
+ lua_pushnumber(L, as.u.kern.kerns[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ lua_setfield(L, -2, "kerns");
+ }
+ }
+ lua_setfield(L, -2, "states");
+ }
+}
+
+void handle_generic_asm(lua_State * L, struct generic_asm *sm)
+{
+ struct generic_asm *next;
+ NESTED_TABLE(do_handle_generic_asm, sm, 6);
+}
+
+
+
+
+void handle_MATH(lua_State * L, struct MATH *MATH)
+{
+ dump_intfield(L, "ScriptPercentScaleDown", MATH->ScriptPercentScaleDown);
+ dump_intfield(L, "ScriptScriptPercentScaleDown",
+ MATH->ScriptScriptPercentScaleDown);
+ dump_intfield(L, "DelimitedSubFormulaMinHeight",
+ MATH->DelimitedSubFormulaMinHeight);
+ dump_intfield(L, "DisplayOperatorMinHeight",
+ MATH->DisplayOperatorMinHeight);
+ dump_intfield(L, "MathLeading", MATH->MathLeading);
+ dump_intfield(L, "AxisHeight", MATH->AxisHeight);
+ dump_intfield(L, "AccentBaseHeight", MATH->AccentBaseHeight);
+ dump_intfield(L, "FlattenedAccentBaseHeight",
+ MATH->FlattenedAccentBaseHeight);
+ dump_intfield(L, "SubscriptShiftDown", MATH->SubscriptShiftDown);
+ dump_intfield(L, "SubscriptTopMax", MATH->SubscriptTopMax);
+ dump_intfield(L, "SubscriptBaselineDropMin",
+ MATH->SubscriptBaselineDropMin);
+ dump_intfield(L, "SuperscriptShiftUp", MATH->SuperscriptShiftUp);
+ dump_intfield(L, "SuperscriptShiftUpCramped",
+ MATH->SuperscriptShiftUpCramped);
+ dump_intfield(L, "SuperscriptBottomMin", MATH->SuperscriptBottomMin);
+ dump_intfield(L, "SuperscriptBaselineDropMax",
+ MATH->SuperscriptBaselineDropMax);
+ dump_intfield(L, "SubSuperscriptGapMin", MATH->SubSuperscriptGapMin);
+ dump_intfield(L, "SuperscriptBottomMaxWithSubscript",
+ MATH->SuperscriptBottomMaxWithSubscript);
+ dump_intfield(L, "SpaceAfterScript", MATH->SpaceAfterScript);
+ dump_intfield(L, "UpperLimitGapMin", MATH->UpperLimitGapMin);
+ dump_intfield(L, "UpperLimitBaselineRiseMin",
+ MATH->UpperLimitBaselineRiseMin);
+ dump_intfield(L, "LowerLimitGapMin", MATH->LowerLimitGapMin);
+ dump_intfield(L, "LowerLimitBaselineDropMin",
+ MATH->LowerLimitBaselineDropMin);
+ dump_intfield(L, "StackTopShiftUp", MATH->StackTopShiftUp);
+ dump_intfield(L, "StackTopDisplayStyleShiftUp",
+ MATH->StackTopDisplayStyleShiftUp);
+ dump_intfield(L, "StackBottomShiftDown", MATH->StackBottomShiftDown);
+ dump_intfield(L, "StackBottomDisplayStyleShiftDown",
+ MATH->StackBottomDisplayStyleShiftDown);
+ dump_intfield(L, "StackGapMin", MATH->StackGapMin);
+ dump_intfield(L, "StackDisplayStyleGapMin", MATH->StackDisplayStyleGapMin);
+ dump_intfield(L, "StretchStackTopShiftUp", MATH->StretchStackTopShiftUp);
+ dump_intfield(L, "StretchStackBottomShiftDown",
+ MATH->StretchStackBottomShiftDown);
+ dump_intfield(L, "StretchStackGapAboveMin", MATH->StretchStackGapAboveMin);
+ dump_intfield(L, "StretchStackGapBelowMin", MATH->StretchStackGapBelowMin);
+ dump_intfield(L, "FractionNumeratorShiftUp",
+ MATH->FractionNumeratorShiftUp);
+ dump_intfield(L, "FractionNumeratorDisplayStyleShiftUp",
+ MATH->FractionNumeratorDisplayStyleShiftUp);
+ dump_intfield(L, "FractionDenominatorShiftDown",
+ MATH->FractionDenominatorShiftDown);
+ dump_intfield(L, "FractionDenominatorDisplayStyleShiftDown",
+ MATH->FractionDenominatorDisplayStyleShiftDown);
+ dump_intfield(L, "FractionNumeratorGapMin", MATH->FractionNumeratorGapMin);
+ dump_intfield(L, "FractionNumeratorDisplayStyleGapMin",
+ MATH->FractionNumeratorDisplayStyleGapMin);
+ dump_intfield(L, "FractionRuleThickness", MATH->FractionRuleThickness);
+ dump_intfield(L, "FractionDenominatorGapMin",
+ MATH->FractionDenominatorGapMin);
+ dump_intfield(L, "FractionDenominatorDisplayStyleGapMin",
+ MATH->FractionDenominatorDisplayStyleGapMin);
+ dump_intfield(L, "SkewedFractionHorizontalGap",
+ MATH->SkewedFractionHorizontalGap);
+ dump_intfield(L, "SkewedFractionVerticalGap",
+ MATH->SkewedFractionVerticalGap);
+ dump_intfield(L, "OverbarVerticalGap", MATH->OverbarVerticalGap);
+ dump_intfield(L, "OverbarRuleThickness", MATH->OverbarRuleThickness);
+ dump_intfield(L, "OverbarExtraAscender", MATH->OverbarExtraAscender);
+ dump_intfield(L, "UnderbarVerticalGap", MATH->UnderbarVerticalGap);
+ dump_intfield(L, "UnderbarRuleThickness", MATH->UnderbarRuleThickness);
+ dump_intfield(L, "UnderbarExtraDescender", MATH->UnderbarExtraDescender);
+ dump_intfield(L, "RadicalVerticalGap", MATH->RadicalVerticalGap);
+ dump_intfield(L, "RadicalDisplayStyleVerticalGap",
+ MATH->RadicalDisplayStyleVerticalGap);
+ dump_intfield(L, "RadicalRuleThickness", MATH->RadicalRuleThickness);
+ dump_intfield(L, "RadicalExtraAscender", MATH->RadicalExtraAscender);
+ dump_intfield(L, "RadicalKernBeforeDegree", MATH->RadicalKernBeforeDegree);
+ dump_intfield(L, "RadicalKernAfterDegree", MATH->RadicalKernAfterDegree);
+ dump_intfield(L, "RadicalDegreeBottomRaisePercent",
+ MATH->RadicalDegreeBottomRaisePercent);
+ dump_intfield(L, "MinConnectorOverlap", MATH->MinConnectorOverlap);
}
/* the handling of BASE is untested, no font */
-void handle_baselangextent (lua_State *L, struct baselangextent *ble);
+void handle_baselangextent(lua_State * L, struct baselangextent *ble);
-void
-do_handle_baselangextent (lua_State *L, struct baselangextent *ble) {
- dump_tag(L,"tag",ble->lang);
- dump_intfield(L,"ascent",ble->ascent);
- dump_intfield(L,"descent",ble->descent);
- lua_newtable(L);
- handle_baselangextent(L, ble->features);
- lua_setfield(L,-2,"features");
+void do_handle_baselangextent(lua_State * L, struct baselangextent *ble)
+{
+ dump_tag(L, "tag", ble->lang);
+ dump_intfield(L, "ascent", ble->ascent);
+ dump_intfield(L, "descent", ble->descent);
+ lua_newtable(L);
+ handle_baselangextent(L, ble->features);
+ lua_setfield(L, -2, "features");
}
-void handle_baselangextent (lua_State *L, struct baselangextent *ble) {
- struct baselangextent *next;
- NESTED_TABLE(do_handle_baselangextent,ble,4);
+void handle_baselangextent(lua_State * L, struct baselangextent *ble)
+{
+ struct baselangextent *next;
+ NESTED_TABLE(do_handle_baselangextent, ble, 4);
}
-void handle_base (lua_State *L, struct Base *Base) {
- int i;
- struct basescript *next = Base->scripts;
- lua_newtable(L);
- for ( i=0; i<Base->baseline_cnt; i++ ) {
- lua_pushstring(L,make_tag_string(Base->baseline_tags[i]));
- lua_rawseti(L,-2,(i+1));
- }
- lua_setfield(L,-2,"tags");
- if (next != NULL) {
+void handle_base(lua_State * L, struct Base *Base)
+{
+ int i;
+ struct basescript *next = Base->scripts;
lua_newtable(L);
- while (next != NULL) {
- lua_pushstring(L,make_tag_string(next->script));
- lua_newtable(L);
- dump_intfield(L, "default_baseline", (next->def_baseline+1)) ;
- lua_newtable(L);
- for ( i=0; i<Base->baseline_cnt; i++ ) {
- lua_pushnumber(L, next->baseline_pos[i]) ;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L, -2, "baseline");
- lua_newtable(L);
- handle_baselangextent(L, next->langs);
- lua_setfield(L, -2, "lang");
- lua_rawset(L,-3);
- next = next->next;
- }
- lua_setfield(L,-2,"scripts");
- }
+ for (i = 0; i < Base->baseline_cnt; i++) {
+ lua_pushstring(L, make_tag_string(Base->baseline_tags[i]));
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "tags");
+ if (next != NULL) {
+ lua_newtable(L);
+ while (next != NULL) {
+ lua_pushstring(L, make_tag_string(next->script));
+ lua_newtable(L);
+ dump_intfield(L, "default_baseline", (next->def_baseline + 1));
+ lua_newtable(L);
+ for (i = 0; i < Base->baseline_cnt; i++) {
+ if (next->baseline_pos != NULL) /* default omitted */
+ lua_pushnumber(L, next->baseline_pos[i]);
+ else
+ lua_pushnumber(L, 0);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "baseline");
+ lua_newtable(L);
+ handle_baselangextent(L, next->langs);
+ lua_setfield(L, -2, "lang");
+ lua_rawset(L, -3);
+ next = next->next;
+ }
+ lua_setfield(L, -2, "scripts");
+ }
}
-void
-handle_axismap (lua_State *L, struct axismap *am) {
- int i;
- lua_checkstack(L,3);
- lua_newtable(L);
- for (i=0;i<am->points;i++) {
- lua_pushnumber(L, am->blends[i] ) ;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L,-2,"blends");
- lua_newtable(L);
- for (i=0;i<am->points;i++) {
- lua_pushnumber(L, am->designs[i] ) ;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L,-2,"designs");
- dump_realfield(L, "min", am->min) ;
- dump_realfield(L, "def", am->def) ;
- dump_realfield(L, "max", am->max) ;
- if (am->axisnames != NULL ){
+void handle_axismap(lua_State * L, struct axismap *am)
+{
+ int i;
+ lua_checkstack(L, 3);
lua_newtable(L);
- handle_macname(L, am->axisnames);
- lua_setfield(L,-2,"axisnames");
- }
-}
+ for (i = 0; i < am->points; i++) {
+ lua_pushnumber(L, am->blends[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "blends");
+ lua_newtable(L);
+ for (i = 0; i < am->points; i++) {
+ lua_pushnumber(L, am->designs[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "designs");
+ dump_realfield(L, "min", am->min);
+ dump_realfield(L, "def", am->def);
+ dump_realfield(L, "max", am->max);
+ if (am->axisnames != NULL) {
+ lua_newtable(L);
+ handle_macname(L, am->axisnames);
+ lua_setfield(L, -2, "axisnames");
+ }
+}
-void
-handle_mmset (lua_State *L, struct mmset *mm) {
- int i, k;
- lua_newtable(L);
- for (i=0;i<mm->axis_count;i++) {
- lua_pushstring(L, mm->axes[i]) ;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L,-2,"axes");
-
- dump_intfield(L,"instance_count",mm->instance_count);
- /* SplineFont *normal; */ /* this is the parent */
- if (mm->instance_count>0) {
+void handle_mmset(lua_State * L, struct mmset *mm)
+{
+ int i, k;
lua_newtable(L);
- for (i=0;i<mm->instance_count*mm->axis_count;i++) {
- lua_pushnumber(L, mm->positions[i]) ;
- lua_rawseti(L,-2, (i+1));
+ for (i = 0; i < mm->axis_count; i++) {
+ lua_pushstring(L, mm->axes[i]);
+ lua_rawseti(L, -2, (i + 1));
}
- lua_setfield(L,-2,"positions");
+ lua_setfield(L, -2, "axes");
+
+ dump_intfield(L, "instance_count", mm->instance_count);
+ /* SplineFont *normal; *//* this is the parent */
+ if (mm->instance_count > 0) {
+ lua_newtable(L);
+ for (i = 0; i < mm->instance_count * mm->axis_count; i++) {
+ lua_pushnumber(L, mm->positions[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "positions");
- /* better not to do this */
+ /* better not to do this */
#if 0
- {
- struct mmset *mmsave ;
- lua_newtable(L);
- for (i=0;i<mm->instance_count;i++) {
- lua_checkstack(L,20);
- lua_createtable(L,0,60);
- mmsave = mm->instances[i]->mm;
- mm->instances[i]->mm = NULL;
- handle_splinefont(L, mm->instances[i]);
- mm->instances[i]->mm = mmsave;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L,-2,"instances");
- }
+ {
+ struct mmset *mmsave;
+ lua_newtable(L);
+ for (i = 0; i < mm->instance_count; i++) {
+ lua_checkstack(L, 20);
+ lua_createtable(L, 0, 60);
+ mmsave = mm->instances[i]->mm;
+ mm->instances[i]->mm = NULL;
+ handle_splinefont(L, mm->instances[i]);
+ mm->instances[i]->mm = mmsave;
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "instances");
+ }
#endif
- lua_newtable(L);
- for (i=0;i<mm->instance_count;i++) {
- lua_pushnumber(L, mm->defweights[i]) ;
- lua_rawseti(L,-2, (i+1));
- }
- lua_setfield(L,-2,"defweights");
- }
-
- if (mm->axismaps != NULL) {
- lua_newtable(L);
- for (i=0;i<mm->axis_count;i++) {
- lua_newtable(L);
- handle_axismap(L, &(mm->axismaps[i]));
- lua_rawseti(L, -2, (i+1));
+ lua_newtable(L);
+ for (i = 0; i < mm->instance_count; i++) {
+ lua_pushnumber(L, mm->defweights[i]);
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "defweights");
}
- lua_setfield(L,-2,"axismaps");
- }
- dump_stringfield(L,"cdv",mm->cdv);
- dump_stringfield(L,"ndv",mm->ndv);
- dump_intfield(L,"named_instance_count",mm->named_instance_count);
- if (mm->named_instance_count>0) {
- lua_newtable(L);
- for (i=0; i<mm->named_instance_count;i++) {
- struct named_instance *ni = &(mm->named_instances[i]);
+ if (mm->axismaps != NULL) {
lua_newtable(L);
+ for (i = 0; i < mm->axis_count; i++) {
+ lua_newtable(L);
+ handle_axismap(L, &(mm->axismaps[i]));
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "axismaps");
+ }
+ dump_stringfield(L, "cdv", mm->cdv);
+ dump_stringfield(L, "ndv", mm->ndv);
+ dump_intfield(L, "named_instance_count", mm->named_instance_count);
+ if (mm->named_instance_count > 0) {
+ lua_newtable(L);
+ for (i = 0; i < mm->named_instance_count; i++) {
+ struct named_instance *ni = &(mm->named_instances[i]);
+ lua_newtable(L);
+
+ lua_newtable(L);
+ for (k = 0; k <= mm->axis_count; k++) {
+ lua_pushnumber(L, ni->coords[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ lua_setfield(L, -2, "coords");
+
+ lua_newtable(L);
+ handle_macname(L, ni->names);
+ lua_setfield(L, -2, "names");
+
+ lua_rawseti(L, -2, (i + 1));
+ }
+ lua_setfield(L, -2, "named_instances");
+ }
+ /* unsigned int changed: 1; */
+ dump_intfield(L, "apple", mm->apple);
+}
+
+
+
+void handle_splinefont(lua_State * L, struct splinefont *sf)
+{
+ int k;
+ int fix_notdef = 0;
+ int l = -1;
+
+ dump_stringfield(L, "table_version", LUA_OTF_VERSION);
+ dump_stringfield(L, "fontname", sf->fontname);
+ dump_stringfield(L, "fullname", sf->fullname);
+ dump_stringfield(L, "familyname", sf->familyname);
+ dump_stringfield(L, "weight", sf->weight);
+ dump_stringfield(L, "copyright", sf->copyright);
+ dump_stringfield(L, "filename", sf->filename);
+ /* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */
+ dump_stringfield(L, "version", sf->version);
+ dump_floatfield(L, "italicangle", sf->italicangle);
+ dump_floatfield(L, "upos", sf->upos);
+ dump_floatfield(L, "uwidth", sf->uwidth);
+ dump_intfield(L, "ascent", sf->ascent);
+ dump_intfield(L, "descent", sf->descent);
+ dump_intfield(L, "uniqueid", sf->uniqueid);
+ dump_intfield(L, "glyphcnt", sf->glyphcnt);
+ dump_intfield(L, "glyphmax", sf->glyphmax);
+ dump_intfield(L, "units_per_em", sf->units_per_em);
+
+ if (sf->possub != NULL) {
lua_newtable(L);
- for (k=0;k<=mm->axis_count;k++) {
- lua_pushnumber(L,ni->coords[k]);
- lua_rawseti(L,-2,(k+1));
+ handle_generic_fpst(L, sf->possub);
+ lua_setfield(L, -2, "lookups");
+ }
+
+ lua_checkstack(L, 4);
+ lua_createtable(L, sf->glyphcnt, 0);
+
+ /* This after-the-fact type discovery is not brilliant,
+ I should really add a 'format' key in the structure */
+ if ((sf->origname != NULL) &&
+ (strmatch(sf->origname + strlen(sf->origname) - 4, ".pfa") == 0 ||
+ strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) {
+ fix_notdef = 1;
+ }
+
+ if (fix_notdef) {
+ /* some code to ensure that the .notdef ends up in slot 0
+ (this will actually be enforced by the CFF writer) */
+ for (k = 0; k < sf->glyphcnt; k++) {
+ if (sf->glyphs[k]) {
+ if (strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
+ l = k;
+ }
+ }
+ }
+ if (l == -1) { /* fake a .notdef at the end */
+ l = sf->glyphcnt;
+ }
+ for (k = 0; k < l; k++) {
+ if (sf->glyphs[k]) {
+ lua_pushnumber(L, (k + 1));
+ lua_createtable(L, 0, 12);
+ handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics);
+ lua_rawset(L, -3);
+ }
+ }
+ if (sf->glyphs != NULL && l < sf->glyphcnt) {
+ lua_pushnumber(L, 0);
+ if (sf->glyphs[l]) {
+ lua_createtable(L, 0, 12);
+ handle_splinechar(L, sf->glyphs[l], sf->hasvmetrics);
+ } else {
+ lua_createtable(L, 0, 0);
+ }
+ lua_rawset(L, -3);
+ }
+ }
+ if ((l + 1) < sf->glyphcnt) {
+ for (k = (l + 1); k < sf->glyphcnt; k++) {
+ if (sf->glyphs[k]) {
+ lua_pushnumber(L, k);
+ lua_createtable(L, 0, 12);
+ handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics);
+ lua_rawset(L, -3);
+ }
}
- lua_setfield(L,-2,"coords");
+ }
+ lua_setfield(L, -2, "glyphs");
+
+ /* dump_intfield(L,"changed", sf->changed); */
+ dump_intfield(L, "hasvmetrics", sf->hasvmetrics);
+ dump_intfield(L, "onlybitmaps", sf->onlybitmaps);
+ dump_intfield(L, "serifcheck", sf->serifcheck);
+ dump_intfield(L, "isserif", sf->isserif);
+ dump_intfield(L, "issans", sf->issans);
+ dump_intfield(L, "encodingchanged", sf->encodingchanged);
+ dump_intfield(L, "strokedfont", sf->strokedfont);
+ dump_intfield(L, "use_typo_metrics", sf->use_typo_metrics);
+ dump_intfield(L, "weight_width_slope_only", sf->weight_width_slope_only);
+ dump_intfield(L, "head_optimized_for_cleartype",
+ sf->head_optimized_for_cleartype);
+
+ dump_enumfield(L, "uni_interp", (sf->uni_interp + 1), uni_interp_enum);
+
+ if (sf->map != NULL) {
+ lua_newtable(L);
+ handle_encmap(L, sf->map, l);
+ lua_setfield(L, -2, "map");
+ }
+
+ dump_stringfield(L, "origname", sf->origname); /* new */
+ if (sf->private != NULL) {
lua_newtable(L);
- handle_macname(L, ni->names);
- lua_setfield(L,-2,"names");
+ handle_psdict(L, sf->private);
+ lua_setfield(L, -2, "private");
+ }
- lua_rawseti(L,-2,(i+1));
- }
- lua_setfield(L,-2,"named_instances");
- }
- /* unsigned int changed: 1; */
- dump_intfield(L,"apple",mm->apple);
-}
+ dump_stringfield(L, "xuid", sf->xuid);
+ lua_createtable(L, 0, 40);
+ handle_pfminfo(L, sf->pfminfo);
+ lua_setfield(L, -2, "pfminfo");
+ if (sf->names != NULL) {
+ lua_newtable(L);
+ handle_ttflangname(L, sf->names);
+ lua_setfield(L, -2, "names");
+ }
-void
-handle_splinefont(lua_State *L, struct splinefont *sf) {
- int k;
- int fix_notdef = 0;
- int l = -1;
-
- dump_stringfield(L,"table_version", LUA_OTF_VERSION);
- dump_stringfield(L,"fontname", sf->fontname);
- dump_stringfield(L,"fullname", sf->fullname);
- dump_stringfield(L,"familyname", sf->familyname);
- dump_stringfield(L,"weight", sf->weight);
- dump_stringfield(L,"copyright", sf->copyright);
- dump_stringfield(L,"filename", sf->filename);
- /* dump_stringfield(L,"defbasefilename", sf->defbasefilename); */
- dump_stringfield(L,"version", sf->version);
- dump_floatfield (L,"italicangle", sf->italicangle);
- dump_floatfield (L,"upos", sf->upos);
- dump_floatfield (L,"uwidth", sf->uwidth);
- dump_intfield (L,"ascent", sf->ascent);
- dump_intfield (L,"descent", sf->descent);
- dump_intfield (L,"uniqueid", sf->uniqueid);
- dump_intfield (L,"glyphcnt", sf->glyphcnt);
- dump_intfield (L,"glyphmax", sf->glyphmax);
- dump_intfield (L,"units_per_em", sf->units_per_em);
-
- if (sf->possub != NULL) {
- lua_newtable(L);
- handle_generic_fpst(L,sf->possub);
- lua_setfield(L,-2,"lookups");
- }
-
- lua_checkstack(L,4);
- lua_createtable(L,sf->glyphcnt,0);
-
- /* This after-the-fact type discovery is not brilliant,
- I should really add a 'format' key in the structure */
- if ((sf->origname != NULL) &&
- (strmatch(sf->origname+strlen(sf->origname)-4, ".pfa")==0 ||
- strmatch(sf->origname+strlen(sf->origname)-4, ".pfb")==0)) {
- fix_notdef = 1;
- }
-
- if (fix_notdef) {
- /* some code to ensure that the .notdef ends up in slot 0
- (this will actually be enforced by the CFF writer) */
- for (k=0;k<sf->glyphcnt;k++) {
- if (sf->glyphs[k]) {
- if (strcmp(sf->glyphs[k]->name,".notdef") == 0) {
- l = k;
+ lua_createtable(L, 0, 4);
+ dump_stringfield(L, "registry", sf->cidregistry);
+ dump_stringfield(L, "ordering", sf->ordering);
+ dump_intfield(L, "version", sf->cidversion);
+ dump_intfield(L, "supplement", sf->supplement);
+ lua_setfield(L, -2, "cidinfo");
+
+ /* SplineFont *cidmaster *//* parent in a subfont */
+ if (sf->subfontcnt > 0) {
+ lua_createtable(L, sf->subfontcnt, 0);
+ for (k = 0; k < sf->subfontcnt; k++) {
+ lua_checkstack(L, 10);
+ lua_newtable(L);
+ handle_splinefont(L, sf->subfonts[k]);
+ lua_rawseti(L, -2, (k + 1));
}
- }
- }
- if (l==-1) { /* fake a .notdef at the end */
- l = sf->glyphcnt;
- }
- for (k=0;k<l;k++) {
- lua_pushnumber(L,(k+1));
- lua_createtable(L,0,12);
- if (sf->glyphs[k]) {
- handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics);
- }
- lua_rawset(L,-3);
- }
- if (sf->glyphs != NULL && l<sf->glyphcnt) {
- lua_pushnumber(L,0);
- lua_createtable(L,0,12);
- if (sf->glyphs[l]) {
- handle_splinechar(L,sf->glyphs[l], sf->hasvmetrics);
- }
- lua_rawset(L,-3);
- }
- }
- if ((l+1)<sf->glyphcnt) {
- for (k=(l+1);k<sf->glyphcnt;k++) {
- lua_pushnumber(L,k);
- lua_createtable(L,0,12);
- if (sf->glyphs[k]) {
- handle_splinechar(L,sf->glyphs[k], sf->hasvmetrics);
- }
- lua_rawset(L,-3);
- }
- }
- lua_setfield(L,-2,"glyphs");
-
- /* dump_intfield(L,"changed", sf->changed); */
- dump_intfield(L,"hasvmetrics", sf->hasvmetrics);
- dump_intfield(L,"onlybitmaps", sf->onlybitmaps);
- dump_intfield(L,"serifcheck", sf->serifcheck);
- dump_intfield(L,"isserif", sf->isserif);
- dump_intfield(L,"issans", sf->issans);
- dump_intfield(L,"encodingchanged", sf->encodingchanged);
- dump_intfield(L,"strokedfont", sf->strokedfont);
- dump_intfield(L,"use_typo_metrics", sf->use_typo_metrics);
- dump_intfield(L,"weight_width_slope_only", sf->weight_width_slope_only);
- dump_intfield(L,"head_optimized_for_cleartype",sf->head_optimized_for_cleartype);
-
- dump_enumfield(L,"uni_interp", (sf->uni_interp+1), uni_interp_enum);
-
- if (sf->map != NULL ) {
- lua_newtable(L);
- handle_encmap(L,sf->map, l);
- lua_setfield(L,-2,"map");
- }
+ lua_setfield(L, -2, "subfonts");
+ }
- dump_stringfield(L,"origname", sf->origname); /* new */
+ dump_stringfield(L, "comments", sf->comments);
+ dump_stringfield(L, "fontlog", sf->fontlog);
- if (sf->private != NULL) {
- lua_newtable(L);
- handle_psdict(L, sf->private);
- lua_setfield(L,-2,"private");
- }
-
- dump_stringfield(L,"xuid", sf->xuid);
-
- lua_createtable(L,0,40);
- handle_pfminfo(L,sf->pfminfo);
- lua_setfield(L,-2,"pfminfo");
-
- if (sf->names != NULL) {
- lua_newtable(L);
- handle_ttflangname(L,sf->names);
- lua_setfield(L,-2,"names");
- }
-
- lua_createtable(L,0,4);
- dump_stringfield(L,"registry", sf->cidregistry);
- dump_stringfield(L,"ordering", sf->ordering);
- dump_intfield (L,"version", sf->cidversion);
- dump_intfield (L,"supplement", sf->supplement);
- lua_setfield(L,-2,"cidinfo");
-
- /* SplineFont *cidmaster */ /* parent in a subfont */
- if (sf->subfontcnt>0) {
- lua_createtable(L,sf->subfontcnt,0);
- for (k=0;k<sf->subfontcnt;k++) {
- lua_checkstack(L,10);
- lua_newtable(L);
- handle_splinefont(L,sf->subfonts[k]);
- lua_rawseti(L,-2,(k+1));
- }
- lua_setfield(L,-2,"subfonts");
- }
-
- dump_stringfield(L,"comments", sf->comments);
- dump_stringfield(L,"fontlog", sf->fontlog);
-
- if (sf->cvt_names != NULL) {
- lua_newtable(L);
- for (k=0; sf->cvt_names[k]!=END_CVT_NAMES; ++k) {
- lua_pushstring(L, sf->cvt_names[k]);
- lua_rawseti(L,-2,(k+1));
+ if (sf->cvt_names != NULL) {
+ lua_newtable(L);
+ for (k = 0; sf->cvt_names[k] != END_CVT_NAMES; ++k) {
+ lua_pushstring(L, sf->cvt_names[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ lua_setfield(L, -2, "cvt_names");
}
- lua_setfield(L,-2,"cvt_names");
- }
- if (sf->ttf_tables != NULL) {
- lua_newtable(L);
- handle_ttf_table(L,sf->ttf_tables);
- lua_setfield(L,-2,"ttf_tables");
- }
+ if (sf->ttf_tables != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tables);
+ lua_setfield(L, -2, "ttf_tables");
+ }
- if (sf->ttf_tab_saved != NULL) {
- lua_newtable(L);
- handle_ttf_table(L,sf->ttf_tab_saved);
- lua_setfield(L,-2,"ttf_tab_saved");
- }
+ if (sf->ttf_tab_saved != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tab_saved);
+ lua_setfield(L, -2, "ttf_tab_saved");
+ }
- if (sf->texdata.type != tex_unset) {
- lua_newtable(L);
- dump_enumfield(L,"type", sf->texdata.type, tex_type_enum);
- lua_newtable(L);
- for (k=0;k<22;k++) {
- lua_pushnumber(L,k);
- lua_pushnumber(L,sf->texdata.params[k]);
- lua_rawset(L,-3);
- }
- lua_setfield(L,-2,"params");
- lua_setfield(L,-2,"texdata");
- }
- if (sf->anchor != NULL) {
- lua_newtable(L);
- handle_anchorclass(L,sf->anchor);
- lua_setfield(L,-2,"anchor_classes");
- }
- if (sf->kerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L,sf->kerns);
- lua_setfield(L,-2,"kerns");
- }
- if (sf->vkerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L,sf->vkerns);
- lua_setfield(L,-2,"vkerns");
- }
- if (sf->gsub_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L,sf->gsub_lookups);
- lua_setfield(L,-2,"gsub");
- }
- if (sf->gpos_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L,sf->gpos_lookups);
- lua_setfield(L,-2,"gpos");
- }
+ if (sf->texdata.type != tex_unset) {
+ lua_newtable(L);
+ dump_enumfield(L, "type", sf->texdata.type, tex_type_enum);
+ lua_newtable(L);
+ for (k = 0; k < 22; k++) {
+ lua_pushnumber(L, k);
+ lua_pushnumber(L, sf->texdata.params[k]);
+ lua_rawset(L, -3);
+ }
+ lua_setfield(L, -2, "params");
+ lua_setfield(L, -2, "texdata");
+ }
+ if (sf->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorclass(L, sf->anchor);
+ lua_setfield(L, -2, "anchor_classes");
+ }
+ if (sf->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->kerns);
+ lua_setfield(L, -2, "kerns");
+ }
+ if (sf->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->vkerns);
+ lua_setfield(L, -2, "vkerns");
+ }
+ if (sf->gsub_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gsub_lookups, sf);
+ lua_setfield(L, -2, "gsub");
+ }
+ if (sf->gpos_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gpos_lookups, sf);
+ lua_setfield(L, -2, "gpos");
+ }
- if (sf->sm != NULL) {
- lua_newtable(L);
- handle_generic_asm(L,sf->sm);
- lua_setfield(L,-2,"sm");
- }
- if (sf->features != NULL) {
- lua_newtable(L);
- handle_macfeat(L,sf->features);
- lua_setfield(L,-2,"features");
- }
- if (sf->mm != NULL) {
- lua_newtable(L);
- handle_mmset (L,sf->mm);
- lua_setfield(L,-2,"mm");
- }
- dump_stringfield(L,"chosenname", sf->chosenname);
-
- dump_intfield(L,"macstyle", sf->macstyle);
- dump_stringfield(L,"fondname", sf->fondname);
-
- dump_intfield(L,"design_size", sf->design_size);
- dump_intfield(L,"fontstyle_id", sf->fontstyle_id);
-
- if (sf->fontstyle_name != NULL) {
- lua_newtable(L);
- handle_otfname(L,sf->fontstyle_name);
- lua_setfield(L,-2,"fontstyle_name");
- }
-
- dump_intfield(L,"design_range_bottom",sf->design_range_bottom);
- dump_intfield(L,"design_range_top", sf->design_range_top);
- dump_floatfield(L,"strokewidth", sf->strokewidth);
-
- if (sf->mark_class_cnt>0) {
- lua_newtable(L);
- for ( k=0; k<sf->mark_class_cnt; ++k ) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,sf->mark_classes[k]);
- lua_rawset(L,-3);
+ if (sf->sm != NULL) {
+ lua_newtable(L);
+ handle_generic_asm(L, sf->sm);
+ lua_setfield(L, -2, "sm");
+ }
+ if (sf->features != NULL) {
+ lua_newtable(L);
+ handle_macfeat(L, sf->features);
+ lua_setfield(L, -2, "features");
}
- lua_setfield(L,-1,"mark_classes");
+ if (sf->mm != NULL) {
+ lua_newtable(L);
+ handle_mmset(L, sf->mm);
+ lua_setfield(L, -2, "mm");
+ }
+ dump_stringfield(L, "chosenname", sf->chosenname);
- lua_newtable(L);
- for ( k=0; k<sf->mark_class_cnt; ++k ) {
- lua_pushnumber(L,(k+1));
- lua_pushstring(L,sf->mark_class_names[k]);
- lua_rawset(L,-3);
+ dump_intfield(L, "macstyle", sf->macstyle);
+ dump_stringfield(L, "fondname", sf->fondname);
+
+ dump_intfield(L, "design_size", sf->design_size);
+ dump_intfield(L, "fontstyle_id", sf->fontstyle_id);
+
+ if (sf->fontstyle_name != NULL) {
+ lua_newtable(L);
+ handle_otfname(L, sf->fontstyle_name);
+ lua_setfield(L, -2, "fontstyle_name");
}
- lua_setfield(L,-1,"mark_class_names");
- }
-
- dump_intfield(L,"creationtime", sf->creationtime);
- dump_intfield(L,"modificationtime", sf->modificationtime);
- dump_intfield(L,"os2_version", sf->os2_version);
- dump_intfield(L,"sfd_version", sf->sfd_version);
+ dump_intfield(L, "design_range_bottom", sf->design_range_bottom);
+ dump_intfield(L, "design_range_top", sf->design_range_top);
+ dump_floatfield(L, "strokewidth", sf->strokewidth);
- if (sf->MATH != NULL) {
- lua_newtable(L);
- handle_MATH(L, sf->MATH);
- lua_setfield(L,-2,"math");
- }
-
- if (sf->loadvalidation_state != 0) {
- int val, st;
- lua_newtable(L);
- val = 1;
- st = sf->loadvalidation_state;
- if (st & lvs_bad_ps_fontname) {
- lua_pushliteral(L, "bad_ps_fontname"); lua_rawseti(L,-2,val++);
+ if (sf->mark_class_cnt > 0) {
+ lua_newtable(L);
+ for (k = 0; k < sf->mark_class_cnt; k++) {
+ if (sf->mark_class_names[k] != NULL) {
+ lua_pushstring(L, sf->mark_class_names[k]);
+ lua_pushstring(L, sf->mark_classes[k]);
+ lua_rawset(L, -3);
+ }
+ }
+ lua_setfield(L, -2, "mark_classes");
}
- if (st & lvs_bad_glyph_table) {
- lua_pushliteral(L, "bad_glyph_table"); lua_rawseti(L,-2,val++);
+
+ dump_intfield(L, "creationtime", sf->creationtime);
+ dump_intfield(L, "modificationtime", sf->modificationtime);
+
+ dump_intfield(L, "os2_version", sf->os2_version);
+ dump_intfield(L, "sfd_version", sf->sfd_version);
+
+ if (sf->MATH != NULL) {
+ lua_newtable(L);
+ handle_MATH(L, sf->MATH);
+ lua_setfield(L, -2, "math");
+ }
+
+ if (sf->loadvalidation_state != 0) {
+ int val, st;
+ lua_newtable(L);
+ val = 1;
+ st = sf->loadvalidation_state;
+ if (st & lvs_bad_ps_fontname) {
+ lua_pushliteral(L, "bad_ps_fontname");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_glyph_table) {
+ lua_pushliteral(L, "bad_glyph_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_cff_table) {
+ lua_pushliteral(L, "bad_cff_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_metrics_table) {
+ lua_pushliteral(L, "bad_metrics_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_cmap_table) {
+ lua_pushliteral(L, "bad_cmap_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_bitmaps_table) {
+ lua_pushliteral(L, "bad_bitmaps_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_gx_table) {
+ lua_pushliteral(L, "bad_gx_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_ot_table) {
+ lua_pushliteral(L, "bad_ot_table");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_os2_version) {
+ lua_pushliteral(L, "bad_os2_version");
+ lua_rawseti(L, -2, val++);
+ }
+ if (st & lvs_bad_sfnt_header) {
+ lua_pushliteral(L, "bad_sfnt_header");
+ lua_rawseti(L, -2, val++);
+ }
+ lua_setfield(L, -2, "validation_state");
}
- if (st & lvs_bad_cff_table) {
- lua_pushliteral(L, "bad_cff_table"); lua_rawseti(L,-2,val++);
+
+ if (sf->horiz_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->horiz_base);
+ lua_setfield(L, -2, "horiz_base");
}
- if (st & lvs_bad_metrics_table) {
- lua_pushliteral(L, "bad_metrics_table"); lua_rawseti(L,-2,val++);
+ if (sf->vert_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->vert_base);
+ lua_setfield(L, -2, "vert_base");
}
- if (st & lvs_bad_cmap_table) {
- lua_pushliteral(L, "bad_cmap_table"); lua_rawseti(L,-2,val++);
+ dump_intfield(L, "extrema_bound", sf->extrema_bound);
+}
+
+int ff_make_table(lua_State * L)
+{
+ SplineFont *sf;
+ sf = *(check_isfont(L, 1));
+ if (sf == NULL) {
+ lua_pushboolean(L, 0);
+ } else {
+ lua_createtable(L, 0, 60);
+ handle_splinefont(L, sf);
}
- if (st & lvs_bad_bitmaps_table) {
- lua_pushliteral(L, "bad_bitmaps_table"); lua_rawseti(L,-2,val++);
+ return 1;
+}
+
+void do_ff_info(lua_State * L, SplineFont * sf)
+{
+ lua_newtable(L);
+ dump_stringfield(L, "familyname", sf->familyname);
+ dump_stringfield(L, "fontname", sf->fontname);
+ dump_stringfield(L, "fullname", sf->fullname);
+ dump_intfield(L, "italicangle", sf->italicangle);
+ dump_stringfield(L, "version", sf->version);
+ dump_stringfield(L, "weight", sf->weight);
+
+}
+
+static int ff_info(lua_State * L)
+{
+ SplineFont *sf;
+ FILE *l;
+ int i;
+ const char *fontname;
+ int openflags = 1;
+ fontname = luaL_checkstring(L, 1);
+ if (!strlen(fontname)) {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed: empty string given\n",
+ fontname);
+ return 2;
}
- if (st & lvs_bad_gx_table) {
- lua_pushliteral(L, "bad_gx_table"); lua_rawseti(L,-2,val++);
+ /* test fontname for existance */
+ if ((l = fopen(fontname, "r"))) {
+ fclose(l);
+ } else {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed for %s (read error)\n",
+ fontname);
+ return 2;
}
- if (st & lvs_bad_ot_table) {
- lua_pushliteral(L, "bad_ot_table"); lua_rawseti(L,-2,val++);
+ sf = ReadSplineFontInfo((char *) fontname, openflags);
+ if (sf == NULL) {
+ lua_pushnil(L);
+ lua_pushfstring(L, "font loading failed for %s\n", fontname);
+ return 2;
+ } else {
+ if (sf->next != NULL) {
+ SplineFont *sf_next;
+ i = 1;
+ lua_newtable(L);
+ while (sf) {
+ do_ff_info(L, sf);
+ lua_rawseti(L, -2, i);
+ i++;
+ sf_next = sf->next;
+ EncMapFree(sf->map);
+ SplineFontFree(sf);
+ sf = sf_next;
+ }
+ } else {
+ do_ff_info(L, sf);
+ EncMapFree(sf->map);
+ SplineFontFree(sf);
+ }
}
- if (st & lvs_bad_os2_version) {
- lua_pushliteral(L, "bad_os2_version"); lua_rawseti(L,-2,val++);
+ return 1;
+}
+
+static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf,
+ int *bufsiz)
+{
+ FILE *f;
+ int32 *bsizes = NULL;
+ int flags = ps_flag_nocffsugar + ps_flag_nohints;
+ EncMap *map;
+
+ map = EncMap1to1(sf->glyphcnt);
+
+ if (WriteTTFFont
+ (filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) {
+ /* success */
+ f = fopen(filename, "rb");
+ readbinfile(f, buf, bufsiz);
+ /*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz); */
+ fclose(f);
+ return;
}
- if (st & lvs_bad_sfnt_header) {
- lua_pushliteral(L, "bad_sfnt_header"); lua_rawseti(L,-2,val++);
+ /* errors */
+ fprintf(stdout, "\n%s => CFF, failed\n", sf->filename);
+
+}
+
+/* exported for writecff.c */
+
+int ff_createcff(char *file, unsigned char **buf, int *bufsiz)
+{
+ SplineFont *sf;
+ int k;
+ char s[] = "tempfile.cff";
+ int openflags = 1;
+ int notdefpos = 0;
+ sf = ReadSplineFont(file, openflags);
+ if (sf) {
+ /* this is not the best way. nicer to have no temp file at all */
+ ff_do_cff(sf, s, buf, bufsiz);
+ for (k = 0; k < sf->glyphcnt; k++) {
+ if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
+ notdefpos = k;
+ break;
+ }
+ }
+ remove(s);
+ EncMapFree(sf->map);
+ SplineFontFree(sf);
}
- lua_setfield(L,-2,"validation_state");
- }
+ return notdefpos;
+}
- if (sf->horiz_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->horiz_base);
- lua_setfield(L,-2,"horiz_base");
- }
- if (sf->vert_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->vert_base);
- lua_setfield(L,-2,"vert_base");
- }
- dump_intfield(L,"extrema_bound", sf->extrema_bound);
-}
-
-int
-ff_make_table (lua_State *L) {
- SplineFont *sf;
- sf = *(check_isfont(L,1));
- if (sf == NULL) {
- lua_pushboolean(L,0);
- } else {
- lua_createtable(L,0,60);
- handle_splinefont(L,sf);
- }
- return 1;
-}
-
-void do_ff_info (lua_State *L, SplineFont *sf) {
- lua_newtable(L);
- dump_stringfield(L,"familyname", sf->familyname);
- dump_stringfield(L,"fontname", sf->fontname);
- dump_stringfield(L,"fullname", sf->fullname);
- dump_intfield (L,"italicangle", sf->italicangle);
- dump_stringfield(L,"version", sf->version);
- dump_stringfield(L,"weight", sf->weight);
-
-}
-
-static int
-ff_info (lua_State *L) {
- SplineFont *sf;
- FILE *l;
- int i;
- const char *fontname;
- int openflags = 1;
- fontname = luaL_checkstring(L,1);
- if (!strlen(fontname)) {
- lua_pushfstring(L,"font loading failed: empty string given\n", fontname);
- lua_error(L);
- return 1;
- }
- /* test fontname for existance */
- if ((l = fopen(fontname,"r"))) {
- fclose(l);
- } else {
- lua_pushfstring(L,"font loading failed for %s (read error)\n", fontname);
- lua_error(L);
- }
- sf = ReadSplineFontInfo((char *)fontname,openflags);
- if (sf==NULL) {
- lua_pushfstring(L,"font loading failed for %s\n", fontname);
- lua_error(L);
- } else {
- if (sf->next != NULL) {
- SplineFont *sf_next;
- i = 1;
- lua_newtable(L);
- while (sf) {
- do_ff_info(L, sf);
- lua_rawseti(L,-2,i);
- i++;
- sf_next = sf->next;
- SplineFontFree(sf);
- sf = sf_next;
- }
- } else {
- do_ff_info(L, sf);
- SplineFontFree(sf);
- }
- }
- return 1;
-}
-
-static void ff_do_cff (SplineFont *sf, char *filename, unsigned char **buf, int *bufsiz) {
- FILE *f;
- int32 *bsizes = NULL;
- int flags = ps_flag_nocffsugar + ps_flag_nohints;
- EncMap *map;
-
- map = EncMap1to1(sf->glyphcnt);
-
- if(WriteTTFFont(filename, sf, ff_cff, bsizes, bf_none, flags, map, ly_fore)) {
- /* success */
- f = fopen(filename,"rb");
- readbinfile(f , buf, bufsiz);
- /*fprintf(stdout,"\n%s => CFF, size: %d\n", sf->filename, *bufsiz);*/
- fclose(f);
- return;
- }
- /* errors */
- fprintf(stdout,"\n%s => CFF, failed\n", sf->filename);
-
-}
-
-
-#include "luafflib.h"
-
-int ff_createcff (char *file, unsigned char **buf, int *bufsiz) {
- SplineFont *sf;
- int k ;
- char s[] = "tempfile.cff";
- int openflags = 1;
- int notdefpos = 0;
- sf = ReadSplineFont(file,openflags);
- if (sf) {
- /* this is not the best way. nicer to have no temp file at all */
- ff_do_cff(sf, s, buf,bufsiz);
- for (k=0;k<sf->glyphcnt;k++) {
- if (sf->glyphs[k] && strcmp(sf->glyphs[k]->name,".notdef")==0) {
- notdefpos=k;
- break;
- }
- }
- remove(s);
- SplineFontFree(sf);
- }
- return notdefpos;
-}
-
-int ff_get_ttc_index(char *ffname, char*psname) {
- SplineFont *sf;
- int i = 0;
- int openflags = 1;
- int index = 0;
-
- sf = ReadSplineFontInfo(ffname,openflags);
- if (sf==NULL) {
- perror("font loading failed unexpectedly\n");
- exit(EXIT_FAILURE);
- }
- while (sf != NULL) {
- if (strcmp(sf->fontname,psname)==0) {
- index = i;
- break;
- }
- i++;
- sf = sf->next;
- }
- return index;
+int ff_get_ttc_index(char *ffname, char *psname)
+{
+ SplineFont *sf;
+ int i = 0;
+ int openflags = 1;
+ int index = -1;
+
+ sf = ReadSplineFontInfo((char *) ffname, openflags);
+ if (sf == NULL) {
+ perror("font loading failed unexpectedly\n");
+ exit(EXIT_FAILURE);
+ }
+ while (sf != NULL) {
+ if (strcmp(sf->fontname, psname) == 0) {
+ index = i;
+ break;
+ }
+ i++;
+ sf = sf->next;
+ }
+ return index;
}
static int warning_given = 0;
-static int
-ffold_info (lua_State *L) {
- if (warning_given<5) {
- fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
- fprintf (stderr, " Please update your source file(s) accordingly.\n");
- warning_given ++;
+static int ffold_info(lua_State * L)
+{
+ if (warning_given < 5) {
+ fprintf(stderr,
+ "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
+ fprintf(stderr, " Please update your source file(s) accordingly.\n");
+ warning_given++;
}
return ff_info(L);
}
-static int
-ffold_open (lua_State *L) {
- fprintf (stderr, "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
- fprintf (stderr, " Please update your source file(s) accordingly.\n");
+static int ffold_open(lua_State * L)
+{
+ fprintf(stderr,
+ "Warning: The 'fontforge' table has been renamed to 'fontloader'.\n");
+ fprintf(stderr, " Please update your source file(s) accordingly.\n");
return ff_open(L);
}
static struct luaL_reg fflib[] = {
- {"open", ffold_open},
- {"info", ffold_info},
- {"close", ff_close},
- {"apply_afmfile", ff_apply_afmfile},
- {"apply_featurefile", ff_apply_featurefile},
- {"to_table", ff_make_table},
- {NULL, NULL}
+ {"open", ffold_open},
+ {"info", ffold_info},
+ {"close", ff_close},
+ {"apply_afmfile", ff_apply_afmfile},
+ {"apply_featurefile", ff_apply_featurefile},
+ {"to_table", ff_make_table},
+ {NULL, NULL}
};
static struct luaL_reg fllib[] = {
- {"open", ff_open},
- {"info", ff_info},
- {"close", ff_close},
- {"apply_afmfile", ff_apply_afmfile},
- {"apply_featurefile", ff_apply_featurefile},
- {"to_table", ff_make_table},
- {NULL, NULL}
+ {"open", ff_open},
+ {"info", ff_info},
+ {"close", ff_close},
+ {"apply_afmfile", ff_apply_afmfile},
+ {"apply_featurefile", ff_apply_featurefile},
+ {"to_table", ff_make_table},
+ {NULL, NULL}
};
-static const struct luaL_reg fflib_m [] = {
- {"__gc", ff_close }, /* doesnt work yet! */
- {NULL, NULL} /* sentinel */
+static const struct luaL_reg fflib_m[] = {
+ {"__gc", ff_close}, /* doesnt work yet! */
+ {NULL, NULL} /* sentinel */
};
extern char *SaveTablesPref;
-extern char *coord_sep ;
-
-int luaopen_ff (lua_State *L) {
- InitSimpleStuff();
- setlocale(LC_ALL,"C"); /* undo whatever InitSimpleStuff has caused */
- coord_sep = ",";
- FF_SetUiInterface(&luaui_interface);
- default_encoding = FindOrMakeEncoding("ISO8859-1");
- SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO";
- luaL_newmetatable(L,FONT_METATABLE);
- luaL_register(L, NULL, fflib_m);
- luaL_openlib(L, "fontforge", fflib, 0);
- luaL_openlib(L, "fontloader", fllib, 0);
- return 1;
+extern char *coord_sep;
+
+int luaopen_ff(lua_State * L)
+{
+ InitSimpleStuff();
+ setlocale(LC_ALL, "C"); /* undo whatever InitSimpleStuff has caused */
+ coord_sep = ",";
+ FF_SetUiInterface(&luaui_interface);
+ default_encoding = FindOrMakeEncoding("ISO8859-1");
+ SaveTablesPref = "VORG,JSTF,acnt,bsln,fdsc,fmtx,hsty,just,trak,Zapf,LINO";
+ luaL_newmetatable(L, FONT_METATABLE);
+ luaL_register(L, NULL, fflib_m);
+ luaL_openlib(L, "fontforge", fflib, 0);
+ luaL_openlib(L, "fontloader", fllib, 0);
+ return 1;
}
-