Document/workaround an issue using IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION since 1.92.0. (#8794)

This commit is contained in:
ocornut
2025-07-23 16:30:30 +09:00
parent 174f37bdaf
commit b884533957
3 changed files with 17 additions and 3 deletions

View File

@@ -49,6 +49,8 @@ Other Changes:
- Error Handling: minor improvements to error handling for TableGetSortSpecs()
and TableSetBgColor() calls. (#1651, #8499)
- Misc: fixed building with IMGUI_DISABLE_DEBUG_TOOLS only. (#8796)
- Misc: document/workaround an issue using IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
since 1.92.0. (#8794) [@tim-rex]
- Misc: removed more redundant inline static linkage from imgui_internal.h to
facilitate using in C++ modules. (#8813, #8682, #8358) [@stripe2933]
- CI: Added SDL3 builds to MacOS and Windows. (#8819, #8778) [@scribam]

View File

@@ -4622,6 +4622,15 @@ static bool ImGui_ImplStbTrueType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig
return true;
}
// Since 1.92.0 (June 2025) we rely on those 3 functions which are implemented inside stb_truetype.h and require STB_TRUETYPE_IMPLEMENTATION.
// Using IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION became broken, see https://github.com/ocornut/imgui/issues/8794
// One way to fix is to remove the 'static' keywords for those 3 functions in your copy of stb_truetype.h
#ifdef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
extern void stbtt__h_prefilter(unsigned char* pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width);
extern void stbtt__v_prefilter(unsigned char* pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width);
extern float stbtt__oversample_shift(int oversample);
#endif
static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void*, ImWchar codepoint, ImFontGlyph* out_glyph, float* out_advance_x)
{
// Search for first font which has the glyph

View File

@@ -4017,7 +4017,8 @@ STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int s
#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)
{
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
int safe_w = w - kernel_width;
@@ -4079,7 +4080,8 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_i
}
}
static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
/*static*/
void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
{
unsigned char buffer[STBTT_MAX_OVERSAMPLE];
int safe_h = h - kernel_width;
@@ -4141,7 +4143,8 @@ static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_i
}
}
static float stbtt__oversample_shift(int oversample)
/*static*/
float stbtt__oversample_shift(int oversample)
{
if (!oversample)
return 0.0f;