mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Updated STB libraries to latest (drift has been reduced with nothings/stb as most of our changes were merged). Using [DEAR IMGUI] markers when changed.
This commit is contained in:
parent
00c637961b
commit
539f69b950
@ -1,4 +1,10 @@
|
|||||||
// stb_rect_pack.h - v0.11 - public domain - rectangle packing
|
// [DEAR IMGUI]
|
||||||
|
// This is a slightly modified version of stb_rect_pack.h 0.99.
|
||||||
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
|
// - Added STBRP__CDECL
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
|
// stb_rect_pack.h - v0.99 - public domain - rectangle packing
|
||||||
// Sean Barrett 2014
|
// Sean Barrett 2014
|
||||||
//
|
//
|
||||||
// Useful for e.g. packing rectangular textures into an atlas.
|
// Useful for e.g. packing rectangular textures into an atlas.
|
||||||
@ -34,6 +40,7 @@
|
|||||||
//
|
//
|
||||||
// Version history:
|
// Version history:
|
||||||
//
|
//
|
||||||
|
// 0.99 (2019-02-07) warning fixes
|
||||||
// 0.11 (2017-03-03) return packing success/fail result
|
// 0.11 (2017-03-03) return packing success/fail result
|
||||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||||
// 0.09 (2016-08-27) fix compiler warnings
|
// 0.09 (2016-08-27) fix compiler warnings
|
||||||
@ -204,6 +211,7 @@ struct stbrp_context
|
|||||||
#define STBRP_ASSERT assert
|
#define STBRP_ASSERT assert
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define STBRP__NOTUSED(v) (void)(v)
|
#define STBRP__NOTUSED(v) (void)(v)
|
||||||
#define STBRP__CDECL __cdecl
|
#define STBRP__CDECL __cdecl
|
||||||
@ -512,6 +520,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||||
@ -523,6 +532,7 @@ static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
|||||||
return (p->w > q->w) ? -1 : (p->w < q->w);
|
return (p->w > q->w) ? -1 : (p->w < q->w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [DEAR IMGUI] Added STBRP__CDECL
|
||||||
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||||
@ -543,9 +553,6 @@ STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int nu
|
|||||||
// we use the 'was_packed' field internally to allow sorting/unsorting
|
// we use the 'was_packed' field internally to allow sorting/unsorting
|
||||||
for (i=0; i < num_rects; ++i) {
|
for (i=0; i < num_rects; ++i) {
|
||||||
rects[i].was_packed = i;
|
rects[i].was_packed = i;
|
||||||
#ifndef STBRP_LARGE_RECTS
|
|
||||||
STBRP_ASSERT(rects[i].w <= 0xffff && rects[i].h <= 0xffff);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort according to heuristic
|
// sort according to heuristic
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
// [ImGui] this is a slightly modified version of stb_textedit.h 1.12. Those changes would need to be pushed into nothings/stb
|
// [DEAR IMGUI]
|
||||||
// [ImGui] - 2018-06: fixed undo/redo after pasting large amount of text (over 32 kb). Redo will still fail when undo buffers are exhausted, but text won't be corrupted (see nothings/stb issue #620)
|
// This is a slightly modified version of stb_textedit.h 1.13.
|
||||||
// [ImGui] - 2018-06: fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
// Those changes would need to be pushed into nothings/stb:
|
||||||
// [ImGui] - fixed some minor warnings
|
// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321)
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
// stb_textedit.h - v1.12 - public domain - Sean Barrett
|
// stb_textedit.h - v1.13 - public domain - Sean Barrett
|
||||||
// Development of this library was sponsored by RAD Game Tools
|
// Development of this library was sponsored by RAD Game Tools
|
||||||
//
|
//
|
||||||
// This C header file implements the guts of a multi-line text-editing
|
// This C header file implements the guts of a multi-line text-editing
|
||||||
@ -34,6 +35,7 @@
|
|||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
|
// 1.13 (2019-02-07) fix bug in undo size management
|
||||||
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash
|
||||||
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield
|
||||||
// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
|
// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual
|
||||||
@ -692,7 +694,7 @@ static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state)
|
|||||||
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state)
|
||||||
{
|
{
|
||||||
if (STB_TEXT_HAS_SELECTION(state)) {
|
if (STB_TEXT_HAS_SELECTION(state)) {
|
||||||
stb_textedit_delete_selection(str,state); // implicity clamps
|
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -744,7 +746,7 @@ retry:
|
|||||||
state->has_preferred_x = 0;
|
state->has_preferred_x = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stb_textedit_delete_selection(str,state); // implicity clamps
|
stb_textedit_delete_selection(str,state); // implicitly clamps
|
||||||
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
|
if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) {
|
||||||
stb_text_makeundo_insert(state, state->cursor, 1);
|
stb_text_makeundo_insert(state, state->cursor, 1);
|
||||||
++state->cursor;
|
++state->cursor;
|
||||||
@ -1132,6 +1134,7 @@ static void stb_textedit_discard_redo(StbUndoState *state)
|
|||||||
state->undo_rec[i].char_storage += n;
|
state->undo_rec[i].char_storage += n;
|
||||||
}
|
}
|
||||||
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
// now move all the redo records towards the end of the buffer; the first one is at 'redo_point'
|
||||||
|
// {DEAR IMGUI]
|
||||||
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0]));
|
||||||
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
const char* buf_begin = (char*)state->undo_rec; (void)buf_begin;
|
||||||
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// [ImGui] this is a slightly modified version of stb_truetype.h 1.19. Those changes would need to be pushed into nothings/stb
|
// [DEAR IMGUI]
|
||||||
// grep for [ImGui] to find the changes.
|
// This is a slightly modified version of stb_truetype.h 1.20.
|
||||||
|
// Mostly fixing for compiler and static analyzer warnings.
|
||||||
|
// Grep for [DEAR IMGUI] to find the changes.
|
||||||
|
|
||||||
// stb_truetype.h - v1.19 - public domain
|
// stb_truetype.h - v1.20 - public domain
|
||||||
// authored from 2009-2016 by Sean Barrett / RAD Game Tools
|
// authored from 2009-2016 by Sean Barrett / RAD Game Tools
|
||||||
//
|
//
|
||||||
// This library processes TrueType files:
|
// This library processes TrueType files:
|
||||||
@ -52,6 +54,7 @@
|
|||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
|
// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
|
||||||
// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod
|
// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod
|
||||||
// 1.18 (2018-01-29) add missing function
|
// 1.18 (2018-01-29) add missing function
|
||||||
// 1.17 (2017-07-23) make more arguments const; doc fix
|
// 1.17 (2017-07-23) make more arguments const; doc fix
|
||||||
@ -78,7 +81,7 @@
|
|||||||
//
|
//
|
||||||
// USAGE
|
// USAGE
|
||||||
//
|
//
|
||||||
// Include this file in whatever places neeed to refer to it. In ONE C/C++
|
// Include this file in whatever places need to refer to it. In ONE C/C++
|
||||||
// file, write:
|
// file, write:
|
||||||
// #define STB_TRUETYPE_IMPLEMENTATION
|
// #define STB_TRUETYPE_IMPLEMENTATION
|
||||||
// before the #include of this file. This expands out the actual
|
// before the #include of this file. This expands out the actual
|
||||||
@ -250,8 +253,8 @@
|
|||||||
// Documentation & header file 520 LOC \___ 660 LOC documentation
|
// Documentation & header file 520 LOC \___ 660 LOC documentation
|
||||||
// Sample code 140 LOC /
|
// Sample code 140 LOC /
|
||||||
// Truetype parsing 620 LOC ---- 620 LOC TrueType
|
// Truetype parsing 620 LOC ---- 620 LOC TrueType
|
||||||
// Software rasterization 240 LOC \ .
|
// Software rasterization 240 LOC \
|
||||||
// Curve tesselation 120 LOC \__ 550 LOC Bitmap creation
|
// Curve tessellation 120 LOC \__ 550 LOC Bitmap creation
|
||||||
// Bitmap management 100 LOC /
|
// Bitmap management 100 LOC /
|
||||||
// Baked bitmap interface 70 LOC /
|
// Baked bitmap interface 70 LOC /
|
||||||
// Font name matching & access 150 LOC ---- 150
|
// Font name matching & access 150 LOC ---- 150
|
||||||
@ -559,6 +562,8 @@ STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int p
|
|||||||
//
|
//
|
||||||
// It's inefficient; you might want to c&p it and optimize it.
|
// It's inefficient; you might want to c&p it and optimize it.
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap);
|
||||||
|
// Query the font vertical metrics without having to create a font first.
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -644,6 +649,12 @@ 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_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
||||||
|
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
||||||
|
// there is no corresponding glyph. If skip=0, which is the default, then
|
||||||
|
// codepoints without a glyph recived the font's "missing character" glyph,
|
||||||
|
// typically an empty box by convention.
|
||||||
|
|
||||||
STBTT_DEF void stbtt_GetPackedQuad(const 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
|
||||||
@ -672,6 +683,7 @@ struct stbtt_pack_context {
|
|||||||
int height;
|
int height;
|
||||||
int stride_in_bytes;
|
int stride_in_bytes;
|
||||||
int padding;
|
int padding;
|
||||||
|
int skip_missing;
|
||||||
unsigned int h_oversample, v_oversample;
|
unsigned int h_oversample, v_oversample;
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
void *nodes;
|
void *nodes;
|
||||||
@ -697,7 +709,7 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
|
|||||||
// file will only define one font and it always be at offset 0, so it will
|
// file will only define one font and it always be at offset 0, so it will
|
||||||
// return '0' for index 0, and -1 for all other indices.
|
// return '0' for index 0, and -1 for all other indices.
|
||||||
|
|
||||||
// The following structure is defined publically so you can declare one on
|
// The following structure is defined publicly so you can declare one on
|
||||||
// the stack or as a global or etc, but you should treat it as opaque.
|
// the stack or as a global or etc, but you should treat it as opaque.
|
||||||
struct stbtt_fontinfo
|
struct stbtt_fontinfo
|
||||||
{
|
{
|
||||||
@ -736,6 +748,7 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
|
|||||||
// and you want a speed-up, call this function with the character you're
|
// and you want a speed-up, call this function with the character you're
|
||||||
// going to process, then use glyph-based functions instead of the
|
// going to process, then use glyph-based functions instead of the
|
||||||
// codepoint-based functions.
|
// codepoint-based functions.
|
||||||
|
// Returns 0 if the character codepoint is not defined in the font.
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -823,7 +836,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s
|
|||||||
// returns # of vertices and fills *vertices with the pointer to them
|
// returns # of vertices and fills *vertices with the pointer to them
|
||||||
// these are expressed in "unscaled" coordinates
|
// these are expressed in "unscaled" coordinates
|
||||||
//
|
//
|
||||||
// The shape is a series of countours. Each one starts with
|
// The shape is a series of contours. Each one starts with
|
||||||
// a STBTT_moveto, then consists of a series of mixed
|
// a STBTT_moveto, then consists of a series of mixed
|
||||||
// STBTT_lineto and STBTT_curveto segments. A lineto
|
// STBTT_lineto and STBTT_curveto segments. A lineto
|
||||||
// draws a line from previous endpoint to its x,y; a curveto
|
// draws a line from previous endpoint to its x,y; a curveto
|
||||||
@ -919,7 +932,7 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
|||||||
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
|
STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
|
||||||
// These functions compute a discretized SDF field for a single character, suitable for storing
|
// These functions compute a discretized SDF field for a single character, suitable for storing
|
||||||
// in a single-channel texture, sampling with bilinear filtering, and testing against
|
// in a single-channel texture, sampling with bilinear filtering, and testing against
|
||||||
// larger than some threshhold to produce scalable fonts.
|
// larger than some threshold to produce scalable fonts.
|
||||||
// info -- the font
|
// info -- the font
|
||||||
// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
|
// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
|
||||||
// glyph/codepoint -- the character to generate the SDF for
|
// glyph/codepoint -- the character to generate the SDF for
|
||||||
@ -2371,7 +2384,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
|||||||
if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
|
if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
|
||||||
return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
|
return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
|
||||||
|
|
||||||
// [ImGui: commented to fix static analyzer warning]
|
// [DEAR IMGUI] Commented to fix static analyzer warning
|
||||||
//classDefTable = classDef1ValueArray + 2 * glyphCount;
|
//classDefTable = classDef1ValueArray + 2 * glyphCount;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -2396,7 +2409,7 @@ static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
|
|||||||
return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
|
return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [ImGui: commented to fix static analyzer warning]
|
// [DEAR IMGUI] Commented to fix static analyzer warning
|
||||||
//classDefTable = classRangeRecords + 6 * classRangeCount;
|
//classDefTable = classRangeRecords + 6 * classRangeCount;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -3029,6 +3042,7 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill,
|
|||||||
dx = -dx;
|
dx = -dx;
|
||||||
dy = -dy;
|
dy = -dy;
|
||||||
t = x0, x0 = xb, xb = t;
|
t = x0, x0 = xb, xb = t;
|
||||||
|
// [DEAR IMGUI] Fix static analyzer warning
|
||||||
(void)dx; // [ImGui: fix static analyzer warning]
|
(void)dx; // [ImGui: fix static analyzer warning]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3167,7 +3181,13 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e,
|
|||||||
if (e->y0 != e->y1) {
|
if (e->y0 != e->y1) {
|
||||||
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
|
stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
|
||||||
if (z != NULL) {
|
if (z != NULL) {
|
||||||
STBTT_assert(z->ey >= scan_y_top);
|
if (j == 0 && off_y != 0) {
|
||||||
|
if (z->ey < scan_y_top) {
|
||||||
|
// this can happen due to subpixel positioning and some kind of fp rounding error i think
|
||||||
|
z->ey = scan_y_top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds
|
||||||
// insert at front
|
// insert at front
|
||||||
z->next = active;
|
z->next = active;
|
||||||
active = z;
|
active = z;
|
||||||
@ -3236,7 +3256,7 @@ static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
|
|||||||
|
|
||||||
static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
|
static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
|
||||||
{
|
{
|
||||||
/* threshhold for transitioning to insertion sort */
|
/* threshold for transitioning to insertion sort */
|
||||||
while (n > 12) {
|
while (n > 12) {
|
||||||
stbtt__edge t;
|
stbtt__edge t;
|
||||||
int c01,c12,c,m,i,j;
|
int c01,c12,c,m,i,j;
|
||||||
@ -3371,7 +3391,7 @@ static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
|
|||||||
points[n].y = y;
|
points[n].y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tesselate until threshhold p is happy... @TODO warped to compensate for non-linear stretching
|
// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching
|
||||||
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
|
static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
|
||||||
{
|
{
|
||||||
// midpoint
|
// midpoint
|
||||||
@ -3796,6 +3816,7 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in
|
|||||||
spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
|
spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
|
||||||
spc->h_oversample = 1;
|
spc->h_oversample = 1;
|
||||||
spc->v_oversample = 1;
|
spc->v_oversample = 1;
|
||||||
|
spc->skip_missing = 0;
|
||||||
|
|
||||||
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
||||||
|
|
||||||
@ -3821,6 +3842,11 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
spc->v_oversample = v_oversample;
|
spc->v_oversample = v_oversample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
|
||||||
|
{
|
||||||
|
spc->skip_missing = skip;
|
||||||
|
}
|
||||||
|
|
||||||
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
||||||
|
|
||||||
static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
|
||||||
@ -3974,13 +4000,17 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb
|
|||||||
int x0,y0,x1,y1;
|
int x0,y0,x1,y1;
|
||||||
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
||||||
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
||||||
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
if (glyph == 0 && spc->skip_missing) {
|
||||||
scale * spc->h_oversample,
|
rects[k].w = rects[k].h = 0;
|
||||||
scale * spc->v_oversample,
|
} else {
|
||||||
0,0,
|
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
||||||
&x0,&y0,&x1,&y1);
|
scale * spc->h_oversample,
|
||||||
rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
|
scale * spc->v_oversample,
|
||||||
rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
|
0,0,
|
||||||
|
&x0,&y0,&x1,&y1);
|
||||||
|
rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
|
||||||
|
rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
|
||||||
|
}
|
||||||
++k;
|
++k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4033,7 +4063,7 @@ STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const
|
|||||||
sub_y = stbtt__oversample_shift(spc->v_oversample);
|
sub_y = stbtt__oversample_shift(spc->v_oversample);
|
||||||
for (j=0; j < ranges[i].num_chars; ++j) {
|
for (j=0; j < ranges[i].num_chars; ++j) {
|
||||||
stbrp_rect *r = &rects[k];
|
stbrp_rect *r = &rects[k];
|
||||||
if (r->was_packed) {
|
if (r->was_packed && r->w != 0 && r->h != 0) {
|
||||||
stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
|
stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
|
||||||
int advance, lsb, x0,y0,x1,y1;
|
int advance, lsb, x0,y0,x1,y1;
|
||||||
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
||||||
@ -4147,6 +4177,19 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *
|
|||||||
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap)
|
||||||
|
{
|
||||||
|
int i_ascent, i_descent, i_lineGap;
|
||||||
|
float scale;
|
||||||
|
stbtt_fontinfo info;
|
||||||
|
stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index));
|
||||||
|
scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size);
|
||||||
|
stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap);
|
||||||
|
*ascent = (float) i_ascent * scale;
|
||||||
|
*descent = (float) i_descent * scale;
|
||||||
|
*lineGap = (float) i_lineGap * scale;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
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;
|
||||||
@ -4259,7 +4302,7 @@ static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex
|
|||||||
int winding = 0;
|
int winding = 0;
|
||||||
|
|
||||||
orig[0] = x;
|
orig[0] = x;
|
||||||
//orig[1] = y; // [ImGui] commmented double assignment without reading
|
//orig[1] = y; // [DEAR IMGUI] commmented double assignment
|
||||||
|
|
||||||
// make sure y never passes through a vertex of the shape
|
// make sure y never passes through a vertex of the shape
|
||||||
y_frac = (float) STBTT_fmod(y, 1.0f);
|
y_frac = (float) STBTT_fmod(y, 1.0f);
|
||||||
|
Loading…
Reference in New Issue
Block a user