Skip to content
Myr

Merge branch 'svg' of https://github.com/chris-y/stb into work2

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents d487122, 0a10163 · Browse files · 1 file+52 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+52 added−1 removed

  • other:+52 added−1 removed

1 file+52 added−1 removed

modified:stb_truetype.h+52 added-1 removed
702 unmodified lines
703 int fontstart; // offset of start of font704705 int numGlyphs; // number of glyphs, needed for range checking706707 int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf707 int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf708 int index_map; // a cmap mapping for our chosen character encoding709 int indexToLocFormat; // format needed to map from glyph index to glyph710711 stbtt__buf cff; // cff font data
118 unmodified lines
830831STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);832// frees the data allocated above833834STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg);835STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg);836// fills svg with the font's SVG data.837// returns data size or 0 if SVG not found.838839//////////////////////////////////////////////////////////////////////////////840//841// BITMAP RENDERING842//
572 unmodified lines
1415 info->numGlyphs = ttUSHORT(data+t+4);1416 else1417 info->numGlyphs = 0xffff;14181419 t = stbtt__find_table(data, fontstart, "SVG ");1420 if (t) {1421 stbtt_uint32 offset = ttULONG(data + t + 2);1422 info->svg = t + offset;1423 } else {1424 info->svg = 0;1425 }1426 1427 // find a cmap encoding table we understand *now* to avoid searching1428 // later. (todo: could make this installable)1429 // the same regardless of glyph.1430 numTables = ttUSHORT(data + cmap + 2);
1184 unmodified lines
2615{2616 STBTT_free(v, info->userdata);2617}26182619STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl)2620{2621 stbtt_uint8 *data = info->data;2622 stbtt_uint8 *svg_doc_list = data + info->svg;2623 2624 int numEntries = ttUSHORT(svg_doc_list);2625 stbtt_uint8 *svg_docs = svg_doc_list + 2;26262627 for(int i=0; i<numEntries; i++) {2628 stbtt_uint8 *svg_doc = svg_docs + (12 * i);2629 printf("%lx - %lx - %lx %lx\n", ttUSHORT(svg_doc), ttUSHORT(svg_doc + 2), ttULONG(svg_doc + 4), ttULONG(svg_doc + 8));2630 if((gl >= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2)))2631 return svg_doc;2632 }2633 return 0; 2634}26352636STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg)2637{2638 stbtt_uint8 *data = info->data;2639 stbtt_uint8 *svg_doc;2640 2641 if(info->svg == 0)2642 return 0;2643 2644 if(svg_doc = stbtt_FindSVGDoc(info, gl)) {2645 *svg = (void *)data + info->svg + ttULONG(svg_doc + 4);2646 return ttULONG(svg_doc + 8);2647 } else {2648 return 0;2649 }2650}26512652STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg)2653{2654 return stbtt_GetGlyphSVG(info, stbtt_FindGlyphIndex(info, unicode_codepoint), svg);2655}26562657//////////////////////////////////////////////////////////////////////////////2658//2659// antialiasing software rasterizer2660//
2279 unmodified lines