Skip to content
Myr

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

1 file+54 added−0 removed

modified:stb_truetype.h+54 added
786 unmodified lines
787STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);788STBTT_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 efficiency790791typedef struct stbtt_kerningentry792{793 int glyph1; // use stbtt_FindGlyphIndex794 int glyph2;795 int advance;796} stbtt_kerningentry;797798STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info);799STBTT_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)803804//////////////////////////////////////////////////////////////////////////////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 lines
2299 if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));2300 }2301}23022303STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info)2304{2305 stbtt_uint8 *data = info->data + info->kern;23062307 // 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;23142315 return ttUSHORT(data+10);2316}23172318STBTT_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;23222323 // 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;23302331 length = ttUSHORT(data+10);2332 if (table_length < length)2333 length = table_length;23342335 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 }23412342 return length;2343}23442345static 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