Skip to content
Myr

Merge branch 'master' of https://github.com/rgriege/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 70bd711, a5b663f · Browse files · 1 file+13 added−3 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+13 added−3 removed

  • other:+13 added−3 removed

1 file+13 added−3 removed

modified:stb_truetype.h+13 added-3 removed
44 unmodified lines
45// Hou Qiming Derek Vinyard46// Rob Loach Cort Stratton47// Kenney Phillis Jr. github:oyvindjam48// Brian Costabile github:vassvik49// Ken Voskuil (kaesve)49// Ken Voskuil (kaesve) Ryan Griege50// 51// VERSION HISTORY52//53// 1.21 (2019-02-25) fix warning
3914 unmodified lines
3968// rects array must be big enough to accommodate all characters in the given ranges3969STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)3970{3971 int i,j,k;3972 int missing_glyph_added = 0;39733974 k=0;3975 for (i=0; i < num_ranges; ++i) {3976 float fh = ranges[i].font_size;
3 unmodified lines
3980 for (j=0; j < ranges[i].num_chars; ++j) {3981 int x0,y0,x1,y1;3982 int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];3983 int glyph = stbtt_FindGlyphIndex(info, codepoint);3983 if (glyph == 0 && spc->skip_missing) {3984 if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) {3985 rects[k].w = rects[k].h = 0;3986 } else {3987 stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,3988 scale * spc->h_oversample,
1 unmodified line
3990 0,0,3991 &x0,&y0,&x1,&y1);3992 rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);3993 rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);3994 if (glyph == 0)3995 missing_glyph_added = 1;3996 }3997 ++k;3998 }3999 }
26 unmodified lines
40264027// rects array must be big enough to accommodate all characters in the given ranges4028STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)4029{4027 int i,j,k, return_value = 1;4030 int i,j,k, missing_glyph = -1, return_value = 1;40314032 // save current values4033 int old_h_over = spc->h_oversample;4034 int old_v_over = spc->v_oversample;
56 unmodified lines
4091 bc->xoff = (float) x0 * recip_h + sub_x;4092 bc->yoff = (float) y0 * recip_v + sub_y;4093 bc->xoff2 = (x0 + r->w) * recip_h + sub_x;4094 bc->yoff2 = (y0 + r->h) * recip_v + sub_y;40954096 if (glyph == 0)4097 missing_glyph = j;4098 } else if (spc->skip_missing) {4099 return_value = 0;4100 } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) {4101 ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph];4102 } else {4103 return_value = 0; // if any fail, report failure4104 }4105
783 unmodified lines