Merge branch 'stbtt_const_chardata' of https://github.com/cdwfs/stb into working

This commit is contained in:
Sean Barrett 2017-03-03 09:35:11 -08:00
commit b280541e6a

View File

@ -50,6 +50,7 @@
// Higor Euripedes // Higor Euripedes
// Thomas Fields // Thomas Fields
// Derek Vinyard // Derek Vinyard
// Cort Stratton
// //
// VERSION HISTORY // VERSION HISTORY
// //
@ -492,7 +493,7 @@ typedef struct
float x1,y1,s1,t1; // bottom-right float x1,y1,s1,t1; // bottom-right
} stbtt_aligned_quad; } stbtt_aligned_quad;
STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above
int char_index, // character to display int char_index, // character to display
float *xpos, float *ypos, // pointers to current position in screen pixel space float *xpos, float *ypos, // pointers to current position in screen pixel space
stbtt_aligned_quad *q, // output: quad to draw stbtt_aligned_quad *q, // output: quad to draw
@ -592,7 +593,7 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
// To use with PackFontRangesGather etc., you must set it before calls // To use with PackFontRangesGather etc., you must set it before calls
// call to PackFontRangesGatherRects. // call to PackFontRangesGatherRects.
STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
int char_index, // character to display int char_index, // character to display
float *xpos, float *ypos, // pointers to current position in screen pixel space float *xpos, float *ypos, // pointers to current position in screen pixel space
stbtt_aligned_quad *q, // output: quad to draw stbtt_aligned_quad *q, // output: quad to draw
@ -3285,11 +3286,11 @@ static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // fo
return bottom_y; return bottom_y;
} }
STBTT_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) STBTT_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)
{ {
float d3d_bias = opengl_fillrule ? 0 : -0.5f; float d3d_bias = opengl_fillrule ? 0 : -0.5f;
float ipw = 1.0f / pw, iph = 1.0f / ph; float ipw = 1.0f / pw, iph = 1.0f / ph;
stbtt_bakedchar *b = chardata + char_index; const stbtt_bakedchar *b = chardata + char_index;
int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f);
int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);
@ -3733,10 +3734,10 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontda
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
} }
STBTT_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) STBTT_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)
{ {
float ipw = 1.0f / pw, iph = 1.0f / ph; float ipw = 1.0f / pw, iph = 1.0f / ph;
stbtt_packedchar *b = chardata + char_index; const stbtt_packedchar *b = chardata + char_index;
if (align_to_integer) { if (align_to_integer) {
float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f);