mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Fonts: (Breaking) Rename ImGuiFreeType:: flags to ImGuiFreeTypeBuilderFlags_XXX. Remove ImGuiFreeType::BuildFontAtlas() flags. Rename ImFontConfig::RasterizerFlags to FontBuilderFlags. Add ImFontBuilderIO (opaque). Amend 53d59f3 with a dozen of small fixes.
This commit is contained in:
@ -122,7 +122,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||
#endif
|
||||
|
||||
#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
|
||||
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in another compilation unit
|
||||
#define STBRP_STATIC
|
||||
#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0)
|
||||
#define STBRP_SORT ImQsort
|
||||
@ -137,7 +137,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||
|
||||
#ifdef IMGUI_ENABLE_STB_TRUETYPE
|
||||
#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
|
||||
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in another compilation unit
|
||||
#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x))
|
||||
#define STBTT_free(x,u) ((void)(u), IM_FREE(x))
|
||||
#define STBTT_assert(x) do { IM_ASSERT(x); } while(0)
|
||||
@ -158,7 +158,7 @@ namespace IMGUI_STB_NAMESPACE
|
||||
#include "imstb_truetype.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif // IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@ -1782,14 +1782,6 @@ ImFontAtlas::ImFontAtlas()
|
||||
memset(this, 0, sizeof(*this));
|
||||
TexGlyphPadding = 1;
|
||||
PackIdMouseCursors = PackIdLines = -1;
|
||||
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
Builder = "freetype";
|
||||
#else
|
||||
# ifdef IMGUI_ENABLE_STB_TRUETYPE
|
||||
Builder = "stb_truetype";
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
ImFontAtlas::~ImFontAtlas()
|
||||
@ -2074,17 +2066,26 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
||||
bool ImFontAtlas::Build()
|
||||
{
|
||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||
|
||||
// Select builder
|
||||
// - Note that we do not reassign to atlas->FontBuilderIO, since it is likely to point to static data which
|
||||
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are
|
||||
// using a hot-reloading scheme that messes up static data, store your own instance of ImFontBuilderIO somewhere
|
||||
// and point to it instead of pointing directly to return value of the GetBuilderXXX functions.
|
||||
const ImFontBuilderIO* builder_io = FontBuilderIO;
|
||||
if (builder_io == NULL)
|
||||
{
|
||||
#ifdef IMGUI_ENABLE_FREETYPE
|
||||
if (strcmp(Builder, "freetype") == 0)
|
||||
return ImGuiFreeType::BuildFontAtlas(this, 0);
|
||||
builder_io = ImGuiFreeType::GetBuilderForFreeType();
|
||||
#elif defined(IMGUI_ENABLE_STB_TRUETYPE)
|
||||
builder_io = ImFontAtlasGetBuilderForStbTruetype();
|
||||
#else
|
||||
IM_ASSERT(0); // Invalid Build function
|
||||
#endif
|
||||
// Not doing "#else" here, since we could have both
|
||||
// IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE defined.
|
||||
#ifdef IMGUI_ENABLE_STB_TRUETYPE
|
||||
if (strcmp(Builder, "stb_truetype") == 0)
|
||||
return ImFontAtlasBuildWithStbTruetype(this);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build
|
||||
return builder_io->FontBuilder_Build(this);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor)
|
||||
@ -2142,7 +2143,7 @@ static void UnpackBitVectorToFlatIndexList(const ImBitVector* in, ImVector<int>*
|
||||
out->push_back((int)(((it - it_begin) << 5) + bit_n));
|
||||
}
|
||||
|
||||
bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
{
|
||||
IM_ASSERT(atlas->ConfigData.Size > 0);
|
||||
|
||||
@ -2394,7 +2395,15 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
||||
ImFontAtlasBuildFinish(atlas);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
const ImFontBuilderIO* ImFontAtlasGetBuilderForStbTruetype()
|
||||
{
|
||||
static ImFontBuilderIO io;
|
||||
io.FontBuilder_Build = ImFontAtlasBuildWithStbTruetype;
|
||||
return &io;
|
||||
}
|
||||
|
||||
#endif // IMGUI_ENABLE_STB_TRUETYPE
|
||||
|
||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||
{
|
||||
|
Reference in New Issue
Block a user