Merge branch 'master' of https://github.com/BSVino/stb into 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 d79349d, f298fb8 · 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
8ee3bea- Tree
0cc5032- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent 1
d79349d- Parent 2
f298fb8
1 file changed+54 added−0 removed
modified:stb_truetype.h+54 added
785 unmodified lines786 STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);787 STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);788 // as above, but takes one or more glyph indices for greater efficiency789 790+typedef struct stbtt_kerningentry791+{792+ int glyph1; // use stbtt_FindGlyphIndex793+ int glyph2;794+ int advance;795+} stbtt_kerningentry;796 797+STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info);798+STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length);799+// Retrieves a complete list of all of the kerning pairs provided by the font800+// stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write.801+// The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1)802+803 //////////////////////////////////////////////////////////////////////////////804 //805 // GLYPH SHAPES (you probably don't need these, but they have to go before806 // the bitmaps for C declaration-order reasons)1491 unmodified lines2298 if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));2299 }2300 }2301 2302+STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info)2303+{2304+ stbtt_uint8 *data = info->data + info->kern;2305+2306+ // we only look at the first table. it must be 'horizontal' and format 0.2307+ if (!info->kern)2308+ return 0;2309+ if (ttUSHORT(data+2) < 1) // number of tables, need at least 12310+ return 0;2311+ if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format2312+ return 0;2313+2314+ return ttUSHORT(data+10);2315+}2316+2317+STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length)2318+{2319+ stbtt_uint8 *data = info->data + info->kern;2320+ int k, length;2321+2322+ // we only look at the first table. it must be 'horizontal' and format 0.2323+ if (!info->kern)2324+ return 0;2325+ if (ttUSHORT(data+2) < 1) // number of tables, need at least 12326+ return 0;2327+ if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format2328+ return 0;2329+2330+ length = ttUSHORT(data+10);2331+ if (table_length < length)2332+ length = table_length;2333+2334+ for (k = 0; k < length; k++)2335+ {2336+ table[k].glyph1 = ttUSHORT(data+18+(k*6));2337+ table[k].glyph2 = ttUSHORT(data+20+(k*6));2338+ table[k].advance = ttSHORT(data+22+(k*6));2339+ }2340+2341+ return length;2342+}2343+2344 static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)2345 {2346 stbtt_uint8 *data = info->data + info->kern;2347 stbtt_uint32 needle, straw;2653 unmodified lines