summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luafontloader
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-09 22:53:09 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-09 22:53:09 +0000
commit5fb8104fddfa73649ef0fde6b7b0cbfd53def358 (patch)
tree830d92cde3f9d6b168b949a28704a0c8960b55e9 /Build/source/texk/web2c/luatexdir/luafontloader
parent1f16f479df5678daa28b623d9d747b84b3bd0e30 (diff)
web2c/luatexdir: sync sith the upstream
git-svn-id: svn://tug.org/texlive/trunk@39981 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luafontloader')
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c830
-rw-r--r--Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c1258
2 files changed, 1050 insertions, 1038 deletions
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 5a3d3b58d20..1e8c09fceca 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c
@@ -286,36 +286,35 @@ int MSLanguageFromLocale(void) {
int langcode, langlocalecode;
for ( i=0; envs[i]!=NULL; ++i ) {
- lang = getenv(envs[i]);
- if ( lang!=NULL ) {
- langlen = strlen(lang);
- if (( langlen>5 && lang[5]=='.' && lang[2]=='_' ) ||
- (langlen==5 && lang[2]=='_' ) ||
- (langlen==2) ||
- (langlen==3)) /* Some obscure languages have a 3 letter code */
- /* I understand this language */
- break;
- }
+ lang = getenv(envs[i]);
+ if ( lang!=NULL ) {
+ langlen = strlen(lang);
+ if (( langlen>5 && lang[5]=='.' && lang[2]=='_' ) ||
+ (langlen==5 && lang[2]=='_' ) ||
+ (langlen==2) ||
+ (langlen==3)) /* Some obscure languages have a 3 letter code */
+ /* I understand this language */
+ break;
+ }
}
if ( lang==NULL )
- lang = "en_US";
+ lang = "en_US";
strncpy(langcountry,lang,5); langcountry[5] = '\0';
strncpy(language,lang,3); language[3] = '\0';
if ( language[2]=='_' ) language[2] = '\0';
- langlen = strlen(language);
-
+ langlen = strlen(language);
langcode = langlocalecode = -1;
for ( i=0; ms_2_locals[i].loc_name!=NULL; ++i ) {
- if ( strmatch(langcountry,ms_2_locals[i].loc_name)==0 ) {
- langlocalecode = ms_2_locals[i].local_id;
- langcode = langlocalecode&0x3ff;
- break;
- } else if ( strncmp(language,ms_2_locals[i].loc_name,langlen)==0 )
- langcode = ms_2_locals[i].local_id&0x3ff;
+ if ( strmatch(langcountry,ms_2_locals[i].loc_name)==0 ) {
+ langlocalecode = ms_2_locals[i].local_id;
+ langcode = langlocalecode&0x3ff;
+ break;
+ } else if ( strncmp(language,ms_2_locals[i].loc_name,langlen)==0 )
+ langcode = ms_2_locals[i].local_id&0x3ff;
}
if ( langcode==-1 ) /* Default to English */
- langcode = 0x9;
-return( langlocalecode==-1 ? (langcode|0x400) : langlocalecode );
+ langcode = 0x9;
+ return( langlocalecode==-1 ? (langcode|0x400) : langlocalecode );
}
/* ************************************************************************** */
@@ -323,8 +322,8 @@ int getushort(FILE *ttf) {
int ch1 = getc(ttf);
int ch2 = getc(ttf);
if ( ch2==EOF )
-return( EOF );
-return( (ch1<<8)|ch2 );
+ return( EOF );
+ return( (ch1<<8)|ch2 );
}
int get3byte(FILE *ttf) {
@@ -332,8 +331,8 @@ int get3byte(FILE *ttf) {
int ch2 = getc(ttf);
int ch3 = getc(ttf);
if ( ch3==EOF )
-return( EOF );
-return( (ch1<<16)|(ch2<<8)|ch3 );
+ return( EOF );
+ return( (ch1<<16)|(ch2<<8)|ch3 );
}
int32 getlong(FILE *ttf) {
@@ -342,19 +341,19 @@ int32 getlong(FILE *ttf) {
int ch3 = getc(ttf);
int ch4 = getc(ttf);
if ( ch4==EOF )
-return( EOF );
-return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 );
+ return( EOF );
+ return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 );
}
static int32 getoffset(FILE *ttf, int offsize) {
if ( offsize==1 )
-return( getc(ttf));
+ return( getc(ttf));
else if ( offsize==2 )
-return( getushort(ttf));
+ return( getushort(ttf));
else if ( offsize==3 )
-return( get3byte(ttf));
+ return( get3byte(ttf));
else
-return( getlong(ttf));
+ return( getlong(ttf));
}
real getfixed(FILE *ttf) {
@@ -362,7 +361,7 @@ real getfixed(FILE *ttf) {
int mant = val&0xffff;
/* This oddity may be needed to deal with the first 16 bits being signed */
/* and the low-order bits unsigned */
-return( (real) (val>>16) + (mant/65536.0) );
+ return( (real) (val>>16) + (mant/65536.0) );
}
real get2dot14(FILE *ttf) {
@@ -370,7 +369,7 @@ real get2dot14(FILE *ttf) {
int mant = val&0x3fff;
/* This oddity may be needed to deal with the first 2 bits being signed */
/* and the low-order bits unsigned */
-return( (real) ((val<<16)>>(16+14)) + (mant/16384.0) );
+ return( (real) ((val<<16)>>(16+14)) + (mant/16384.0) );
}
static Encoding *enc_from_platspec(int platform,int specific) {
@@ -379,61 +378,62 @@ static Encoding *enc_from_platspec(int platform,int specific) {
enc = "Custom";
if ( platform==0 ) {
- enc = "Unicode";
+ enc = "Unicode";
if ( specific==4 )
enc = "UnicodeFull";
} else if ( platform==1 ) {
- if ( specific==0 )
- enc = "Mac";
- else if ( specific==1 )
- enc = "Sjis";
- else if ( specific==2 )
- enc = "Big5hkscs"; /* Or should we just guess big5? Both are wrong sometimes */
- else if ( specific==3 )
- enc = "EUC-KR";
- else if ( specific==25 )
- enc = "EUC-CN";
+ if ( specific==0 )
+ enc = "Mac";
+ else if ( specific==1 )
+ enc = "Sjis";
+ else if ( specific==2 )
+ enc = "Big5hkscs"; /* Or should we just guess big5? Both are wrong sometimes */
+ else if ( specific==3 )
+ enc = "EUC-KR";
+ else if ( specific==25 )
+ enc = "EUC-CN";
} else if ( platform==2 ) { /* obselete */
- if ( specific==0 )
- enc = "ASCII";
- else if ( specific==1 )
- enc = "Unicode";
- else if ( specific==2 )
- enc = "ISO8859-1";
+ if ( specific==0 )
+ enc = "ASCII";
+ else if ( specific==1 )
+ enc = "Unicode";
+ else if ( specific==2 )
+ enc = "ISO8859-1";
} else if ( platform==3 ) {
- if ( specific==1 || specific==0 ) /* symbol (sp=0) is just unicode (PUA) */
- enc = "Unicode";
- else if ( specific==2 )
- enc = "Sjis";
- else if ( specific==3 )
- enc = "EUC-CN";
- else if ( specific==4 )
- enc = "Big5hkscs";
- else if ( specific==5 )
- enc = "EUC-KR";
- else if ( specific==6 )
- enc = "Johab";
- else if ( specific==10 )
- enc = "UnicodeFull";
+ if ( specific==1 || specific==0 ) /* symbol (sp=0) is just unicode (PUA) */
+ enc = "Unicode";
+ else if ( specific==2 )
+ enc = "Sjis";
+ else if ( specific==3 )
+ enc = "EUC-CN";
+ else if ( specific==4 )
+ enc = "Big5hkscs";
+ else if ( specific==5 )
+ enc = "EUC-KR";
+ else if ( specific==6 )
+ enc = "Johab";
+ else if ( specific==10 )
+ enc = "UnicodeFull";
} else if ( platform==7 ) { /* Used internally in freetype, but */
- if ( specific==0 ) /* there's no harm in looking for it */
- enc = "AdobeStandard"; /* even if it never happens */
- else if ( specific==1 ) {
- /* adobe_expert */;
- } else if ( specific==2 ) {
- /* adobe_custom */;
- }
+ if ( specific==0 ) /* there's no harm in looking for it */
+ enc = "AdobeStandard"; /* even if it never happens */
+ else if ( specific==1 ) {
+ /* adobe_expert */;
+ } else if ( specific==2 ) {
+ /* adobe_custom */;
+ }
}
e = FindOrMakeEncoding(enc);
if ( e==NULL ) {
- static int p = -1,s = -1;
+ static int p = -1,s = -1;
if ( p!=platform || s!=specific ) {
LogError( _("The truetype encoding specified by platform=%d specific=%d (which we map to %s) is not supported by your version of iconv(3).\n"),
platform, specific, enc );
- p = platform; s = specific;
+ p = platform;
+ s = specific;
}
}
-return( e );
+ return( e );
}
static char *_readencstring(FILE *ttf,int offset,int len,
@@ -450,55 +450,55 @@ static char *_readencstring(FILE *ttf,int offset,int len,
/* Mac is screwy, there are several different varients of MacRoman */
/* depending on the language, they didn't get it right when they */
/* invented their script system */
- char *cstr, *cpt;
- cstr = cpt = galloc(len+1);
- for ( i=0; i<len; ++i )
+ char *cstr, *cpt;
+ cstr = cpt = galloc(len+1);
+ for ( i=0; i<len; ++i )
*cpt++ = getc(ttf);
- *cpt = '\0';
- ret = MacStrToUtf8(cstr,specific,language);
- free(cstr);
+ *cpt = '\0';
+ ret = MacStrToUtf8(cstr,specific,language);
+ free(cstr);
} else {
- enc = enc_from_platspec(platform,specific);
- if ( enc==NULL )
-return( NULL );
- if ( enc->is_unicodebmp ) {
- str = pt = galloc((sizeof(unichar_t)/2)*len+sizeof(unichar_t));
- for ( i=0; i<len/2; ++i ) {
- ch = getc(ttf)<<8;
- *pt++ = ch | getc(ttf);
- }
- *pt = 0;
- } else if ( enc->unicode!=NULL ) {
- str = pt = galloc(sizeof(unichar_t)*len+sizeof(unichar_t));
- for ( i=0; i<len; ++i )
- *pt++ = enc->unicode[getc(ttf)];
- *pt = 0;
- } else if ( enc->tounicode!=NULL ) {
- size_t inlen = len+1, outlen = sizeof(unichar_t)*(len+1);
- char *cstr = galloc(inlen);
- ICONV_CONST char *in = cstr;
- char *out;
+ enc = enc_from_platspec(platform,specific);
+ if ( enc==NULL )
+ return( NULL );
+ if ( enc->is_unicodebmp ) {
+ str = pt = galloc((sizeof(unichar_t)/2)*len+sizeof(unichar_t));
+ for ( i=0; i<len/2; ++i ) {
+ ch = getc(ttf)<<8;
+ *pt++ = ch | getc(ttf);
+ }
+ *pt = 0;
+ } else if ( enc->unicode!=NULL ) {
+ str = pt = galloc(sizeof(unichar_t)*len+sizeof(unichar_t));
+ for ( i=0; i<len; ++i )
+ *pt++ = enc->unicode[getc(ttf)];
+ *pt = 0;
+ } else if ( enc->tounicode!=NULL ) {
+ size_t inlen = len+1, outlen = sizeof(unichar_t)*(len+1);
+ char *cstr = galloc(inlen);
+ ICONV_CONST char *in = cstr;
+ char *out;
#ifdef UNICHAR_16
str = galloc(outlen+2);
#else
str = galloc(outlen+sizeof(unichar_t));
#endif
/*str = galloc(outlen+2);*/
- out = (char *) str;
- iconv(enc->tounicode,&in,&inlen,&out,&outlen);
- out[0] = '\0'; out[1] = '\0';
+ out = (char *) str;
+ iconv(enc->tounicode,&in,&inlen,&out,&outlen);
+ out[0] = '\0'; out[1] = '\0';
#ifndef UNICHAR_16
- out[2] = '\0'; out[3] = '\0';
+ out[2] = '\0'; out[3] = '\0';
#endif
- free(cstr);
- } else {
- str = uc_copy("");
- }
- ret = u2utf8_copy(str);
- free(str);
+ free(cstr);
+ } else {
+ str = uc_copy("");
+ }
+ ret = u2utf8_copy(str);
+ free(str);
}
fseek(ttf,pos,SEEK_SET);
-return( ret );
+ return( ret );
}
char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2) {
@@ -519,15 +519,15 @@ char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2) {
/* 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;
+ 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 );
+ return( NULL );
fseek(ttf,nameoffset,SEEK_SET);
/* format = */ getushort(ttf);
@@ -535,63 +535,62 @@ return( NULL );
stringoffset = nameoffset+getushort(ttf);
fullval = famval = 0;
for ( i=0; i<num; ++i ) {
- plat = getushort(ttf);
- spec = getushort(ttf);
- lang = getushort(ttf);
- name = getushort(ttf);
- len = getushort(ttf);
- off = getushort(ttf);
- enc = enc_from_platspec(plat,spec);
- if ( enc==NULL )
- continue;
- val = 0;
- if ( plat==3 && !enc->is_custom && lang==locale )
- val = 15;
- else if ( plat==3 && !enc->is_custom && (lang&0xff)==(locale&0xff) )
- val = 14;
- else if ( (plat==0 || plat==1) && !enc->is_custom && lang==maclang )
- val = 13;
- /* Ok, that didn't work, how about an english name? */
- else if ( plat==3 && !enc->is_custom && lang==0x409 )
- val = 12;
- else if ( plat==3 && !enc->is_custom && (lang&0xff)==0x09 )
- val = 11;
- else if ( (plat==0 || plat==1) && !enc->is_custom && lang==0 )
- val = 10;
- /* failing that I'll take what I can get */
- else if ( !enc->is_custom )
- val = 1;
- if ( name==4 && val>fullval ) {
- fullval = val;
- fullstr = off;
- fulllen = len;
- fullplat = plat;
- fullspec = spec;
- fulllang = lang;
- if ( val==12 )
- break;
- } else if ( name==1 && val>famval ) {
- famval = val;
- famstr = off;
- famlen = len;
- famplat = plat;
- famspec = spec;
- famlang = lang;
- }
+ plat = getushort(ttf);
+ spec = getushort(ttf);
+ lang = getushort(ttf);
+ name = getushort(ttf);
+ len = getushort(ttf);
+ off = getushort(ttf);
+ enc = enc_from_platspec(plat,spec);
+ if ( enc==NULL )
+ continue;
+ val = 0;
+ if ( plat==3 && !enc->is_custom && lang==locale )
+ val = 15;
+ else if ( plat==3 && !enc->is_custom && (lang&0xff)==(locale&0xff) )
+ val = 14;
+ else if ( (plat==0 || plat==1) && !enc->is_custom && lang==maclang )
+ val = 13;
+ /* Ok, that didn't work, how about an english name? */
+ else if ( plat==3 && !enc->is_custom && lang==0x409 )
+ val = 12;
+ else if ( plat==3 && !enc->is_custom && (lang&0xff)==0x09 )
+ val = 11;
+ else if ( (plat==0 || plat==1) && !enc->is_custom && lang==0 )
+ val = 10;
+ /* failing that I'll take what I can get */
+ else if ( !enc->is_custom )
+ val = 1;
+ if ( name==4 && val>fullval ) {
+ fullval = val;
+ fullstr = off;
+ fulllen = len;
+ fullplat = plat;
+ fullspec = spec;
+ fulllang = lang;
+ if ( val==12 )
+ break;
+ } else if ( name==1 && val>famval ) {
+ famval = val;
+ famstr = off;
+ famlen = len;
+ famplat = plat;
+ famspec = spec;
+ famlang = lang;
+ }
}
if ( fullval==0 ) {
- if ( famval==0 )
-return( NULL );
- fullstr = famstr;
- fulllen = famlen;
- fullplat = famplat;
- fullspec = famspec;
- fulllang = famlang;
- }
-return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang));
+ if ( famval==0 )
+ return( NULL );
+ fullstr = famstr;
+ fulllen = famlen;
+ fullplat = famplat;
+ fullspec = famspec;
+ fulllang = famlang;
+ }
+ return( _readencstring(ttf,stringoffset+fullstr,fulllen,fullplat,fullspec,fulllang));
}
-
char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
int i,num;
int32 tag, length, stringoffset;
@@ -605,15 +604,15 @@ char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
/* 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;
+ 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 );
+ return( NULL );
fseek(ttf,nameoffset,SEEK_SET);
/* format = */ getushort(ttf);
@@ -621,23 +620,23 @@ char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2) {
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);
- }
- }
+ /* 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;
}
@@ -661,16 +660,16 @@ static int PickTTFFont(FILE *ttf,char *filename,char **chosenname) {
names = galloc(cnt*sizeof(char *));
for ( i=j=0; i<cnt; ++i ) {
names[j] = TTFGetFontName(ttf,offsets[i],0);
- if ( names[j]!=NULL ) ++j;
+ if ( names[j]!=NULL )
+ ++j;
}
pt = strrchr(filename,'/');
- if ( pt==NULL ) pt = filename;
+ if ( pt==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' ) {
+ 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';
@@ -687,9 +686,9 @@ static int PickTTFFont(FILE *ttf,char *filename,char **chosenname) {
char *fn = copy(filename);
fn[lparen-filename] = '\0';
ff_post_error(_("Not in Collection"),
-/* GT: The user is trying to open a font file which contains multiple fonts and */
-/* GT: has asked for a font which is not in that file. */
-/* GT: The string will look like: <fontname> is not in <filename> */
+ /* GT: The user is trying to open a font file which contains multiple fonts and */
+ /* GT: has asked for a font which is not in that file. */
+ /* GT: The string will look like: <fontname> is not in <filename> */
_("%1$s is not in %2$.100s"),find,fn);
free(fn);
}
@@ -712,14 +711,14 @@ static int PickCFFFont(char **fontnames) {
int cnt, i, choice;
for ( cnt=0; fontnames[cnt]!=NULL; ++cnt);
- names = gcalloc(cnt+1,sizeof(unichar_t *));
+ names = gcalloc(cnt+1,sizeof(unichar_t *));
for ( i=0; i<cnt; ++i )
- names[i] = uc_copy(fontnames[i]);
+ names[i] = uc_copy(fontnames[i]);
choice = 0;
for ( i=0; i<cnt; ++i )
- free(names[i]);
+ free(names[i]);
free(names);
-return( choice );
+ return( choice );
}
static void ParseSaveTablesPref(struct ttfinfo *info) {
@@ -729,40 +728,40 @@ static void ParseSaveTablesPref(struct ttfinfo *info) {
info->savecnt = 0;
info->savetab = NULL;
if ( SaveTablesPref==NULL || *SaveTablesPref=='\0' )
-return;
+ return;
for ( pt=SaveTablesPref, cnt=0; *pt; ++pt )
if ( *pt==',' )
++cnt;
info->savecnt = cnt+1;
info->savetab = gcalloc(cnt+1,sizeof(struct savetab));
for ( pt=spt=SaveTablesPref, cnt=0; ; ++pt ) {
- if ( *pt==',' || *pt=='\0' ) {
- uint32 tag;
- tag = ( ( spt <pt )? spt[0] : ' ' )<<24;
- tag |= ( ( spt+1<pt )? spt[1] : ' ' )<<16;
- tag |= ( ( spt+2<pt )? spt[2] : ' ' )<<8 ;
- tag |= ( ( spt+3<pt )? spt[3] : ' ' ) ;
- info->savetab[cnt++].tag = tag;
- if ( *pt )
- spt = pt+1;
- else
- break;
- }
+ if ( *pt==',' || *pt=='\0' ) {
+ uint32 tag;
+ tag = ( ( spt <pt )? spt[0] : ' ' )<<24;
+ tag |= ( ( spt+1<pt )? spt[1] : ' ' )<<16;
+ tag |= ( ( spt+2<pt )? spt[2] : ' ' )<<8 ;
+ tag |= ( ( spt+3<pt )? spt[3] : ' ' ) ;
+ info->savetab[cnt++].tag = tag;
+ if ( *pt )
+ spt = pt+1;
+ else
+ break;
+ }
}
}
static int32 filechecksum(FILE *file, int start, int len) {
uint32 sum = 0, chunk;
-
fseek(file,start,SEEK_SET);
- if ( len!=-1 ) len=(len+3)>>2;
+ if ( len!=-1 )
+ len=(len+3)>>2;
while ( len==-1 || --len>=0 ) {
- chunk = getlong(file);
- if ( feof(file))
- break;
- sum += chunk;
+ chunk = getlong(file);
+ if ( feof(file))
+ break;
+ sum += chunk;
}
-return( sum );
+ return( sum );
}
static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
@@ -772,10 +771,10 @@ static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
/* bather */
uint32 restore_this_pos = ftell(ttf);
struct tt_tables {
- uint32 tag;
- uint32 checksum;
- uint32 offset;
- uint32 length;
+ uint32 tag;
+ uint32 checksum;
+ uint32 offset;
+ uint32 length;
} *tabs, temp;
int i,j;
uint32 file_len;
@@ -792,77 +791,77 @@ static void ValidateTTFHead(FILE *ttf,struct ttfinfo *info) {
e_rs = info->numtables*16-e_sr;
if ( e_sr!=sr || e_es!=es || e_rs!=rs ) {
LogError( _("Unexpected values for binsearch header. Based on the number of tables I\n expect searchRange=%d (not %d), entrySel=%d (not %d) rangeShift=%d (not %d)\n"),
- e_sr, sr, e_es, es, e_rs, rs );
- info->bad_sfnt_header = true;
+ e_sr, sr, e_es, es, e_rs, rs );
+ info->bad_sfnt_header = true;
}
if ( info->numtables<=0 ) {
- LogError(_("An sfnt file must contain SOME tables, but this one does not."));
- info->bad_sfnt_header = true;
- fseek(ttf,restore_this_pos,SEEK_SET);
-return;
+ LogError(_("An sfnt file must contain SOME tables, but this one does not."));
+ info->bad_sfnt_header = true;
+ fseek(ttf,restore_this_pos,SEEK_SET);
+ return;
} else if ( info->numtables>1000 ) {
- LogError(_("An sfnt file may contain a large number of tables, but this one has over 1000\n and that seems like too many\n"));
- info->bad_sfnt_header = true;
- fseek(ttf,restore_this_pos,SEEK_SET);
-return;
+ LogError(_("An sfnt file may contain a large number of tables, but this one has over 1000\n and that seems like too many\n"));
+ info->bad_sfnt_header = true;
+ fseek(ttf,restore_this_pos,SEEK_SET);
+ return;
}
tabs = galloc(info->numtables*sizeof(struct tt_tables));
for ( i=0; i<info->numtables; ++i ) {
- tabs[i].tag = getlong(ttf);
- tabs[i].checksum = getlong(ttf);
- tabs[i].offset = getlong(ttf);
- tabs[i].length = getlong(ttf);
- if ( i!=0 && tabs[i].tag<tabs[i-1].tag && !info->bad_sfnt_header ) {
- LogError(_("Table tags should be in alphabetic order in the font header\n but '%c%c%c%c', appears after '%c%c%c%c'."),
- tabs[i-1].tag>>24, tabs[i-1].tag>>16, tabs[i-1].tag>>8, tabs[i-1].tag,
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
+ tabs[i].tag = getlong(ttf);
+ tabs[i].checksum = getlong(ttf);
+ tabs[i].offset = getlong(ttf);
+ tabs[i].length = getlong(ttf);
+ if ( i!=0 && tabs[i].tag<tabs[i-1].tag && !info->bad_sfnt_header ) {
+ LogError(_("Table tags should be in alphabetic order in the font header\n but '%c%c%c%c', appears after '%c%c%c%c'."),
+ tabs[i-1].tag>>24, tabs[i-1].tag>>16, tabs[i-1].tag>>8, tabs[i-1].tag,
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
}
fseek(ttf,0,SEEK_END);
file_len = ftell(ttf);
for ( i=0; i<info->numtables; ++i ) for ( j=i+1; j<info->numtables; ++j ) {
- if ( tabs[i].offset>tabs[j].offset ) {
- temp = tabs[i];
- tabs[i] = tabs[j];
- tabs[j] = temp;
- }
+ if ( tabs[i].offset>tabs[j].offset ) {
+ temp = tabs[i];
+ tabs[i] = tabs[j];
+ tabs[j] = temp;
+ }
}
for ( i=0; i<info->numtables-1; ++i ) {
- for ( j=i+1; j<info->numtables; ++j ) {
- if ( tabs[i].tag==tabs[j].tag ) {
- LogError(_("Same table tag, '%c%c%c%c', appears twice in sfnt header"),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
- }
- if ( tabs[i].offset+tabs[i].length > tabs[i+1].offset ) {
- LogError(_("Tables '%c%c%c%c' and '%c%c%c%c' overlap"),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag,
- tabs[j].tag>>24, tabs[j].tag>>16, tabs[j].tag>>8, tabs[j].tag );
- }
+ for ( j=i+1; j<info->numtables; ++j ) {
+ if ( tabs[i].tag==tabs[j].tag ) {
+ LogError(_("Same table tag, '%c%c%c%c', appears twice in sfnt header"),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
+ }
+ if ( tabs[i].offset+tabs[i].length > tabs[i+1].offset ) {
+ LogError(_("Tables '%c%c%c%c' and '%c%c%c%c' overlap"),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag,
+ tabs[j].tag>>24, tabs[j].tag>>16, tabs[j].tag>>8, tabs[j].tag );
+ }
}
if ( tabs[i].offset+tabs[i].length > file_len ) {
- LogError(_("Table '%c%c%c%c' extends beyond end of file."),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
+ LogError(_("Table '%c%c%c%c' extends beyond end of file."),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
}
/* Checksums. First file as a whole, then each table */
if ( filechecksum(ttf,0,-1)!=(int)0xb1b0afba ) {
- LogError(_("File checksum is incorrect."));
- info->bad_sfnt_header = true;
+ LogError(_("File checksum is incorrect."));
+ info->bad_sfnt_header = true;
}
for ( i=0; i<info->numtables-1; ++i ) if ( tabs[i].tag!=CHR('h','e','a','d')) {
- if ( filechecksum(ttf,tabs[i].offset,tabs[i].length)!=(int)tabs[i].checksum ) {
- LogError(_("Table '%c%c%c%c' has a bad checksum."),
- tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
- info->bad_sfnt_header = true;
- }
+ if ( filechecksum(ttf,tabs[i].offset,tabs[i].length)!=(int)tabs[i].checksum ) {
+ LogError(_("Table '%c%c%c%c' has a bad checksum."),
+ tabs[i].tag>>24, tabs[i].tag>>16, tabs[i].tag>>8, tabs[i].tag );
+ info->bad_sfnt_header = true;
+ }
}
hashead = hashhea = hasmaxp = masos2 = haspost = hasname = hasos2 = false;
@@ -3671,10 +3670,10 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
cffinfofillup(info, dict, strings, scnt );
/* We'll set the encmap later */
- /*info->map = encmap = EncMapNew(info->glyph_cnt,info->glyph_cnt,&custom);*/
+ /* info->map = encmap = EncMapNew(info->glyph_cnt,info->glyph_cnt,&custom);*/
for ( j=0; subdicts[j]!=NULL; ++j );
- info->subfontcnt = j;
+ info->subfontcnt = j;
info->subfonts = gcalloc(j+1,sizeof(SplineFont *));
for ( j=0; subdicts[j]!=NULL; ++j ) {
info->subfonts[j] = cffsffillup(subdicts[j],strings,scnt,info);
@@ -3682,21 +3681,22 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
info->subfonts[j]->glyphmin = -1;
}
/* here we also deal with glyphmin */
-
for ( i=0; i<info->glyph_cnt; ++i ) {
sf = info->subfonts[ fdselect[i] ];
cid = dict->charset[i];
if ( cid>=sf->glyphcnt ) {
- if (sf->glyphmin == -1) {
- sf->glyphmin = cid;
- }
- sf->glyphcnt = sf->glyphmax = cid+1;
- }
- /*if ( cid>=encmap->enccount )
- encmap->enccount = cid+1;*/
+ if (sf->glyphmin == -1) {
+ /*
+ sf->glyphmin = cid;
+ */
+ }
+ sf->glyphcnt = sf->glyphmax = cid+1;
+ }
+ /* if ( cid>=encmap->enccount ) encmap->enccount = cid+1;*/
}
- for ( j=0; subdicts[j]!=NULL; ++j )
+ for ( j=0; subdicts[j]!=NULL; ++j ) {
info->subfonts[j]->glyphs = gcalloc(info->subfonts[j]->glyphcnt,sizeof(SplineChar *));
+ }
/*encmap->encmax = encmap->enccount;*/
/*encmap->map = galloc(encmap->enccount*sizeof(int));*/
@@ -3721,26 +3721,24 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
cstype = subdicts[j]->charstringtype;
pscontext.is_type2 = cstype-1;
pscontext.painttype = subdicts[j]->painttype;
- gsubrs->bias = cstype==1 ? 0 :
- gsubrs->cnt < 1240 ? 107 :
- gsubrs->cnt <33900 ? 1131 : 32768;
+ gsubrs->bias = cstype==1 ? 0 : gsubrs->cnt < 1240 ? 107 : gsubrs->cnt <33900 ? 1131 : 32768;
subrs = &subdicts[j]->local_subrs;
- subrs->bias = cstype==1 ? 0 :
- subrs->cnt < 1240 ? 107 :
- subrs->cnt <33900 ? 1131 : 32768;
- cid = dict->charset[i];
+ subrs->bias = cstype==1 ? 0 : subrs->cnt < 1240 ? 107 : subrs->cnt <33900 ? 1131 : 32768;
+ /*
+ cid = dict->charset[i];
+ */
+ cid = i ;
/*encmap->map[cid] = cid;*/
uni = CID2NameUni(map,cid,buffer,sizeof(buffer));
- info->chars[i] = PSCharStringToBB(
- dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,
- subrs,gsubrs,buffer);
+ info->chars[i] = PSCharStringToBB(dict->glyphs.values[i], dict->glyphs.lens[i],&pscontext,subrs,gsubrs,buffer);
info->chars[i]->vwidth = sf->ascent+sf->descent;
info->chars[i]->unicodeenc = uni;
sf->glyphs[cid] = info->chars[i];
sf->glyphs[cid]->parent = sf;
sf->glyphs[cid]->orig_pos = i; /* fixed in 0.80.1 */
- if ( sf->glyphs[cid]->layers[ly_fore].refs!=NULL )
+ if ( sf->glyphs[cid]->layers[ly_fore].refs!=NULL ) {
IError( "Reference found in CID font. Can't fix it up");
+ }
THPatchSplineChar(sf->glyphs[cid]);
if ( cstype==2 ) {
if ( sf->glyphs[cid]->width == (int16) 0x8000 )
@@ -3748,8 +3746,18 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict,
else
sf->glyphs[cid]->width += subdicts[j]->nominalwidthx;
}
+ /* moved here */
+ if (sf->glyphmin == -1) {
+ /* if (sf->glyphs[cid] != (struct splinechar *)-1) { */
+ sf->glyphmin = cid ;
+ /* } */
+ }
ff_progress_next();
}
+ /* bonus */
+ if (sf->glyphmin == -1) {
+ sf->glyphmin = 0 ;
+ }
/* No need to do a reference fixup here-- the chars aren't associated */
/* with any encoding as is required for seac */
}
@@ -3768,7 +3776,7 @@ static int readcffglyphs(FILE *ttf,struct ttfinfo *info) {
if ( getc(ttf)!='\1' ) { /* Major version */
LogError( _("CFF version mismatch\n" ));
info->bad_cff = true;
-return( 0 );
+ return 0;
}
getc(ttf); /* Minor version */
hdrsize = getc(ttf);
@@ -3778,13 +3786,14 @@ return( 0 );
fontnames = readcfffontnames(ttf,NULL,info);
which = 0;
if ( fontnames[1]!=NULL ) { /* More than one? Can that even happen in OpenType? */
- which = PickCFFFont(fontnames);
- if ( which==-1 ) {
- for ( i=0; fontnames[i]!=NULL; ++i )
- free(fontnames[i]);
- free(fontnames);
-return( 0 );
- }
+ which = PickCFFFont(fontnames);
+ if (which == -1) {
+ for (i=0; fontnames[i]!=NULL; ++i) {
+ free(fontnames[i]);
+ }
+ free(fontnames);
+ return 0;
+ }
}
dicts = readcfftopdicts(ttf,fontnames,info->cff_start,info, NULL);
/* String index is just the same as fontname index */
@@ -3792,60 +3801,60 @@ return( 0 );
readcffsubrs(ttf,&gsubs,info );
/* Can be many fonts here. Only decompose the one */
if ( dicts[which]->charstringsoff!=-1 ) {
- fseek(ttf,info->cff_start+dicts[which]->charstringsoff,SEEK_SET);
- readcffsubrs(ttf,&dicts[which]->glyphs,info);
+ fseek(ttf,info->cff_start+dicts[which]->charstringsoff,SEEK_SET);
+ readcffsubrs(ttf,&dicts[which]->glyphs,info);
}
if ( dicts[which]->private_offset!=-1 )
- readcffprivate(ttf,dicts[which],info);
+ readcffprivate(ttf,dicts[which],info);
if ( dicts[which]->charsetoff!=-1 )
- readcffset(ttf,dicts[which],info);
+ readcffset(ttf,dicts[which],info);
if ( dicts[which]->fdarrayoff==-1 )
- cfffigure(info,dicts[which],strings,scnt,&gsubs);
+ cfffigure(info,dicts[which],strings,scnt,&gsubs);
else {
- fseek(ttf,info->cff_start+dicts[which]->fdarrayoff,SEEK_SET);
- subdicts = readcfftopdicts(ttf,NULL,info->cff_start,info,dicts[which]);
- fseek(ttf,info->cff_start+dicts[which]->fdselectoff,SEEK_SET);
- fdselect = readfdselect(ttf,dicts[which]->glyphs.cnt,info);
- for ( j=0; subdicts[j]!=NULL; ++j ) {
- if ( subdicts[j]->private_offset!=-1 )
- readcffprivate(ttf,subdicts[j],info);
- if ( subdicts[j]->charsetoff!=-1 )
- readcffset(ttf,subdicts[j],info);
- }
- cidfigure(info,dicts[which],strings,scnt,&gsubs,subdicts,fdselect);
- for ( j=0; subdicts[j]!=NULL; ++j )
- TopDictFree(subdicts[j]);
- free(subdicts); free(fdselect);
+ fseek(ttf,info->cff_start+dicts[which]->fdarrayoff,SEEK_SET);
+ subdicts = readcfftopdicts(ttf,NULL,info->cff_start,info,dicts[which]);
+ fseek(ttf,info->cff_start+dicts[which]->fdselectoff,SEEK_SET);
+ fdselect = readfdselect(ttf,dicts[which]->glyphs.cnt,info);
+ for ( j=0; subdicts[j]!=NULL; ++j ) {
+ if ( subdicts[j]->private_offset!=-1 )
+ readcffprivate(ttf,subdicts[j],info);
+ if ( subdicts[j]->charsetoff!=-1 )
+ readcffset(ttf,subdicts[j],info);
+ }
+ cidfigure(info,dicts[which],strings,scnt,&gsubs,subdicts,fdselect);
+ for ( j=0; subdicts[j]!=NULL; ++j )
+ TopDictFree(subdicts[j]);
+ free(subdicts); free(fdselect);
}
if ( dicts[which]->encodingoff!=-1 )
- readcffenc(ttf,dicts[which],info,strings,scnt);
+ readcffenc(ttf,dicts[which],info,strings,scnt);
if ( dicts[which]->fdarrayoff==-1 ) {
- for ( i=0; i<info->glyph_cnt ; ++i )
- if ( info->chars[i]!=NULL )
- info->chars[i]->orig_pos = i;
- }
+ for ( i=0; i<info->glyph_cnt ; ++i )
+ if ( info->chars[i]!=NULL )
+ info->chars[i]->orig_pos = i;
+ }
if ( info->to_order2 ) {
- for ( i=0; i<info->glyph_cnt; ++i )
- SCConvertToOrder2(info->chars[i]);
+ for ( i=0; i<info->glyph_cnt; ++i )
+ SCConvertToOrder2(info->chars[i]);
}
for ( i=0; fontnames[i]!=NULL && i<1; ++i ) {
- free(fontnames[i]);
- TopDictFree(dicts[i]);
+ free(fontnames[i]);
+ TopDictFree(dicts[i]);
}
free(fontnames); free(dicts);
if ( strings!=NULL ) {
- for ( i=0; strings[i]!=NULL; ++i )
- free(strings[i]);
- free(strings);
+ for ( i=0; strings[i]!=NULL; ++i )
+ free(strings[i]);
+ free(strings);
}
for ( i=0; i<gsubs.cnt; ++i )
- free(gsubs.values[i]);
+ free(gsubs.values[i]);
free(gsubs.values); free(gsubs.lens);
-return( 1 );
+ return 1 ;
}
static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) {
@@ -3855,55 +3864,58 @@ static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) {
SplineChar *sc;
fseek(ttf,info->typ1_start,SEEK_SET);
-/* There appear to be about 20 bytes of garbage (well, I don't know what they */
-/* mean, so they are garbage to me) before the start of the PostScript. But */
-/* it's not exactly 20. I've seen 22 and 24. So see if we can find "%!PS-Adobe" */
-/* in the first few bytes of the file, and skip to there if found */
- { char buffer[41];
+
+ /* There appear to be about 20 bytes of garbage (well, I don't know what they */
+ /* mean, so they are garbage to me) before the start of the PostScript. But */
+ /* it's not exactly 20. I've seen 22 and 24. So see if we can find "%!PS-Adobe" */
+ /* in the first few bytes of the file, and skip to there if found */
+
+ {
+ char buffer[41];
if(fread(buffer,1,sizeof(buffer),ttf) != sizeof(buffer))
-return( false );
- buffer[40] = '\0';
- for ( i=39; i>=0; --i )
- if ( buffer[i]=='%' && buffer[i+1]=='!' )
- break;
- if ( i<0 )
- i = 0;
- fseek(ttf,info->typ1_start+i,SEEK_SET);
+ return( false );
+ buffer[40] = '\0';
+ for ( i=39; i>=0; --i )
+ if ( buffer[i]=='%' && buffer[i+1]=='!' )
+ break;
+ if ( i<0 )
+ i = 0;
+ fseek(ttf,info->typ1_start+i,SEEK_SET);
}
tmp = tmpfile();
for ( i=0; i<(int)info->typ1_length; ++i )
- putc(getc(ttf),tmp);
+ putc(getc(ttf),tmp);
rewind(tmp);
fd = _ReadPSFont(tmp);
fclose(tmp);
if ( fd!=NULL ) {
- SplineFont *sf = SplineFontFromPSFont(fd);
- PSFontFree(fd);
- info->emsize = (sf->ascent+sf->descent);
- info->ascent = sf->ascent;
- info->descent = sf->descent;
- if ( sf->subfontcnt!=0 ) {
- info->subfontcnt = sf->subfontcnt;
- info->subfonts = sf->subfonts;
- info->cidregistry = copy(sf->cidregistry);
- info->ordering = copy(sf->ordering);
- info->supplement = sf->supplement;
- info->cidfontversion = sf->cidversion;
- sf->subfonts = NULL;
- sf->subfontcnt = 0;
- } else {
- info->chars = sf->glyphs;
- info->glyph_cnt = sf->glyphcnt;
- for ( i=sf->glyphcnt-1; i>=0; --i ) if ( (sc=sf->glyphs[i])!=NULL )
- sc->parent = NULL;
- sf->glyphs = NULL;
- sf->glyphcnt = 0;
- }
- SplineFontFree(sf);
-return( true );
+ SplineFont *sf = SplineFontFromPSFont(fd);
+ PSFontFree(fd);
+ info->emsize = (sf->ascent+sf->descent);
+ info->ascent = sf->ascent;
+ info->descent = sf->descent;
+ if ( sf->subfontcnt!=0 ) {
+ info->subfontcnt = sf->subfontcnt;
+ info->subfonts = sf->subfonts;
+ info->cidregistry = copy(sf->cidregistry);
+ info->ordering = copy(sf->ordering);
+ info->supplement = sf->supplement;
+ info->cidfontversion = sf->cidversion;
+ sf->subfonts = NULL;
+ sf->subfontcnt = 0;
+ } else {
+ info->chars = sf->glyphs;
+ info->glyph_cnt = sf->glyphcnt;
+ for ( i=sf->glyphcnt-1; i>=0; --i ) if ( (sc=sf->glyphs[i])!=NULL )
+ sc->parent = NULL;
+ sf->glyphs = NULL;
+ sf->glyphcnt = 0;
+ }
+ SplineFontFree(sf);
+ return( true );
}
-return( false );
+ return( false );
}
static void readttfwidths(FILE *ttf,struct ttfinfo *info) {
@@ -4839,41 +4851,41 @@ return;
for ( i=0; i<count; ++i ) {
int gid = getushort(ttf);
if ( dounicode )
- info->chars[gid]->unicodeenc = first+i;
+ info->chars[gid]->unicodeenc = first+i;
if ( map!=NULL && first+i < map->enccount )
- map->map[first+i] = gid;
+ map->map[first+i] = gid;
}
} else if ( format==12 ) {
uint32 ngroups, start, end, startglyph;
if ( !enc->is_unicodefull ) {
- IError("I don't support 32 bit characters except for the UCS-4 (MS platform, specific=10)" );
- enc = FindOrMakeEncoding("UnicodeFull");
+ IError("I don't support 32 bit characters except for the UCS-4 (MS platform, specific=10)" );
+ enc = FindOrMakeEncoding("UnicodeFull");
}
ngroups = getlong(ttf);
for ( j=0; j<(int)ngroups; ++j ) {
- start = getlong(ttf);
- end = getlong(ttf);
- startglyph = getlong(ttf);
- if ( justinuse==git_justinuse ) {
- for ( i=start; i<=(int)end; ++i )
- if ( startglyph+i-start < (unsigned)info->glyph_cnt )
- info->inuse[startglyph+i-start]= 1;
- else
- break;
- } else
- for ( i=start; i<=(int)end; ++i ) {
- if ( startglyph+i-start >= (unsigned)info->glyph_cnt ||
- info->chars[startglyph+i-start]==NULL ) {
- LogError( _("Bad font: Encoding data out of range.\n") );
- info->bad_cmap = true;
- break;
- } else {
- if ( dounicode )
- info->chars[startglyph+i-start]->unicodeenc = i;
- if ( map!=NULL && i < map->enccount && i>=0)
- map->map[i] = startglyph+i-start;
- }
- }
+ start = getlong(ttf);
+ end = getlong(ttf);
+ startglyph = getlong(ttf);
+ if ( justinuse==git_justinuse ) {
+ for ( i=start; i<=(int)end; ++i )
+ if ( startglyph+i-start < (unsigned)info->glyph_cnt )
+ info->inuse[startglyph+i-start]= 1;
+ else
+ break;
+ } else {
+ for ( i=start; i<=(int)end; ++i ) {
+ if ( startglyph+i-start >= (unsigned)info->glyph_cnt || info->chars[startglyph+i-start]==NULL ) {
+ LogError( _("Bad font: Encoding data out of range.\n") );
+ info->bad_cmap = true;
+ break;
+ } else {
+ if ( dounicode )
+ info->chars[startglyph+i-start]->unicodeenc = i;
+ if ( map!=NULL && i < map->enccount && i>=0)
+ map->map[i] = startglyph+i-start;
+ }
+ }
+ }
}
}
}
@@ -5069,7 +5081,7 @@ static void readttfpostnames(FILE *ttf,struct ttfinfo *info) {
nm[j] = getc(ttf);
nm[j] = '\0';
if ( indexes[i]<info->glyph_cnt && info->chars[indexes[i]]!=NULL ) {
- if (info->chars[indexes[i]]->name)
+ if (info->chars[indexes[i]]->name)
free( info->chars[indexes[i]]->name );
info->chars[indexes[i]]->name = nm;
#if 0 /* Too many fonts have badly named glyphs */
@@ -6083,7 +6095,7 @@ static SplineFont *SFFillFromTTFInfo(struct ttfinfo *info) {
free(info->savetab);
if (info->chosenname)
- free(info->chosenname);
+ free(info->chosenname);
if ( sf->copyright==NULL )
sf->copyright = info->copyright;
else
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
index 91dcfeee028..afbf08520d4 100644
--- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
+++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c
@@ -35,7 +35,10 @@
#define FONT_GLYPHS_METATABLE "fontloader.splinefont.glyphs"
#define FONT_GLYPH_METATABLE "fontloader.splinefont.glyph"
-#define LUA_OTF_VERSION "0.4"
+#define LUA_OTF_VERSION "0.5"
+
+extern void normal_error(const char *t, const char *p);
+extern void formatted_error(const char *t, const char *fmt, ...);
static const char *possub_type_enum[] = {
"null", "position", "pair", "substitution",
@@ -276,6 +279,7 @@ static int ff_close(lua_State * L)
return 0;
}
+/*
static int notdef_loc(SplineFont * sf)
{
int k;
@@ -291,6 +295,20 @@ static int notdef_loc(SplineFont * sf)
l = sf->glyphcnt;
return l;
}
+*/
+
+static int notdef_loc(SplineFont * sf)
+{
+ int k;
+ for (k = 0; k < sf->glyphcnt; k++) {
+ if (sf->glyphs[k]) {
+ if (strcmp(sf->glyphs[k]->name, ".notdef") == 0) {
+ return k ;
+ }
+ }
+ }
+ return -1;
+}
static int ff_apply_featurefile(lua_State * L)
{
@@ -323,15 +341,15 @@ static int ff_apply_afmfile(lua_State * L)
fname = luaL_checkstring(L, 2);
CheckAfmOfPostscript(*sf, fname, (*sf)->map);
if (gww_error_count > 0) {
- int i;
- 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();
+ int i;
+ 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);
+ lua_pushnil(L);
}
return 1;
}
@@ -594,8 +612,6 @@ static int do_handle_lookup(lua_State * L, struct otlookup *lookup, SplineFont *
}
lua_setfield(L, -2, "flags");
-
-
dump_stringfield(L, "name", lookup->lookup_name);
if (lookup->features != NULL) {
@@ -967,9 +983,6 @@ static void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvm
lua_pushnumber(L, glyph->ymax);
lua_rawset(L, -3);
lua_setfield(L, -2, "boundingbox");
- if (glyph->orig_pos>=0) {
- dump_intfield(L,"orig_pos",glyph->orig_pos);
-}
if (hasvmetrics) {
dump_intfield(L, "vwidth", glyph->vwidth);
if (glyph->tsb != 0)
@@ -1205,31 +1218,17 @@ static void handle_pfminfo(lua_State * L, struct pfminfo pfm)
dump_intfield(L, "firstchar", pfm.firstchar);
dump_intfield(L, "lastchar", pfm.lastchar);
lua_createtable(L, 0, 10);
- dump_enumfield(L, "familytype",
- fix_range(panose_values_0_max, pfm.panose[0]),
- panose_values_0);
- dump_enumfield(L, "serifstyle",
- fix_range(panose_values_1_max, pfm.panose[1]),
- panose_values_1);
- dump_enumfield(L, "weight", fix_range(panose_values_2_max, pfm.panose[2]),
- panose_values_2);
- dump_enumfield(L, "proportion",
- fix_range(panose_values_3_max, pfm.panose[3]),
- panose_values_3);
- dump_enumfield(L, "contrast", fix_range(panose_values_4_max, pfm.panose[4]),
- panose_values_4);
- dump_enumfield(L, "strokevariation",
- fix_range(panose_values_5_max, pfm.panose[5]),
- panose_values_5);
- dump_enumfield(L, "armstyle", fix_range(panose_values_6_max, pfm.panose[6]),
- panose_values_6);
- dump_enumfield(L, "letterform",
- fix_range(panose_values_7_max, pfm.panose[7]),
- panose_values_7);
- dump_enumfield(L, "midline", fix_range(panose_values_8_max, pfm.panose[8]),
- panose_values_8);
- dump_enumfield(L, "xheight", fix_range(panose_values_9_max, pfm.panose[9]),
- panose_values_9);
+
+ dump_enumfield(L, "familytype", fix_range(panose_values_0_max, pfm.panose[0]), panose_values_0);
+ dump_enumfield(L, "serifstyle", fix_range(panose_values_1_max, pfm.panose[1]), panose_values_1);
+ dump_enumfield(L, "weight", fix_range(panose_values_2_max, pfm.panose[2]), panose_values_2);
+ dump_enumfield(L, "proportion", fix_range(panose_values_3_max, pfm.panose[3]), panose_values_3);
+ dump_enumfield(L, "contrast", fix_range(panose_values_4_max, pfm.panose[4]), panose_values_4);
+ dump_enumfield(L, "strokevariation", fix_range(panose_values_5_max, pfm.panose[5]), panose_values_5);
+ dump_enumfield(L, "armstyle", fix_range(panose_values_6_max, pfm.panose[6]), panose_values_6);
+ dump_enumfield(L, "letterform", fix_range(panose_values_7_max, pfm.panose[7]), panose_values_7);
+ dump_enumfield(L, "midline", fix_range(panose_values_8_max, pfm.panose[8]), panose_values_8);
+ dump_enumfield(L, "xheight", fix_range(panose_values_9_max, pfm.panose[9]), panose_values_9);
lua_setfield(L, -2, "panose");
dump_intfield(L, "fstype", pfm.fstype);
@@ -1325,8 +1324,7 @@ static char *do_handle_enc(lua_State * L, struct enc *enc)
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_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);
@@ -1366,9 +1364,11 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
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);
}
@@ -1379,13 +1379,12 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
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 (map->backmap[i] != -1) {
+ /*
if (i < notdef_loc)
lua_pushnumber(L, (i + 1));
else
+ */
lua_pushnumber(L, i);
lua_pushnumber(L, map->backmap[i]);
lua_rawset(L, -3);
@@ -1399,7 +1398,7 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc)
lua_newtable(L);
encname = do_handle_enc(L, map->enc);
lua_setfield(L, -2, "enc");
- lua_pushstring(L, encname);
+ lua_pushstring(L, encname);
lua_setfield(L, -2, "enc_name");
}
}
@@ -1438,13 +1437,12 @@ static void handle_ttflangname(lua_State * L, struct ttflangname *names)
static 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; */
+ /* uint8 has_base; */
+ /* uint8 processed, has_mark, matches, ac_num; */
+ /* uint8 ticked; */
}
static void handle_anchorclass(lua_State * L, struct anchorclass *anchor)
@@ -1473,19 +1471,19 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha
int k;
int match = 0;
if (name) {
- struct lookup_subtable *s = kerns->subtable;
- while (s != NULL) {
- if (strcmp(s->subtable_name,name)==0) {
- match = 1;
- break;
- }
+ struct lookup_subtable *s = kerns->subtable;
+ while (s != NULL) {
+ if (strcmp(s->subtable_name,name)==0) {
+ match = 1;
+ break;
+ }
s = s->next;
- }
+ }
} else {
- match = 1;
+ match = 1;
}
if (!match) {
- return 0;
+ return 0;
}
lua_checkstack(L, 4);
lua_createtable(L, kerns->first_cnt, 1);
@@ -1507,7 +1505,6 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha
if (!name) {
dump_subtable_name(L, "lookup", kerns->subtable);
}
-
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) {
@@ -1622,7 +1619,9 @@ static void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format)
}
lua_setfield(L, -2, "lookups");
} else {
- /*fprintf(stderr,"handle_fpst_rule(): No lookups?\n"); */
+ /*
+ fprintf(stderr,"handle_fpst_rule(): No lookups?\n");
+ */
}
}
@@ -1901,7 +1900,7 @@ static void handle_mmset(lua_State * L, struct mmset *mm)
static void handle_splinefont(lua_State * L, struct splinefont *sf)
{
int k;
- int fix_notdef = 0;
+ int fix_notdef = 0; /* obsolete */
int l = -1;
dump_stringfield(L, "table_version", LUA_OTF_VERSION);
@@ -1918,6 +1917,7 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf)
dump_floatfield(L, "uwidth", sf->uwidth);
dump_intfield(L, "ascent", sf->ascent);
dump_intfield(L, "descent", sf->descent);
+ dump_intfield(L, "notdef_loc",notdef_loc(sf));
if (sf->uniqueid!=0) {
dump_intfield(L, "uniqueid", sf->uniqueid);
}
@@ -1943,13 +1943,19 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf)
/* 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) {
+
+ /* this is obsolete */
+
/* 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++) {
@@ -2249,7 +2255,7 @@ static void do_ff_info(lua_State * L, SplineFont * sf)
dump_stringfield(L, "weight", sf->weight);
dump_intfield(L, "units_per_em", sf->units_per_em);
- /* These are not assigned in info... */
+
/*dump_intfield(L, "design_range_bottom", sf->design_range_bottom);*/
/*dump_intfield(L, "design_range_top", sf->design_range_top);*/
/*dump_intfield(L, "design_size", sf->design_size);*/
@@ -2259,6 +2265,7 @@ static void do_ff_info(lua_State * L, SplineFont * sf)
lua_setfield(L, -2, "pfminfo");
/* Do we need this ? */
+
if (sf->names != NULL) {
lua_newtable(L);
handle_ttflangname(L, sf->names);
@@ -2317,7 +2324,7 @@ typedef enum {
FK_vkerns,
FK_gsub,
FK_gpos,
- /* FK_sm, */ /*this was removed because AAT is not supported anymore*/
+ /* FK_sm, */ /* AAT is not supported anymore */
FK_features,
FK_mm,
FK_chosenname,
@@ -2339,6 +2346,7 @@ typedef enum {
FK_horiz_base,
FK_vert_base,
FK_extrema_bound,
+ FK_notdef_loc,
} font_key_values;
const char *font_keys[] = {
@@ -2413,10 +2421,10 @@ const char *font_keys[] = {
"horiz_base",
"vert_base",
"extrema_bound",
+ "notdef_loc",
NULL
};
-
typedef enum {
GK_name = 0,
GK_unicode,
@@ -2441,7 +2449,6 @@ typedef enum {
GK_vert_variants,
GK_horiz_variants,
GK_mathkern,
- GK_orig_pos,
} font_glyph_key_values;
const char *font_glyph_keys[] = {
@@ -2468,7 +2475,6 @@ const char *font_glyph_keys[] = {
"vert_variants",
"horiz_variants",
"mathkern",
- "orig_pos",
NULL
};
@@ -2500,7 +2506,7 @@ static int ff_glyphs_index(lua_State * L)
SplineFont *sf;
int gid = 0;
int l = -1;
- int fix_notdef = 0;
+ int fix_notdef = 0; /* obsolete */
lua_pushstring(L, "__sf");
lua_rawget(L, 1);
/* sf = *check_isfont(L, -1); */
@@ -2518,21 +2524,27 @@ static int ff_glyphs_index(lua_State * L)
}
/* 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;
}
+ */
/* some code to ensure that the .notdef ends up in slot 0
(this will actually be enforced by the CFF writer) */
if (fix_notdef) {
+ /* this is obsolete */
l = notdef_loc(sf);
/* now l is the .notdef location, adjust gid if needed */
- if (l == sf->glyphcnt) { /* no .notdef at all, will be created at zero */
+ if (l == sf->glyphcnt) {
+ /* no .notdef at all, will be created at zero */
if (gid == 0) {
- gid = l; /* .notdef was added at end */
+ /* we ask for .notdef but .notdef was added at end */
+ gid = l;
} else {
- gid--; /* f.glyphs[gid] == sf->glyphs[gid-1] */
+ /* f.glyphs[gid] == sf->glyphs[gid-1] */
+ gid--;
}
} else if (l != 0) {
if (gid == 0) {
@@ -2542,11 +2554,11 @@ static int ff_glyphs_index(lua_State * L)
}
}
}
- /* push the glyph */
+
if (sf->glyphs[gid] && sf->glyphs[gid] != (struct splinechar *)-1) {
lua_ff_pushglyph(L, sf->glyphs[gid]);
} else {
- lua_pushnil(L);
+ lua_pushnil(L);
}
return 1;
}
@@ -2564,175 +2576,167 @@ static int ff_glyph_index(lua_State * L)
}
key = luaL_checkoption(L, 2, NULL, font_glyph_keys);
switch (key) {
- case GK_name:
- lua_pushstring(L, glyph->name);
- break;
- case GK_unicode:
- lua_pushnumber(L, glyph->unicodeenc);
- break;
- case GK_boundingbox:
- if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0
- && glyph->ymin == 0) {
- DBounds bb;
- SplineCharFindBounds(glyph, &bb);
- glyph->xmin = bb.minx;
- glyph->ymin = bb.miny;
- glyph->xmax = bb.maxx;
- glyph->ymax = bb.maxy;
- }
- 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);
- break;
- case GK_vwidth:
- lua_pushnumber(L, glyph->vwidth);
- break;
- case GK_width:
- lua_pushnumber(L, glyph->width);
- break;
- case GK_lsidebearing:
- lua_pushnumber(L, glyph->lsidebearing);
- break;
- case GK_class:
- if (glyph->glyph_class > 0) {
- lua_pushstring(L, glyph_class_enum[glyph->glyph_class]);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_kerns:
- if (glyph->kerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L, glyph->kerns);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_vkerns:
- if (glyph->vkerns != NULL) {
- lua_newtable(L);
- handle_kernpair(L, glyph->vkerns);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_dependents:
- if (glyph->dependents != NULL) {
- lua_newtable(L);
- handle_splinecharlist(L, glyph->dependents);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_lookups:
- if (glyph->possub != NULL) {
- lua_newtable(L);
- handle_generic_pst(L, glyph->possub);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_ligatures:
- if (glyph->ligofme != NULL) {
- lua_newtable(L);
- handle_liglist(L, glyph->ligofme);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_comment:
- lua_pushstring(L, glyph->comment);
- break;
- case GK_anchors:
- if (glyph->anchor != NULL) {
- lua_newtable(L);
- handle_anchorpoint(L, glyph->anchor);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_altuni:
- if (glyph->altuni != NULL) {
- lua_newtable(L);
- handle_altuni(L, glyph->altuni);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_tex_height:
- if (glyph->tex_height != TEX_UNDEF) {
- lua_pushnumber(L, glyph->tex_height);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_tex_depth:
- if (glyph->tex_height != TEX_UNDEF) {
- lua_pushnumber(L, glyph->tex_depth);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_is_extended_shape:
- lua_pushnumber(L, glyph->is_extended_shape);
- break;
- case GK_italic_correction:
- if (glyph->italic_correction != TEX_UNDEF) {
- lua_pushnumber(L, glyph->italic_correction);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_top_accent:
- if (glyph->top_accent_horiz != TEX_UNDEF) {
- lua_pushnumber(L, glyph->top_accent_horiz);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_vert_variants:
- if (glyph->vert_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->vert_variants);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_horiz_variants:
- if (glyph->horiz_variants != NULL) {
- lua_newtable(L);
- handle_glyphvariants(L, glyph->horiz_variants);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_mathkern:
- if (glyph->mathkern != NULL) {
- lua_newtable(L);
- handle_mathkern(L, glyph->mathkern);
- } else {
- lua_pushnil(L);
- }
- break;
- case GK_orig_pos:
- if (glyph->orig_pos>=0) {
- lua_pushnumber(L, glyph->orig_pos);
- } else {
+ case GK_name:
+ lua_pushstring(L, glyph->name);
+ break;
+ case GK_unicode:
+ lua_pushnumber(L, glyph->unicodeenc);
+ break;
+ case GK_boundingbox:
+ if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0 && glyph->ymin == 0) {
+ DBounds bb;
+ SplineCharFindBounds(glyph, &bb);
+ glyph->xmin = bb.minx;
+ glyph->ymin = bb.miny;
+ glyph->xmax = bb.maxx;
+ glyph->ymax = bb.maxy;
+ }
+ 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);
+ break;
+ case GK_vwidth:
+ lua_pushnumber(L, glyph->vwidth);
+ break;
+ case GK_width:
+ lua_pushnumber(L, glyph->width);
+ break;
+ case GK_lsidebearing:
+ lua_pushnumber(L, glyph->lsidebearing);
+ break;
+ case GK_class:
+ if (glyph->glyph_class > 0) {
+ lua_pushstring(L, glyph_class_enum[glyph->glyph_class]);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_kerns:
+ if (glyph->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->kerns);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_vkerns:
+ if (glyph->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernpair(L, glyph->vkerns);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_dependents:
+ if (glyph->dependents != NULL) {
+ lua_newtable(L);
+ handle_splinecharlist(L, glyph->dependents);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_lookups:
+ if (glyph->possub != NULL) {
+ lua_newtable(L);
+ handle_generic_pst(L, glyph->possub);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_ligatures:
+ if (glyph->ligofme != NULL) {
+ lua_newtable(L);
+ handle_liglist(L, glyph->ligofme);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_comment:
+ lua_pushstring(L, glyph->comment);
+ break;
+ case GK_anchors:
+ if (glyph->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorpoint(L, glyph->anchor);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_altuni:
+ if (glyph->altuni != NULL) {
+ lua_newtable(L);
+ handle_altuni(L, glyph->altuni);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_tex_height:
+ if (glyph->tex_height != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->tex_height);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_tex_depth:
+ if (glyph->tex_height != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->tex_depth);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_is_extended_shape:
+ lua_pushnumber(L, glyph->is_extended_shape);
+ break;
+ case GK_italic_correction:
+ if (glyph->italic_correction != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->italic_correction);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_top_accent:
+ if (glyph->top_accent_horiz != TEX_UNDEF) {
+ lua_pushnumber(L, glyph->top_accent_horiz);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_vert_variants:
+ if (glyph->vert_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->vert_variants);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_horiz_variants:
+ if (glyph->horiz_variants != NULL) {
+ lua_newtable(L);
+ handle_glyphvariants(L, glyph->horiz_variants);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case GK_mathkern:
+ if (glyph->mathkern != NULL) {
+ lua_newtable(L);
+ handle_mathkern(L, glyph->mathkern);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ default:
lua_pushnil(L);
- }
- break;
- default:
- lua_pushnil(L);
}
return 1;
}
@@ -2742,12 +2746,10 @@ static int ff_index(lua_State * L)
SplineFont *sf;
int k, key;
/* sf = *check_isfont(L, 1); */
- if (!(is_userdata(L, 1, FONT_METATABLE) ||
- is_userdata(L, 1, FONT_SUBFONT_METATABLE))) {
+ if (!(is_userdata(L, 1, FONT_METATABLE) || is_userdata(L, 1, FONT_SUBFONT_METATABLE))) {
return luaL_error(L, "fontloader.__index: expected a (sub)font userdata object\n");
}
sf = *((SplineFont **)lua_touserdata(L, 1));
-
if (sf == NULL) {
lua_pushnil(L);
return 1;
@@ -2757,400 +2759,403 @@ static int ff_index(lua_State * L)
}
key = luaL_checkoption(L, 2, NULL, font_keys);
switch (key) {
- case FK_table_version:
- lua_pushstring(L, LUA_OTF_VERSION);
- break;
- case FK_fontname:
- lua_pushstring(L, sf->fontname);
- break;
- case FK_fullname:
- lua_pushstring(L, sf->fullname);
- break;
- case FK_familyname:
- lua_pushstring(L, sf->familyname);
- break;
- case FK_weight:
- lua_pushstring(L, sf->weight);
- break;
- case FK_copyright:
- lua_pushstring(L, sf->copyright);
- break;
- case FK_filename:
- lua_pushstring(L, sf->filename);
- break;
- case FK_version:
- lua_pushstring(L, sf->version);
- break;
- case FK_italicangle:
- lua_pushnumber(L, sf->italicangle);
- break;
- case FK_upos:
- lua_pushnumber(L, sf->upos);
- break;
- case FK_uwidth:
- lua_pushnumber(L, sf->uwidth);
- break;
- case FK_ascent:
- lua_pushnumber(L, sf->ascent);
- break;
- case FK_descent:
- lua_pushnumber(L, sf->descent);
- break;
- case FK_uniqueid:
- lua_pushnumber(L, sf->uniqueid);
- break;
- case FK_glyphcnt:
- if (sf->glyphcnt > 0) {
- lua_pushnumber(L, sf->glyphmax - sf->glyphmin + 1);
- } else {
- lua_pushnumber(L, 0);
- }
- break;
- case FK_glyphmax:
- lua_pushnumber(L, sf->glyphmax - 1);
- break;
- case FK_glyphmin:
- lua_pushnumber(L, sf->glyphmin);
- break;
- case FK_units_per_em:
- lua_pushnumber(L, sf->units_per_em);
- break;
- case FK_lookups:
- if (sf->possub != NULL) {
- lua_newtable(L);
- handle_generic_fpst(L, sf->possub);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_glyphs:
- lua_newtable(L); /* the virtual glyph table */
- lua_pushstring(L, "__sf");
- lua_pushvalue(L, 1); /* that is our font */
- lua_rawset(L, -3);
- luaL_getmetatable(L, FONT_GLYPHS_METATABLE);
- lua_setmetatable(L, -2); /* assign the metatable */
- break;
- case FK_hasvmetrics:
- lua_pushnumber(L, sf->hasvmetrics);
- break;
- case FK_onlybitmaps:
- lua_pushnumber(L, sf->onlybitmaps);
- break;
- case FK_serifcheck:
- lua_pushnumber(L, sf->serifcheck);
- break;
- case FK_isserif:
- lua_pushnumber(L, sf->isserif);
- break;
- case FK_issans:
- lua_pushnumber(L, sf->issans);
- break;
- case FK_encodingchanged:
- lua_pushnumber(L, sf->encodingchanged);
- break;
- case FK_strokedfont:
- lua_pushnumber(L, sf->strokedfont);
- break;
- case FK_use_typo_metrics:
- lua_pushnumber(L, sf->use_typo_metrics);
- break;
- case FK_weight_width_slope_only:
- lua_pushnumber(L, sf->weight_width_slope_only);
- break;
- case FK_head_optimized_for_cleartype:
- lua_pushnumber(L, sf->head_optimized_for_cleartype);
- break;
- case FK_uni_interp:
- lua_pushstring(L, uni_interp_enum[(sf->uni_interp + 1)]);
- break;
- case FK_map:
- if (sf->map != NULL) {
- lua_newtable(L);
- handle_encmap(L, sf->map, notdef_loc(sf));
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_origname:
- lua_pushstring(L, sf->origname);
- break;
- case FK_private:
- if (sf->private != NULL) {
- lua_newtable(L);
- handle_psdict(L, sf->private);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_xuid:
- lua_pushstring(L, sf->xuid);
- break;
- case FK_pfminfo:
- lua_createtable(L, 0, 40);
- handle_pfminfo(L, sf->pfminfo);
- break;
- case FK_names:
- if (sf->names != NULL) {
- lua_newtable(L);
- handle_ttflangname(L, sf->names);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_cidinfo:
- 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);
- break;
- case FK_subfonts:
- if (sf->subfontcnt > 0) {
- lua_createtable(L, sf->subfontcnt, 0);
- for (k = 0; k < sf->subfontcnt; k++) {
- lua_ff_pushsubfont(L, sf->subfonts[k]);
- lua_rawseti(L, -2, (k + 1));
+ case FK_table_version:
+ lua_pushstring(L, LUA_OTF_VERSION);
+ break;
+ case FK_fontname:
+ lua_pushstring(L, sf->fontname);
+ break;
+ case FK_fullname:
+ lua_pushstring(L, sf->fullname);
+ break;
+ case FK_familyname:
+ lua_pushstring(L, sf->familyname);
+ break;
+ case FK_weight:
+ lua_pushstring(L, sf->weight);
+ break;
+ case FK_copyright:
+ lua_pushstring(L, sf->copyright);
+ break;
+ case FK_filename:
+ lua_pushstring(L, sf->filename);
+ break;
+ case FK_version:
+ lua_pushstring(L, sf->version);
+ break;
+ case FK_italicangle:
+ lua_pushnumber(L, sf->italicangle);
+ break;
+ case FK_upos:
+ lua_pushnumber(L, sf->upos);
+ break;
+ case FK_uwidth:
+ lua_pushnumber(L, sf->uwidth);
+ break;
+ case FK_ascent:
+ lua_pushnumber(L, sf->ascent);
+ break;
+ case FK_descent:
+ lua_pushnumber(L, sf->descent);
+ break;
+ case FK_uniqueid:
+ lua_pushnumber(L, sf->uniqueid);
+ break;
+ case FK_glyphcnt:
+ if (sf->glyphcnt > 0) {
+ lua_pushnumber(L, sf->glyphmax - sf->glyphmin + 1);
+ } else {
+ lua_pushnumber(L, 0);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_comments:
- lua_pushstring(L, sf->comments);
- break;
- case FK_fontlog:
- lua_pushstring(L, sf->fontlog);
- break;
- case FK_cvt_names:
- 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));
+ break;
+ case FK_glyphmax:
+ lua_pushnumber(L, sf->glyphmax - 1);
+ break;
+ case FK_glyphmin:
+ lua_pushnumber(L, sf->glyphmin);
+ break;
+ case FK_units_per_em:
+ lua_pushnumber(L, sf->units_per_em);
+ break;
+ case FK_lookups:
+ if (sf->possub != NULL) {
+ lua_newtable(L);
+ handle_generic_fpst(L, sf->possub);
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_ttf_tables:
- if (sf->ttf_tables != NULL) {
- lua_newtable(L);
- handle_ttf_table(L, sf->ttf_tables);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_ttf_tab_saved:
- if (sf->ttf_tab_saved != NULL) {
- lua_newtable(L);
- handle_ttf_table(L, sf->ttf_tab_saved);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_texdata:
- 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);
+ break;
+ case FK_glyphs:
+ lua_newtable(L); /* the virtual glyph table */
+ lua_pushstring(L, "__sf");
+ lua_pushvalue(L, 1); /* that is our font */
+ lua_rawset(L, -3);
+ luaL_getmetatable(L, FONT_GLYPHS_METATABLE);
+ lua_setmetatable(L, -2); /* assign the metatable */
+ break;
+ case FK_hasvmetrics:
+ lua_pushnumber(L, sf->hasvmetrics);
+ break;
+ case FK_onlybitmaps:
+ lua_pushnumber(L, sf->onlybitmaps);
+ break;
+ case FK_serifcheck:
+ lua_pushnumber(L, sf->serifcheck);
+ break;
+ case FK_isserif:
+ lua_pushnumber(L, sf->isserif);
+ break;
+ case FK_issans:
+ lua_pushnumber(L, sf->issans);
+ break;
+ case FK_encodingchanged:
+ lua_pushnumber(L, sf->encodingchanged);
+ break;
+ case FK_strokedfont:
+ lua_pushnumber(L, sf->strokedfont);
+ break;
+ case FK_use_typo_metrics:
+ lua_pushnumber(L, sf->use_typo_metrics);
+ break;
+ case FK_weight_width_slope_only:
+ lua_pushnumber(L, sf->weight_width_slope_only);
+ break;
+ case FK_head_optimized_for_cleartype:
+ lua_pushnumber(L, sf->head_optimized_for_cleartype);
+ break;
+ case FK_uni_interp:
+ lua_pushstring(L, uni_interp_enum[(sf->uni_interp + 1)]);
+ break;
+ case FK_map:
+ if (sf->map != NULL) {
+ lua_newtable(L);
+ handle_encmap(L, sf->map, 0); /* notdef_loc(sf)); */
+ } else {
+ lua_pushnil(L);
}
- lua_setfield(L, -2, "params");
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_anchor_classes:
- if (sf->anchor != NULL) {
- lua_newtable(L);
- handle_anchorclass(L, sf->anchor);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_kerns:
- if (sf->kerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L, sf->kerns, NULL);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_vkerns:
- if (sf->vkerns != NULL) {
- lua_newtable(L);
- handle_kernclass(L, sf->vkerns, NULL);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_gsub:
- if (sf->gsub_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L, sf->gsub_lookups, sf);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_gpos:
- if (sf->gpos_lookups != NULL) {
- lua_newtable(L);
- handle_lookup(L, sf->gpos_lookups, sf);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_mm:
- if (sf->mm != NULL) {
- lua_newtable(L);
- handle_mmset(L, sf->mm);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_chosenname:
- lua_pushstring(L, sf->chosenname);
- break;
- case FK_macstyle:
- lua_pushnumber(L, sf->macstyle);
- break;
- case FK_fondname:
- lua_pushstring(L, sf->fondname);
- break;
- case FK_design_size:
- lua_pushnumber(L, sf->design_size);
- break;
- case FK_fontstyle_id:
- lua_pushnumber(L, sf->fontstyle_id);
- break;
- case FK_fontstyle_name:
- if (sf->fontstyle_name != NULL) {
- lua_newtable(L);
- handle_otfname(L, sf->fontstyle_name);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_design_range_bottom:
- lua_pushnumber(L, sf->design_range_bottom);
- break;
- case FK_design_range_top:
- lua_pushnumber(L, sf->design_range_top);
- break;
- case FK_strokewidth:
- lua_pushnumber(L, sf->strokewidth);
- break;
- case FK_mark_classes:
- 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]);
+ break;
+ case FK_origname:
+ lua_pushstring(L, sf->origname);
+ break;
+ case FK_private:
+ if (sf->private != NULL) {
+ lua_newtable(L);
+ handle_psdict(L, sf->private);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_xuid:
+ lua_pushstring(L, sf->xuid);
+ break;
+ case FK_pfminfo:
+ lua_createtable(L, 0, 40);
+ handle_pfminfo(L, sf->pfminfo);
+ break;
+ case FK_names:
+ if (sf->names != NULL) {
+ lua_newtable(L);
+ handle_ttflangname(L, sf->names);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_cidinfo:
+ 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);
+ break;
+ case FK_subfonts:
+ if (sf->subfontcnt > 0) {
+ lua_createtable(L, sf->subfontcnt, 0);
+ for (k = 0; k < sf->subfontcnt; k++) {
+ lua_ff_pushsubfont(L, sf->subfonts[k]);
+ lua_rawseti(L, -2, (k + 1));
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_comments:
+ lua_pushstring(L, sf->comments);
+ break;
+ case FK_fontlog:
+ lua_pushstring(L, sf->fontlog);
+ break;
+ case FK_cvt_names:
+ 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));
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_ttf_tables:
+ if (sf->ttf_tables != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tables);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_ttf_tab_saved:
+ if (sf->ttf_tab_saved != NULL) {
+ lua_newtable(L);
+ handle_ttf_table(L, sf->ttf_tab_saved);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_texdata:
+ 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");
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_creationtime:
- lua_pushnumber(L, sf->creationtime);
- break;
- case FK_modificationtime:
- lua_pushnumber(L, sf->modificationtime);
- break;
- case FK_os2_version:
- lua_pushnumber(L, sf->os2_version);
- break;
- case FK_sfd_version:
- lua_pushnumber(L, sf->sfd_version);
- break;
- case FK_math:
- if (sf->MATH != NULL) {
- lua_newtable(L);
- handle_MATH(L, sf->MATH);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_validation_state:
- 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++);
+ break;
+ case FK_anchor_classes:
+ if (sf->anchor != NULL) {
+ lua_newtable(L);
+ handle_anchorclass(L, sf->anchor);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_glyph_table) {
- lua_pushliteral(L, "bad_glyph_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_kerns:
+ if (sf->kerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->kerns, NULL);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_cff_table) {
- lua_pushliteral(L, "bad_cff_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_vkerns:
+ if (sf->vkerns != NULL) {
+ lua_newtable(L);
+ handle_kernclass(L, sf->vkerns, NULL);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_metrics_table) {
- lua_pushliteral(L, "bad_metrics_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_gsub:
+ if (sf->gsub_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gsub_lookups, sf);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_cmap_table) {
- lua_pushliteral(L, "bad_cmap_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_gpos:
+ if (sf->gpos_lookups != NULL) {
+ lua_newtable(L);
+ handle_lookup(L, sf->gpos_lookups, sf);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_bitmaps_table) {
- lua_pushliteral(L, "bad_bitmaps_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_mm:
+ if (sf->mm != NULL) {
+ lua_newtable(L);
+ handle_mmset(L, sf->mm);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_gx_table) {
- lua_pushliteral(L, "bad_gx_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_chosenname:
+ lua_pushstring(L, sf->chosenname);
+ break;
+ case FK_macstyle:
+ lua_pushnumber(L, sf->macstyle);
+ break;
+ case FK_fondname:
+ lua_pushstring(L, sf->fondname);
+ break;
+ case FK_design_size:
+ lua_pushnumber(L, sf->design_size);
+ break;
+ case FK_fontstyle_id:
+ lua_pushnumber(L, sf->fontstyle_id);
+ break;
+ case FK_fontstyle_name:
+ if (sf->fontstyle_name != NULL) {
+ lua_newtable(L);
+ handle_otfname(L, sf->fontstyle_name);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_ot_table) {
- lua_pushliteral(L, "bad_ot_table");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_design_range_bottom:
+ lua_pushnumber(L, sf->design_range_bottom);
+ break;
+ case FK_design_range_top:
+ lua_pushnumber(L, sf->design_range_top);
+ break;
+ case FK_strokewidth:
+ lua_pushnumber(L, sf->strokewidth);
+ break;
+ case FK_mark_classes:
+ 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);
+ }
+ }
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_os2_version) {
- lua_pushliteral(L, "bad_os2_version");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_creationtime:
+ lua_pushnumber(L, sf->creationtime);
+ break;
+ case FK_modificationtime:
+ lua_pushnumber(L, sf->modificationtime);
+ break;
+ case FK_os2_version:
+ lua_pushnumber(L, sf->os2_version);
+ break;
+ case FK_sfd_version:
+ lua_pushnumber(L, sf->sfd_version);
+ break;
+ case FK_math:
+ if (sf->MATH != NULL) {
+ lua_newtable(L);
+ handle_MATH(L, sf->MATH);
+ } else {
+ lua_pushnil(L);
}
- if (st & lvs_bad_sfnt_header) {
- lua_pushliteral(L, "bad_sfnt_header");
- lua_rawseti(L, -2, val++);
+ break;
+ case FK_validation_state:
+ 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++);
+ }
+ } else {
+ lua_pushnil(L);
}
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_horiz_base:
- if (sf->horiz_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->horiz_base);
- } else {
- lua_pushnil(L);
- }
- break;
- case FK_vert_base:
- if (sf->vert_base != NULL) {
- lua_newtable(L);
- handle_base(L, sf->vert_base);
- } else {
+ break;
+ case FK_horiz_base:
+ if (sf->horiz_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->horiz_base);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_vert_base:
+ if (sf->vert_base != NULL) {
+ lua_newtable(L);
+ handle_base(L, sf->vert_base);
+ } else {
+ lua_pushnil(L);
+ }
+ break;
+ case FK_extrema_bound:
+ lua_pushnumber(L, sf->extrema_bound);
+ break;
+ case FK_notdef_loc:
+ lua_pushinteger(L, notdef_loc(sf));
+ break;
+ default:
+ /* can't actually happen, |luaL_checkoption| raises an error instead */
lua_pushnil(L);
- }
- break;
- case FK_extrema_bound:
- lua_pushnumber(L, sf->extrema_bound);
- break;
- default:
- /* can't actually happen, |luaL_checkoption| raises an error instead */
- lua_pushnil(L);
- break;
+ break;
}
return 1;
}
@@ -3232,10 +3237,7 @@ static void ff_do_cff(SplineFont * sf, char *filename, unsigned char **buf,
fclose(f);
return;
}
- /* snprintf(errmsg, 255, "%s => CFF, failed", sf->filename); */
- /* normal_error("fontloader",errmsg); */ /* TODO */
- fprintf(stdout,"%s => CFF, failed", sf->filename);
- exit(EXIT_FAILURE);
+ formatted_error("fontloader","%s to CFF conversion failed", sf->filename);
}
/* exported for writecff.c */
@@ -3273,9 +3275,7 @@ int ff_get_ttc_index(char *ffname, char *psname)
sf = ReadSplineFontInfo((char *) ffname, openflags);
if (sf == NULL) {
- /* normal_error("fontloader","font loading failed unexpectedly"); */ /* TODO */
- fprintf(stdout,"font loading failed unexpectedly\n");
- exit(EXIT_FAILURE);
+ normal_error("fontloader","font loading failed unexpectedly");
}
while (sf != NULL) {
if (strcmp(sf->fontname, psname) == 0) {
@@ -3285,7 +3285,7 @@ int ff_get_ttc_index(char *ffname, char *psname)
sf = sf->next;
}
if (index>=0)
- return (i-index-1);
+ return (i-index-1);
return -1;
}