mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-06 06:09:17 -05:00
Updated to latest version of stb libs
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// stb_truetype.h - v1.08 - public domain
|
||||
// stb_truetype.h - v1.09 - public domain
|
||||
// authored from 2009-2015 by Sean Barrett / RAD Game Tools
|
||||
//
|
||||
// This library processes TrueType files:
|
||||
@ -42,12 +42,15 @@
|
||||
// Sergey Popov
|
||||
// Giumo X. Clanjor
|
||||
// Higor Euripedes
|
||||
// Thomas Fields
|
||||
// Derek Vinyard
|
||||
//
|
||||
// Misc other:
|
||||
// Ryan Gordon
|
||||
//
|
||||
// VERSION HISTORY
|
||||
//
|
||||
// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly
|
||||
// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
|
||||
// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
|
||||
// variant PackFontRanges to pack and render in separate phases;
|
||||
@ -1556,7 +1559,7 @@ STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
|
||||
|
||||
STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
||||
{
|
||||
int x0,y0,x1,y1;
|
||||
int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning
|
||||
if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
|
||||
// e.g. space character
|
||||
if (ix0) *ix0 = 0;
|
||||
@ -1672,6 +1675,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i
|
||||
{
|
||||
stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
|
||||
float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
|
||||
STBTT_assert(z != NULL);
|
||||
if (!z) return z;
|
||||
|
||||
// round dx down to avoid overshooting
|
||||
@ -1693,6 +1697,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i
|
||||
{
|
||||
stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
|
||||
float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
|
||||
STBTT_assert(z != NULL);
|
||||
//STBTT_assert(e->y0 <= start_point);
|
||||
if (!z) return z;
|
||||
z->fdx = dxdy;
|
||||
@ -1817,21 +1822,23 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
||||
while (e->y0 <= scan_y) {
|
||||
if (e->y1 > scan_y) {
|
||||
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata);
|
||||
// find insertion point
|
||||
if (active == NULL)
|
||||
active = z;
|
||||
else if (z->x < active->x) {
|
||||
// insert at front
|
||||
z->next = active;
|
||||
active = z;
|
||||
} else {
|
||||
// find thing to insert AFTER
|
||||
stbtt__active_edge *p = active;
|
||||
while (p->next && p->next->x < z->x)
|
||||
p = p->next;
|
||||
// at this point, p->next->x is NOT < z->x
|
||||
z->next = p->next;
|
||||
p->next = z;
|
||||
if (z != NULL) {
|
||||
// find insertion point
|
||||
if (active == NULL)
|
||||
active = z;
|
||||
else if (z->x < active->x) {
|
||||
// insert at front
|
||||
z->next = active;
|
||||
active = z;
|
||||
} else {
|
||||
// find thing to insert AFTER
|
||||
stbtt__active_edge *p = active;
|
||||
while (p->next && p->next->x < z->x)
|
||||
p = p->next;
|
||||
// at this point, p->next->x is NOT < z->x
|
||||
z->next = p->next;
|
||||
p->next = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
++e;
|
||||
@ -2101,10 +2108,12 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
||||
while (e->y0 <= scan_y_bottom) {
|
||||
if (e->y0 != e->y1) {
|
||||
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
|
||||
STBTT_assert(z->ey >= scan_y_top);
|
||||
// insert at front
|
||||
z->next = active;
|
||||
active = z;
|
||||
if (z != NULL) {
|
||||
STBTT_assert(z->ey >= scan_y_top);
|
||||
// insert at front
|
||||
z->next = active;
|
||||
active = z;
|
||||
}
|
||||
}
|
||||
++e;
|
||||
}
|
||||
@ -2513,6 +2522,7 @@ STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // fo
|
||||
float scale;
|
||||
int x,y,bottom_y, i;
|
||||
stbtt_fontinfo f;
|
||||
f.userdata = NULL;
|
||||
if (!stbtt_InitFont(&f, data, offset))
|
||||
return -1;
|
||||
STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
|
||||
@ -2706,6 +2716,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i
|
||||
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
|
||||
int safe_w = w - kernel_width;
|
||||
int j;
|
||||
STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
|
||||
for (j=0; j < h; ++j) {
|
||||
int i;
|
||||
unsigned int total;
|
||||
@ -2767,6 +2778,7 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i
|
||||
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
|
||||
int safe_h = h - kernel_width;
|
||||
int j;
|
||||
STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
|
||||
for (j=0; j < w; ++j) {
|
||||
int i;
|
||||
unsigned int total;
|
||||
@ -2975,6 +2987,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd
|
||||
if (rects == NULL)
|
||||
return 0;
|
||||
|
||||
info.userdata = spc->user_allocator_context;
|
||||
stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index));
|
||||
|
||||
n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
|
||||
@ -3192,6 +3205,7 @@ STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const
|
||||
|
||||
// FULL VERSION HISTORY
|
||||
//
|
||||
// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges
|
||||
// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
|
||||
// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
|
||||
// allow PackFontRanges to pack and render in separate phases;
|
||||
|
||||
Reference in New Issue
Block a user