| @@ -717,6 +717,10 @@ struct stbtt_fontinfo · 716 unmodified lines |
| 717 | int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf | 717 | int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf |
| 718 | int index_map; // a cmap mapping for our chosen character encoding | 718 | int index_map; // a cmap mapping for our chosen character encoding |
| 719 | int indexToLocFormat; // format needed to map from glyph index to glyph | 719 | int indexToLocFormat; // format needed to map from glyph index to glyph |
| | 720 | int underlinePosition; |
| | 721 | int underlineThickness; |
| | 722 | char family[128]; |
| | 723 | char subfamily[128]; |
| 720 | | 724 | |
| 721 | stbtt__buf cff; // cff font data | 725 | stbtt__buf cff; // cff font data |
| 722 | stbtt__buf charstrings; // the charstring index | 726 | stbtt__buf charstrings; // the charstring index |
| @@ -1378,7 +1382,9 @@ static int stbtt__get_svg(stbtt_fontinfo *info) · 655 unmodified lines |
| 1378 | static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) | 1382 | static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) |
| 1379 | { | 1383 | { |
| 1380 | stbtt_uint32 cmap, t; | 1384 | stbtt_uint32 cmap, t; |
| 1381 | stbtt_int32 i,numTables; | 1385 | stbtt_int32 i, numTables; |
| | 1386 | |
| | 1387 | memset(info, 0, sizeof(*info)); |
| 1382 | | 1388 | |
| 1383 | info->data = data; | 1389 | info->data = data; |
| 1384 | info->fontstart = fontstart; | 1390 | info->fontstart = fontstart; |
| @@ -1456,6 +1462,43 @@ static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, in · 71 unmodified lines |
| 1456 | | 1462 | |
| 1457 | info->svg = -1; | 1463 | info->svg = -1; |
| 1458 | | 1464 | |
| | 1465 | t = stbtt__find_table(data, fontstart, "post"); |
| | 1466 | if (t) { |
| | 1467 | info->underlinePosition = ttSHORT(data+t+8); |
| | 1468 | info->underlineThickness = ttUSHORT(data+t+10); |
| | 1469 | } |
| | 1470 | |
| | 1471 | t = stbtt__find_table(data, fontstart, "name"); |
| | 1472 | if (t) { |
| | 1473 | stbtt_int32 i, platform, name, count, stringOffset, length; |
| | 1474 | stbtt_uint8 *fc = data; |
| | 1475 | stbtt_uint32 offset = fontstart; |
| | 1476 | stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); |
| | 1477 | char *o, tmp[256]; |
| | 1478 | |
| | 1479 | count = ttUSHORT(fc+nm+2); |
| | 1480 | stringOffset = nm + ttUSHORT(fc+nm+4); |
| | 1481 | for (i=0; i < count; ++i) { |
| | 1482 | stbtt_uint32 loc = nm + 6 + 12 * i; |
| | 1483 | platform = ttUSHORT(fc+loc+0); |
| | 1484 | if (platform != 0 && platform != 1) |
| | 1485 | continue; |
| | 1486 | name = ttUSHORT(fc+loc+6); |
| | 1487 | if (name != 1 && name != 2) /* FIXME use 16 and 17? */ |
| | 1488 | continue; |
| | 1489 | length = ttUSHORT(fc+loc+8); |
| | 1490 | o = (char*)fc+stringOffset+ttUSHORT(fc+loc+10); |
| | 1491 | if (platform == 0) { |
| | 1492 | length = utf16to8((uchar*)tmp, sizeof(tmp), (uchar*)o, length); |
| | 1493 | o = tmp; |
| | 1494 | } |
| | 1495 | if (name == 1) |
| | 1496 | snprint(info->family, sizeof(info->family), "%.*s", length, o); |
| | 1497 | else if (name == 2) |
| | 1498 | snprint(info->subfamily, sizeof(info->subfamily), "%.*s", length, o); |
| | 1499 | } |
| | 1500 | } |
| | 1501 | |
| 1459 | // find a cmap encoding table we understand *now* to avoid searching | 1502 | // find a cmap encoding table we understand *now* to avoid searching |
| 1460 | // later. (todo: could make this installable) | 1503 | // later. (todo: could make this installable) |
| 1461 | // the same regardless of glyph. | 1504 | // the same regardless of glyph. |