Skip to content
Myr

stb_truetype: tweaks to codepoint-missing packing

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 · parent f11f1e8 · Browse files · 1 file+5 added−4 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+5 added−4 removed

  • other:+5 added−4 removed

1 file+5 added−4 removed

modified:stb_truetype.h+5 added-4 removed
641 unmodified lines
642//643// To use with PackFontRangesGather etc., you must set it before calls644// call to PackFontRangesGatherRects.645646STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);647// If skip != 0, this tells stb_truetype to skip any codepoints for which648// there is no corresponding glyph. If skip=0, which is the default, then649// codepoints without a glyph recived the font's "missing character" glyph,650// typically an empty box by convention.650STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);651652STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above653 int char_index, // character to display654 float *xpos, float *ypos, // pointers to current position in screen pixel space
21 unmodified lines
676 int width;677 int height;678 int stride_in_bytes;679 int padding;680 int skip_empty;680 int skip_missing;681 unsigned int h_oversample, v_oversample;682 unsigned char *pixels;683 void *nodes;684};
3120 unmodified lines
3805 spc->padding = padding;3806 spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;3807 spc->h_oversample = 1;3808 spc->v_oversample = 1;3809 spc->skip_missing = 0;38103811 stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);38123813 if (pixels)
19 unmodified lines
3833}38343835STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)3836{3836 spc->skip_empty = skip;3837 spc->skip_missing = skip;3838}38393840#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)3841
147 unmodified lines
3989 for (j=0; j < ranges[i].num_chars; ++j) {3990 int x0,y0,x1,y1;3991 int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];3992 int glyph = stbtt_FindGlyphIndex(info, codepoint);3992 if (glyph == 0 && spc->skip_empty) {3993 if (glyph == 0 && spc->skip_missing) {3994 rects[k].w = rects[k].h = 0;3995 } else {3996 stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,3997 scale * spc->h_oversample,
896 unmodified lines