- sf->minmem = post.minMemType42;
- sf->maxmem = post.maxMemType42;
- fi->italicangle = post.italicAngle / 65536.0;
- switch (post.format) {
- case 0x00010000:
- sf->nglyphs = 258;
- sf->glyphsbyindex = (glyph *)tt_std_glyphs;
- break;
- case 0x00020000:
- if ((char *)ptr + 2 > (char *)end) return;
- decode_uint16(ptr, &sf->nglyphs);
- ptr = (char *)ptr + 2;
- if ((char *)ptr + 2*sf->nglyphs > (char *)end) return;
- nextras = 0;
- for (sptr = (unsigned char *)ptr + 2*sf->nglyphs;
- sptr < (unsigned char *)end;
- sptr += *sptr+1)
- nextras++;
- extraglyphs = snewn(nextras, glyph);
- i = 0;
- for (sptr = (unsigned char *)ptr + 2*sf->nglyphs;
- sptr < (unsigned char *)end;
- sptr += *sptr+1) {
- memcpy(tmp, sptr + 1, *sptr);
- tmp[*sptr] = 0;
- assert(i < nextras);
- extraglyphs[i++] = glyph_intern(tmp);
+ sf->minmem = post.minMemType42;
+ sf->maxmem = post.maxMemType42;
+ fi->italicangle = post.italicAngle / 65536.0;
+ switch (post.format) {
+ case 0x00010000:
+ if (sf->nglyphs != 258) {
+ err_sfntbadtable(&sf->pos, "post");
+ break;
+ }
+ sf->glyphsbyindex = (glyph *)tt_std_glyphs;
+ break;
+ case 0x00020000:
+ if ((char *)ptr + 2 > (char *)end) {
+ err_sfntbadtable(&sf->pos, "post");
+ break;
+ }
+ ptr = (char *)ptr + 2;
+ if ((char *)ptr + 2*sf->nglyphs > (char *)end) {
+ err_sfntbadtable(&sf->pos, "post");
+ break;
+ }
+ nextras = 0;
+ for (sptr = (unsigned char *)ptr + 2*sf->nglyphs;
+ sptr < (unsigned char *)end;
+ sptr += *sptr+1)
+ nextras++;
+ extraglyphs = snewn(nextras, glyph);
+ i = 0;
+ for (sptr = (unsigned char *)ptr + 2*sf->nglyphs;
+ sptr < (unsigned char *)end;
+ sptr += *sptr+1) {
+ memcpy(tmp, sptr + 1, *sptr);
+ tmp[*sptr] = 0;
+ assert(i < nextras);
+ extraglyphs[i++] = glyph_intern(tmp);
+ }
+ sf->glyphsbyindex = snewn(sf->nglyphs, glyph);
+ for (i = 0; i < sf->nglyphs; i++) {
+ decode_uint16((char *)ptr + 2*i, &g);
+ if (g <= 257)
+ sf->glyphsbyindex[i] = tt_std_glyphs[g];
+ else if (g < 258 + nextras)
+ sf->glyphsbyindex[i] = extraglyphs[g - 258];
+ else {
+ err_sfntbadtable(&sf->pos, "post");
+ sf->glyphsbyindex[i] = genglyph(i);
+ }
+ }
+ sfree(extraglyphs);
+ break;
+ case 0x00030000:
+ break;
+ default:
+ err_sfnttablevers(&sf->pos, "post");
+ break;