Merge branch 'working'
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 50dc480, 8ee3bea · Browse files · 1 file·+54 added−0 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+54 added−0 removed
- other:+54 added−0 removed
Provenance
- Commit
17c3018- Tree
f7bf52c- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent 1
50dc480- Parent 2
8ee3bea
1 file changed+54 added−0 removed
modified:stb_truetype.h+54 added
786 unmodified lines787 STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);788 STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);789 // as above, but takes one or more glyph indices for greater efficiency790 791+typedef struct stbtt_kerningentry792+{793+ int glyph1; // use stbtt_FindGlyphIndex794+ int glyph2;795+ int advance;796+} stbtt_kerningentry;797 798+STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info);799+STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length);800+// Retrieves a complete list of all of the kerning pairs provided by the font801+// stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write.802+// The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1)803+804 //////////////////////////////////////////////////////////////////////////////805 //806 // GLYPH SHAPES (you probably don't need these, but they have to go before807 // the bitmaps for C declaration-order reasons)1491 unmodified lines2299 if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));2300 }2301 }2302 2303+STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info)2304+{2305+ stbtt_uint8 *data = info->data + info->kern;2306+2307+ // we only look at the first table. it must be 'horizontal' and format 0.2308+ if (!info->kern)2309+ return 0;2310+ if (ttUSHORT(data+2) < 1) // number of tables, need at least 12311+ return 0;2312+ if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format2313+ return 0;2314+2315+ return ttUSHORT(data+10);2316+}2317+2318+STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length)2319+{2320+ stbtt_uint8 *data = info->data + info->kern;2321+ int k, length;2322+2323+ // we only look at the first table. it must be 'horizontal' and format 0.2324+ if (!info->kern)2325+ return 0;2326+ if (ttUSHORT(data+2) < 1) // number of tables, need at least 12327+ return 0;2328+ if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format2329+ return 0;2330+2331+ length = ttUSHORT(data+10);2332+ if (table_length < length)2333+ length = table_length;2334+2335+ for (k = 0; k < length; k++)2336+ {2337+ table[k].glyph1 = ttUSHORT(data+18+(k*6));2338+ table[k].glyph2 = ttUSHORT(data+20+(k*6));2339+ table[k].advance = ttSHORT(data+22+(k*6));2340+ }2341+2342+ return length;2343+}2344+2345 static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)2346 {2347 stbtt_uint8 *data = info->data + info->kern;2348 stbtt_uint32 needle, straw;2653 unmodified lines