fix use of stbrp_coord if no stb_rect_pack;
Before adoption: this commit came in with the history the project adopted, so no landing records it.
fix a few assert()s that weren't STBTT_asserts(); fix missing cast for C++ fix typo in C++ test compilation that prevented it from trying to compile stb_truetype
authored by Sean Barrett · committed by Sean Barrett · parent 34eec7c · Browse files · 3 files·+15 added−8 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+15 added−8 removed
- tests:+6 added−2 removed
- other:+9 added−6 removed
Provenance
- Commit
2643925- Tree
ffda04a- Author
Sean Barrett <sean2@nothings.org>- Committer
Sean Barrett <sean2@nothings.org>- Parent
34eec7c
3 files changed+15 added−8 removed
modified:tests/stretch_test.c+4 added
1+// check that stb_truetype compiles with no stb_rect_pack.h2+#define STB_TRUETYPE_IMPLEMENTATION3+#include "stb_truetype.h"4+5 #include "stretchy_buffer.h"6 #include <assert.h>7 8 int main(int arg, char **argv)20 unmodified linesmodified:tests/test_cpp_compilation.cpp+2 added-2 removed
1-#define STB_TRUETYPE_IMPLEMENTATIOn1+#define STB_TRUETYPE_IMPLEMENTATION2 #define STB_PERLIN_IMPLEMENTATION3 #define STB_IMAGE_WRITE_IMPLEMENTATION4 #define STB_DXT_IMPLEMENATION5 #define STB_C_LEXER_IMPLEMENTATIOn1 unmodified line7 #define STB_IMAGE_IMPLEMENTATION8 #define STB_HERRINGBONE_WANG_TILE_IMPLEMENTATION9 #define STB_RECT_PACK_IMPLEMENTATION10 11+#include "stb_rect_pack.h"12 #include "stb_truetype.h"13 #include "stb_image_write.h"14 #include "stb_perlin.h"15 #include "stb_dxt.h"16 #include "stb_c_lexer.h"17 #include "stb_divide.h"18 #include "stb_image.h"19 #include "stb_herringbone_wang_tile.h"19-#include "stb_rect_pack.h"20 21 #define STBTE_DRAW_RECT(x0,y0,x1,y1,color) do ; while(0)22 #define STBTE_DRAW_TILE(x,y,id,highlight,data) do ; while(0)23 #define STB_TILEMAP_EDITOR_IMPLEMENTATION1 unmodified linemodified:stb_truetype.h+9 added-6 removed
2060 unmodified lines2061 #else2062 #define STBTT__NOTUSED(v) (void)sizeof(v)2063 #endif2064 2065+typedef int stbrp_coord;2066+2067 ////////////////////////////////////////////////////////////////////////////////////2068 // //2069 // //2070 // COMPILER WARNING ?!?!? //16 unmodified lines2087 } stbrp_node;2088 2089 typedef struct2090 {2091+ stbrp_coord x,y;2089- int id,w,h,x,y,was_packed;2092+ int id,w,h,was_packed;2093 } stbrp_rect;2094 2095 static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)2096 {72 unmodified lines2169 }2170 2171 void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)2172 {2170- assert(h_oversample <= STBTT_MAX_OVERSAMPLE);2171- assert(v_oversample <= STBTT_MAX_OVERSAMPLE);2173+ STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);2174+ STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);2175 if (h_oversample <= STBTT_MAX_OVERSAMPLE)2176 spc->h_oversample = h_oversample;2177 if (v_oversample <= STBTT_MAX_OVERSAMPLE)2178 spc->v_oversample = v_oversample;45 unmodified lines2224 break;2225 }2226 2227 for (; i < w; ++i) {2225- assert(pixels[i] == 0);2228+ STBTT_assert(pixels[i] == 0);2229 total -= buffer[i & STBTT__OVER_MASK];2230 pixels[i] = (unsigned char) (total / kernel_width);2231 }2232 45 unmodified lines2278 break;2279 }2280 2281 for (; i < h; ++i) {2279- assert(pixels[i*stride_in_bytes] == 0);2282+ STBTT_assert(pixels[i*stride_in_bytes] == 0);2283 total -= buffer[i & STBTT__OVER_MASK];2284 pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);2285 }2286 35 unmodified lines2322 n = 0;2323 for (i=0; i < num_ranges; ++i)2324 n += ranges[i].num_chars_in_range;2325 2323- rects = STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);2326+ rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);2327 if (rects == NULL)2328 return 0;2329 2330 stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index));281 unmodified lines