diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-10-05 20:49:02 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-10-05 20:49:02 +0000 |
commit | 9f0c232e474828b1552ecd430a237b28e8e57e7f (patch) | |
tree | 11223de78961eed1d125e9d1e1eb5bb056e1f43c /Build/source/texk/web2c/luatexdir/luafontloader | |
parent | a3a26fc921f8182b70d96386e6d76ce051ed247f (diff) |
web2c/luatexdir: Sync with the upstream trunk.
git-svn-id: svn://tug.org/texlive/trunk@38555 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luafontloader')
6 files changed, 192 insertions, 143 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/lookups.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/lookups.c index 85bcd91b94f..243d4ec6a44 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/lookups.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/lookups.c @@ -22,7 +22,7 @@ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "fontforgevw.h" #include <chardata.h> @@ -1179,14 +1179,14 @@ static struct { uint32 tag; } localscripts[] = { { N_("Arabic"), CHR('a','r','a','b') }, - { N_("Aramaic"), CHR('a','r','a','m') }, + { N_("Aramaic"), CHR('a','r','a','m') }, /* Only in ff */ { N_("Armenian"), CHR('a','r','m','n') }, - { N_("Avestan"), CHR('a','v','e','s') }, + { N_("Avestan"), CHR('a','v','e','s') }, /* Only in ff */ { N_("Balinese"), CHR('b','a','l','i') }, { N_("Batak"), CHR('b','a','t','k') }, { N_("Bengali"), CHR('b','e','n','g') }, { N_("Bengali2"), CHR('b','n','g','2') }, - { N_("Bliss Symbolics"), CHR('b','l','i','s') }, + { N_("Bliss Symbolics"), CHR('b','l','i','s') }, /* Only in ff */ { N_("Bopomofo"), CHR('b','o','p','o') }, { N_("Brāhmī"), CHR('b','r','a','h') }, { N_("Braille"), CHR('b','r','a','i') }, @@ -1198,11 +1198,11 @@ static struct { { N_("Cherokee"), CHR('c','h','a','m') }, { N_("Cham"), CHR('c','h','a','m') }, { N_("Cherokee"), CHR('c','h','e','r') }, - { N_("Cirth"), CHR('c','i','r','t') }, + { N_("Cirth"), CHR('c','i','r','t') }, /* Only in ff */ { N_("CJK Ideographic"), CHR('h','a','n','i') }, { N_("Coptic"), CHR('c','o','p','t') }, { N_("Cypro-Minoan"), CHR('c','p','r','t') }, - { N_("Cypriot syllabary"), CHR('c','p','m','n') }, + { N_("Cypriot syllabary"), CHR('c','p','m','n') }, /* Only in ff */ { N_("Cyrillic"), CHR('c','y','r','l') }, { N_("Default"), CHR('D','F','L','T') }, { N_("Deseret (Mormon)"), CHR('d','s','r','t') }, @@ -1242,35 +1242,35 @@ static struct { { N_("Latin"), CHR('l','a','t','n') }, { N_("Lepcha (Róng)"), CHR('l','e','p','c') }, { N_("Limbu"), CHR('l','i','m','b') }, /* Not in ISO 15924 !!!!!, just guessing */ - { N_("Linear A"), CHR('l','i','n','a') }, + { N_("Linear A"), CHR('l','i','n','a') }, /* Only in ff */ { N_("Linear B"), CHR('l','i','n','b') }, { N_("Lycian"), CHR('l','y','c','i') }, { N_("Lydian"), CHR('l','y','d','i') }, { N_("Mandaean"), CHR('m','a','n','d') }, /* { N_("Mayan hieroglyphs"), CHR('m','a','y','a') },*/ { N_("Malayālam"), CHR('m','l','y','m') }, - { N_("Malayālam2"), CHR('m','l','y','2') }, + { N_("Malayālam2"), CHR('m','l','y','2') }, /* Only in ff, should be mlm2 */ { N_("Mathematical Alphanumeric Symbols"), CHR('m','a','t','h') }, { N_("Mongolian"), CHR('m','o','n','g') }, - { N_("Musical"), CHR('m','u','s','i') }, + { N_("Musical"), CHR('m','u','s','i') }, /* Only in ff, should be musc */ { N_("Myanmar"), CHR('m','y','m','r') }, { N_("New Tai Lue"), CHR('t','a','l','u') }, { N_("N'Ko"), CHR('n','k','o',' ') }, { N_("Ogham"), CHR('o','g','a','m') }, { N_("Ol Chiki"), CHR('o','l','c','k') }, { N_("Old Italic (Etruscan, Oscan, etc.)"), CHR('i','t','a','l') }, - { N_("Old Permic"), CHR('p','e','r','m') }, + { N_("Old Permic"), CHR('p','e','r','m') }, /* Only in ff */ { N_("Old Persian cuneiform"), CHR('x','p','e','o') }, { N_("Oriya"), CHR('o','r','y','a') }, { N_("Oriya2"), CHR('o','r','y','2') }, { N_("Osmanya"), CHR('o','s','m','a') }, - { N_("Pahlavi"), CHR('p','a','l','v') }, + { N_("Pahlavi"), CHR('p','a','l','v') }, /* Only in ff */ { N_("Phags-pa"), CHR('p','h','a','g') }, { N_("Phoenician"), CHR('p','h','n','x') }, - { N_("Phaistos"), CHR('p','h','s','t') }, - { N_("Pollard Phonetic"), CHR('p','l','r','d') }, + { N_("Phaistos"), CHR('p','h','s','t') }, /* Only in ff */ + { N_("Pollard Phonetic"), CHR('p','l','r','d') }, /* Only in ff */ { N_("Rejang"), CHR('r','j','n','g') }, - { N_("Rongorongo"), CHR('r','o','r','o') }, + { N_("Rongorongo"), CHR('r','o','r','o') }, /* Only in ff */ { N_("Runic"), CHR('r','u','n','r') }, { N_("Saurashtra"), CHR('s','a','u','r') }, { N_("Shavian"), CHR('s','h','a','w') }, @@ -1287,15 +1287,15 @@ static struct { { N_("Tamil2"), CHR('t','m','l','2') }, { N_("Telugu"), CHR('t','e','l','u') }, { N_("Telugu2"), CHR('t','e','l','2') }, - { N_("Tengwar"), CHR('t','e','n','g') }, + { N_("Tengwar"), CHR('t','e','n','g') }, /* Only in ff */ { N_("Thaana"), CHR('t','h','a','a') }, { N_("Thai"), CHR('t','h','a','i') }, { N_("Tibetan"), CHR('t','i','b','t') }, { N_("Tifinagh (Berber)"), CHR('t','f','n','g') }, - { N_("Ugaritic"), CHR('u','g','r','t') }, /* Not in ISO 15924 !!!!!, just guessing */ + { N_("Ugaritic"), CHR('u','g','r','t') }, /* Only in ff, should be ugar */ { N_("Vai"), CHR('v','a','i',' ') }, /* { N_("Visible Speech"), CHR('v','i','s','p') },*/ - { N_("Cuneiform, Ugaritic"), CHR('x','u','g','a') }, + { N_("Cuneiform, Ugaritic"), CHR('x','u','g','a') }, /* Only in ff */ { N_("Yi") , CHR('y','i',' ',' ') }, /* { N_("Private Use Script 1"), CHR('q','a','a','a') },*/ /* { N_("Private Use Script 2"), CHR('q','a','a','b') },*/ 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 92efbc7800f..0a79633f11e 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettf.c @@ -938,7 +938,7 @@ return; free(tabs); fseek(ttf,restore_this_pos,SEEK_SET); } - + static struct tablenames { uint32 tag; char *name; } stdtables[] = { { CHR('a','c','n','t'), N_("accent attachment table") }, { CHR('a','v','a','r'), N_("axis variation table") }, @@ -1546,7 +1546,7 @@ static char *FindLangEntry(struct ttfinfo *info, int id ) { for ( cur=info->names; cur!=NULL && cur->names[id]==NULL; cur=cur->next ); if ( cur==NULL ) return( NULL ); - ret = copy(cur->names[id]); + ret = copy(cur->names[id]); return( ret ); } @@ -1602,7 +1602,7 @@ static void readttfcopyrights(FILE *ttf,struct ttfinfo *info) { name = getushort(ttf); str_len = getushort(ttf); stroff = getushort(ttf); - + TTFAddLangStr(ttf,info,name,str_len,tableoff+stroff, platform,specific,language); } @@ -2114,11 +2114,11 @@ return( sc ); 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); } - + return( sc ); } @@ -3669,20 +3669,30 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict, /*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); - info->subfonts[j]->map = encmap; + info->subfonts[j] = cffsffillup(subdicts[j],strings,scnt,info); + info->subfonts[j]->map = encmap; + 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 ) sf->glyphcnt = sf->glyphmax = cid+1; - /*if ( cid>=encmap->enccount ) encmap->enccount = cid+1;*/ + 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;*/ } for ( j=0; subdicts[j]!=NULL; ++j ) - info->subfonts[j]->glyphs = gcalloc(info->subfonts[j]->glyphcnt,sizeof(SplineChar *)); + info->subfonts[j]->glyphs = gcalloc(info->subfonts[j]->glyphcnt,sizeof(SplineChar *)); + /*encmap->encmax = encmap->enccount;*/ /*encmap->map = galloc(encmap->enccount*sizeof(int));*/ /*memset(encmap->map,-1,encmap->enccount*sizeof(int));*/ @@ -3697,49 +3707,46 @@ static void cidfigure(struct ttfinfo *info, struct topdicts *dict, map = FindCidMap(info->cidregistry,info->ordering,info->supplement,NULL); for ( i=0; i<info->glyph_cnt; ++i ) { - j = fdselect[i]; - sf = info->subfonts[ j ]; -/* The format allows for some dicts that are type1 strings and others that */ -/* are type2s. Which means that the global subrs will have a different bias */ -/* as we flip from font to font. So we can't set the bias when we read in */ -/* the subrs but must wait until we know which font we're working on. */ - 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; - subrs = &subdicts[j]->local_subrs; - subrs->bias = cstype==1 ? 0 : - subrs->cnt < 1240 ? 107 : - subrs->cnt <33900 ? 1131 : 32768; - - cid = dict->charset[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]->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 = cid; /* Bug! should be i, but I assume sf->chars[orig_pos]->orig_pos==orig_pos */ - if ( sf->glyphs[cid]->layers[ly_fore].refs!=NULL ) - IError( "Reference found in CID font. Can't fix it up"); - + j = fdselect[i]; + sf = info->subfonts[j]; + /* The format allows for some dicts that are type1 strings and others that */ + /* are type2s. Which means that the global subrs will have a different bias */ + /* as we flip from font to font. So we can't set the bias when we read in */ + /* the subrs but must wait until we know which font we're working on. */ + 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; + subrs = &subdicts[j]->local_subrs; + subrs->bias = cstype==1 ? 0 : + subrs->cnt < 1240 ? 107 : + subrs->cnt <33900 ? 1131 : 32768; + cid = dict->charset[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]->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 ) + 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 ) - sf->glyphs[cid]->width = subdicts[j]->defaultwidthx; - else - sf->glyphs[cid]->width += subdicts[j]->nominalwidthx; - } - ff_progress_next(); + if ( cstype==2 ) { + if ( sf->glyphs[cid]->width == (int16) 0x8000 ) + sf->glyphs[cid]->width = subdicts[j]->defaultwidthx; + else + sf->glyphs[cid]->width += subdicts[j]->nominalwidthx; + } + ff_progress_next(); } /* No need to do a reference fixup here-- the chars aren't associated */ - /* with any encoding as is required for seac */ + /* with any encoding as is required for seac */ } static int readcffglyphs(FILE *ttf,struct ttfinfo *info) { @@ -3857,7 +3864,7 @@ static int readtyp1glyphs(FILE *ttf,struct ttfinfo *info) { 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); @@ -3892,7 +3899,7 @@ return( true ); } return( false ); } - + static void readttfwidths(FILE *ttf,struct ttfinfo *info) { int i,j; int lastwidth = info->emsize, lsb; @@ -3936,7 +3943,7 @@ static void readttfwidths(FILE *ttf,struct ttfinfo *info) { LogError( _("Invalid ttf hmtx table (or hhea), numOfLongMetrics is 0\n") ); info->bad_metrics = true; } - + for ( j=i; j<info->glyph_cnt; ++j ) { if ( (sc = info->chars[j])!=NULL ) { /* In a ttc file we may skip some */ sc->width = lastwidth; @@ -4701,7 +4708,7 @@ return; } else if ( format==2 ) { int max_sub_head_key = 0, cnt, max_pos= -1; struct subhead *subheads; - + for ( i=0; i<256; ++i ) { table[i] = getushort(ttf)/8; /* Sub-header keys */ if ( table[i]>max_sub_head_key ) { @@ -5703,7 +5710,7 @@ static SplineFont *SFFillFromTTF(struct ttfinfo *info) { SplineChar *sc; struct ttf_table *last[2], *tab, *next; - + sf = SplineFontEmpty(); sf->display_size = -default_fv_font_size; #ifdef LUA_FF_LIB @@ -5861,7 +5868,7 @@ static SplineFont *SFFillFromTTF(struct ttfinfo *info) { sf->layers = info->layers; sf->layer_cnt = info->layer_cnt; } - + for ( i=0; i<info->glyph_cnt; ++i ) if ( info->chars[i]!=NULL ) { SCOrderAP(info->chars[i]); @@ -5982,12 +5989,12 @@ return( 0 ); return( true ); } -/* I am not sure what happens to the ttinfo struct's members. +/* I am not sure what happens to the ttinfo struct's members. perhaps some need free()-ing */ -void THPatchSplineChar (SplineChar *sc) -{ +void THPatchSplineChar (SplineChar *sc) +{ DBounds bb; if (sc->layers!=NULL && sc->layers[ly_fore].splines != NULL) { if (sc->xmax==0 && sc->ymax==0 && sc->xmin==0 && sc->ymin==0) { @@ -6006,7 +6013,7 @@ void THPatchSplineChar (SplineChar *sc) sc->layers[ly_fore].refs = NULL; } } - + static SplineFont *SFFillFromTTFInfo(struct ttfinfo *info) { SplineFont *sf ; 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 97974e3baf5..85114e1213d 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsettfatt.c @@ -447,7 +447,7 @@ static void addPairPos(struct ttfinfo *info, int glyph1, int glyph2, uint32 base,FILE *ttf) { (void)ttf; /* for -Wall */ (void)l; /* for -Wall */ - (void)base; /* for -Wall */ + (void)base; /* for -Wall */ if ( glyph1<info->glyph_cnt && glyph2<info->glyph_cnt ) { PST *pos = chunkalloc(sizeof(PST)); pos->type = pst_pair; @@ -1727,7 +1727,7 @@ return; } static void gposContextSubTable(FILE *ttf, int stoffset, - struct ttfinfo *info, struct lookup *l, struct lookup_subtable *subtable, + struct ttfinfo *info, struct lookup *l, struct lookup_subtable *subtable, struct lookup *alllooks) { switch( getushort(ttf)) { case 1: @@ -1743,7 +1743,7 @@ static void gposContextSubTable(FILE *ttf, int stoffset, } static void gposChainingSubTable(FILE *ttf, int stoffset, - struct ttfinfo *info, struct lookup *l, struct lookup_subtable *subtable, + struct ttfinfo *info, struct lookup *l, struct lookup_subtable *subtable, struct lookup *alllooks) { switch( getushort(ttf)) { case 1: @@ -2570,10 +2570,10 @@ static void gposExtensionSubTable(FILE *ttf, int stoffset, switch ( lu_type ) { case 1: gposSimplePos(ttf,st,info,l,subtable); - break; + break; case 2: gposKernSubTable(ttf,st,info,l,subtable); - break; + break; case 3: gposCursiveSubTable(ttf,st,info,l,subtable); break; @@ -2657,10 +2657,10 @@ static void gposLookupSwitch(FILE *ttf, int st, switch ( l->type | 0x100 ) { case gpos_single: gposSimplePos(ttf,st,info,l,subtable); - break; + break; case gpos_pair: gposKernSubTable(ttf,st,info,l,subtable); - break; + break; case gpos_cursive: gposCursiveSubTable(ttf,st,info,l,subtable); break; @@ -2838,17 +2838,24 @@ void readttfgdef(FILE *ttf,struct ttfinfo *info) { int coverage, cnt, i,j, format; uint16 *glyphs, *lc_offsets, *offsets; uint32 caret_base; + uint32 version; PST *pst; SplineChar *sc; fseek(ttf,info->gdef_start,SEEK_SET); - if ( getlong(ttf)!=0x00010000 ) -return; + + version = getlong(ttf) ; + if (version != 0x00010000 && version != 0x00010002) + return; + info->g_bounds = info->gdef_start + info->gdef_length; gclass = getushort(ttf); /* attach list = */ getushort(ttf); lclo = getushort(ttf); /* ligature caret list */ - mac = getushort(ttf); /* mark attach class */ + mac = getushort(ttf); /* mark attach class */ + + if (version == 0x00010002) + getushort(ttf); /* class defs */ if ( gclass!=0 ) { uint16 *gclasses = getClassDefTable(ttf,info->gdef_start+gclass, info); @@ -3614,7 +3621,7 @@ void readttfbase(FILE *ttf,struct ttfinfo *info) { struct Base *curBase; struct basescript *curScript, *last; struct baselangextent *cur, *lastLang; - + if ( info->base_start==0 ) return; fseek(ttf,info->base_start,SEEK_SET); 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 edb726e0657..ccee275e015 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/splinefont.h @@ -771,7 +771,7 @@ typedef struct bdfprops { typedef struct bdffont { struct splinefont *sf; - int glyphcnt, glyphmax; /* used & allocated sizes of glyphs array */ + int glyphcnt, glyphmax,glyphmin; /* used & allocated sizes of glyphs array */ BDFChar **glyphs; /* an array of charcnt entries */ int16 pixelsize; int16 ascent, descent; @@ -1484,7 +1484,7 @@ typedef struct splinefont { struct splinefont *next; int ascent, descent; int uniqueid; /* Not copied when reading in!!!! */ - int glyphcnt, glyphmax; /* allocated size of glyphs array */ + int glyphcnt, glyphmax,glyphmin; /* allocated size of glyphs array */ SplineChar **glyphs; unsigned int changed: 1; unsigned int changed_since_autosave: 1; diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottf.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottf.c index 89a0da5860b..3a1f02c273e 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottf.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/tottf.c @@ -480,6 +480,7 @@ return; sf->glyphs = gcalloc(max,sizeof(SplineChar *)); sf->glyphcnt = sf->glyphmax = max; + sf->glyphmin = 0; for ( k=0; k<sf->subfontcnt; ++k ) for ( i=0; i<sf->subfonts[k]->glyphcnt; ++i ) if ( sf->subfonts[k]->glyphs[i]!=NULL ) sf->glyphs[i] = sf->subfonts[k]->glyphs[i]; @@ -1896,7 +1897,7 @@ static int dumpcff(struct alltabs *at,SplineFont *sf,enum fontformat format, SFDummyUpCIDs(&at->gi,sf); /* life is easier if we ignore the seperate fonts of a cid keyed fonts and treat it as flat */ ret = dumpcidglyphs(sf,at); free(sf->glyphs); sf->glyphs = NULL; - sf->glyphcnt = sf->glyphmax = 0; + sf->glyphcnt = sf->glyphmax = sf->glyphmin = 0; } free( at->gi.bygid ); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c index f2791367b61..3f2ce922bf7 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c @@ -1,5 +1,5 @@ /* luafflib.c - + Copyright 2007-2010 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. @@ -49,7 +49,7 @@ extern int readbinfile(FILE * f, unsigned char **b, int *s); #define FONT_GLYPHS_METATABLE "fontloader.splinefont.glyphs" #define FONT_GLYPH_METATABLE "fontloader.splinefont.glyph" -#define LUA_OTF_VERSION "0.3" +#define LUA_OTF_VERSION "0.4" static char *possub_type_enum[] = { "null", "position", "pair", "substitution", @@ -154,7 +154,7 @@ void handle_glyphvariants(lua_State * L, struct glyphvariants *vars); void handle_mathkern(lua_State * L, struct mathkern *mk); int handle_altuni(lua_State * L, struct altuni *au); -int is_userdata(lua_State *L, int b, char *utype) +int is_userdata(lua_State *L, int b, char *utype) { if (lua_type(L,b) == LUA_TUSERDATA) { lua_getmetatable(L, b); @@ -162,7 +162,7 @@ int is_userdata(lua_State *L, int b, char *utype) if (lua_compare(L, -2, -1, LUA_OPEQ)) { lua_pop(L,2); return 1; - } + } lua_pop(L,2); } return 0; @@ -287,7 +287,7 @@ static int ff_close(lua_State * L) /*fputs("ff_close called",stderr); */ sf = check_isfont(L, 1); if (*sf != NULL) { - if ((*sf)->fv) { // condition might be improved + if ((*sf)->fv) { /* condition might be improved */ FontViewClose((*sf)->fv); } else { EncMapFree((*sf)->map); @@ -561,7 +561,7 @@ void do_handle_lookup_subtable(lua_State * L, struct lookup_subtable *subtable) /* 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_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); @@ -704,6 +704,8 @@ void 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 */ + + int handle_altuni(lua_State * L, struct altuni *au) { struct altuni *next = au; @@ -711,16 +713,18 @@ int handle_altuni(lua_State * L, struct altuni *au) int k = 1; lua_checkstack(L, 3); while (next != NULL) { - if (next->unienc<0x10FFF) { - lua_newtable(L); - dump_intfield(L, "unicode", next->unienc); - i++; - if (next->vs != -1) - dump_intfield(L, "variant", next->vs); - /* dump_intfield(L, "fid", next->fid); */ - lua_rawseti(L, -2, k++); - } - next = next->next; + if (next->unienc<0x10FFFF) { + lua_newtable(L); + dump_intfield(L, "unicode", next->unienc); + i++; + if (next->vs != -1) + dump_intfield(L, "variant", next->vs); + /* dump_intfield(L, "fid", next->fid); */ + lua_rawseti(L, -2, k++); + } else { + printf("ignoring variant %i %i\n",next->unienc,next->vs); + } + next = next->next; } return i; } @@ -1001,7 +1005,9 @@ void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics) lua_pushnumber(L, glyph->ymax); lua_rawset(L, -3); lua_setfield(L, -2, "boundingbox"); - /*dump_intfield(L,"orig_pos", glyph->orig_pos); */ + 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) @@ -1029,23 +1035,23 @@ void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvmetrics) 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,"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,"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,"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; @@ -1987,10 +1993,17 @@ void handle_splinefont(lua_State * L, struct splinefont *sf) dump_intfield(L, "ascent", sf->ascent); dump_intfield(L, "descent", sf->descent); if (sf->uniqueid!=0) { - dump_intfield(L, "uniqueid", sf->uniqueid); + dump_intfield(L, "uniqueid", sf->uniqueid); + } + + if (sf->glyphcnt > 0) { + dump_intfield(L, "glyphcnt", sf->glyphmax - sf->glyphmin + 1); + } else { + dump_intfield(L, "glyphcnt", 0); } - dump_intfield(L, "glyphcnt", sf->glyphcnt); - dump_intfield(L, "glyphmax", sf->glyphmax); + + dump_intfield(L, "glyphmax", sf->glyphmax - 1); + dump_intfield(L, "glyphmin", sf->glyphmin); dump_intfield(L, "units_per_em", sf->units_per_em); if (sf->possub != NULL) { @@ -2011,7 +2024,7 @@ void handle_splinefont(lua_State * L, struct splinefont *sf) } if (fix_notdef) { - /* some code to ensure that the .notdef ends up in slot 0 + /* 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]) { @@ -2310,7 +2323,7 @@ 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... */ + /* 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);*/ @@ -2320,11 +2333,11 @@ 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); - lua_setfield(L, -2, "names"); - } + if (sf->names != NULL) { + lua_newtable(L); + handle_ttflangname(L, sf->names); + lua_setfield(L, -2, "names"); + } } typedef enum { @@ -2344,6 +2357,7 @@ typedef enum { FK_uniqueid, FK_glyphcnt, FK_glyphmax, + FK_glyphmin, FK_units_per_em, FK_lookups, FK_glyphs, @@ -2418,6 +2432,7 @@ const char *font_keys[] = { "uniqueid", "glyphcnt", "glyphmax", + "glyphmin", "units_per_em", "lookups", "glyphs", @@ -2500,6 +2515,7 @@ typedef enum { GK_vert_variants, GK_horiz_variants, GK_mathkern, + GK_orig_pos, } font_glyph_key_values; const char *font_glyph_keys[] = { @@ -2526,6 +2542,7 @@ const char *font_glyph_keys[] = { "vert_variants", "horiz_variants", "mathkern", + "orig_pos", NULL }; @@ -2573,7 +2590,8 @@ static int ff_glyphs_index(lua_State * L) lua_pop(L, 1); gid = luaL_checkinteger(L, 2); - if (gid < 0 || gid >= sf->glyphmax) { + /* if (gid < sf->glyphmin || gid >= sf->glyphmax) {*/ + if (gid < sf->glyphmin || gid > sf->glyphmax) { return luaL_error(L, "fontloader.glyphs.__index: index is invalid\n"); } /* This after-the-fact type discovery is not brilliant, @@ -2583,7 +2601,7 @@ static int ff_glyphs_index(lua_State * L) strmatch(sf->origname + strlen(sf->origname) - 4, ".pfb") == 0)) { fix_notdef = 1; } - /* some code to ensure that the .notdef ends up in slot 0 + /* some code to ensure that the .notdef ends up in slot 0 (this will actually be enforced by the CFF writer) */ if (fix_notdef) { l = notdef_loc(sf); @@ -2786,6 +2804,13 @@ static int ff_glyph_index(lua_State * L) lua_pushnil(L); } break; + case GK_orig_pos: + if (glyph->orig_pos>=0) { + lua_pushnumber(L, glyph->orig_pos); + } else { + lua_pushnil(L); + } + break; default: lua_pushnil(L); } @@ -2804,10 +2829,12 @@ static int ff_index(lua_State * L) "fontloader.__index: expected a (sub)font userdata object\n"); } sf = *((SplineFont **)lua_touserdata(L, 1)); - + if (sf == NULL) { - return luaL_error(L, - "fontloader.__index: font is nonexistent or freed already\n"); + /* return luaL_error(L, */ + /* "fontloader.__index: font is nonexistent or freed already\n");*/ + lua_pushnil(L); + return 1; } if (!lua_isstring(L, 2)) { /* 1 == 'font' */ return luaL_error(L, @@ -2858,10 +2885,17 @@ static int ff_index(lua_State * L) lua_pushnumber(L, sf->uniqueid); break; case FK_glyphcnt: - lua_pushnumber(L, sf->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); + 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); |