Skip to content
Myr

stbtt: chardata can be const in GetBakedQuad() and GetPackedQuad()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Cort · committed by Cort · parent 59a5a15 · Browse files · 1 file+7 added−6 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+7 added−6 removed

  • other:+7 added−6 removed

1 file+7 added−6 removed

modified:stb_truetype.h+7 added-6 removed
48 unmodified lines
49// Giumo X. Clanjor50// Higor Euripedes51// Thomas Fields52// Derek Vinyard53// Cort Stratton54//55// VERSION HISTORY56//57// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts, num-fonts-in-TTC function
436 unmodified lines
494 float x0,y0,s0,t0; // top-left495 float x1,y1,s1,t1; // bottom-right496} stbtt_aligned_quad;497497STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above498STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above499 int char_index, // character to display500 float *xpos, float *ypos, // pointers to current position in screen pixel space501 stbtt_aligned_quad *q, // output: quad to draw502 int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier
91 unmodified lines
594//595// To use with PackFontRangesGather etc., you must set it before calls596// call to PackFontRangesGatherRects.597597STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above598STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above599 int char_index, // character to display600 float *xpos, float *ypos, // pointers to current position in screen pixel space601 stbtt_aligned_quad *q, // output: quad to draw602 int align_to_integer);
2684 unmodified lines
3287 }3288 return bottom_y;3289}32903290STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)3291STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)3292{3293 float d3d_bias = opengl_fillrule ? 0 : -0.5f;3294 float ipw = 1.0f / pw, iph = 1.0f / ph;3294 stbtt_bakedchar *b = chardata + char_index;3295 const stbtt_bakedchar *b = chardata + char_index;3296 int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f);3297 int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);32983299 q->x0 = round_x + d3d_bias;
435 unmodified lines
3735 range.font_size = font_size;3736 return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);3737}37383738STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)3739STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)3740{3741 float ipw = 1.0f / pw, iph = 1.0f / ph;3741 stbtt_packedchar *b = chardata + char_index;3742 const stbtt_packedchar *b = chardata + char_index;37433744 if (align_to_integer) {3745 float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f);3746 float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f);
273 unmodified lines