Skip to content
Myr

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

1 file+54 added−0 removed

modified:stb_truetype.h+54 added
785 unmodified lines
786STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);787STBTT_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 efficiency789790typedef struct stbtt_kerningentry791{792 int glyph1; // use stbtt_FindGlyphIndex793 int glyph2;794 int advance;795} stbtt_kerningentry;796797STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info);798STBTT_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)802803//////////////////////////////////////////////////////////////////////////////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 lines
2298 if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));2299 }2300}23012302STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info)2303{2304 stbtt_uint8 *data = info->data + info->kern;23052306 // 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;23132314 return ttUSHORT(data+10);2315}23162317STBTT_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;23212322 // 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;23292330 length = ttUSHORT(data+10);2331 if (table_length < length)2332 length = table_length;23332334 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 }23402341 return length;2342}23432344static 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