From 2fd411a83ee639d0faf64e2401e41756eb3ed583 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 15 Mar 2020 22:27:04 +0100 Subject: [PATCH] Support custom stb_rect_pack filename in Freetype (#3062) Copies the #define magic from imgui_draw.cpp to the imgui_freetype implementation to allow the use of a custom stb rect_pack here as well. References: fe5347ef94d7dc648c237323cc9e257aff6ab917 --- docs/CHANGELOG.txt | 2 ++ misc/freetype/imgui_freetype.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f37c6883b..703e48a53 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -57,6 +57,8 @@ Other Changes: - Window: Fixed a bug with child window inheriting ItemFlags from their parent when the child window also manipulate the ItemFlags stack. (#3024) [@Stanbroek] - Font: Fixed non-ASCII space occasionally creating unnecessary empty polygons. +- Misc, Freetype: Fixed support for IMGUI_STB_RECT_PACK_FILENAME compile time directive + in imgui_freetype.cpp (matching support in the regular code path). (#3062) [@DonKult] - Demo: Added black and white and color gradients to Demo>Examples>Custom Rendering. - CI: Added more tests on the continuous-integration server: extra warnings for Clang/GCC, building SDL+Metal example, and more compile-time imconfig.h settings: disabling obsolete functions, diff --git a/misc/freetype/imgui_freetype.cpp b/misc/freetype/imgui_freetype.cpp index be4183599..93a561639 100644 --- a/misc/freetype/imgui_freetype.cpp +++ b/misc/freetype/imgui_freetype.cpp @@ -278,12 +278,18 @@ namespace } } -#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) -#define STBRP_ASSERT(x) IM_ASSERT(x) +#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) +#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION +#define STBRP_ASSERT(x) IM_ASSERT(x) #define STBRP_STATIC #define STB_RECT_PACK_IMPLEMENTATION +#endif +#ifdef IMGUI_STB_RECT_PACK_FILENAME +#include IMGUI_STB_RECT_PACK_FILENAME +#else #include "imstb_rectpack.h" #endif +#endif struct ImFontBuildSrcGlyphFT {