From 024e23c4d701a943c91fb838c36c01270af8261d Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 14 Feb 2018 12:04:21 +0100 Subject: [PATCH] Comments, moved ImFontAtlas::Flags to "public" area. --- imgui.h | 2 +- imgui_draw.cpp | 3 ++- misc/fonts/README.txt | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/imgui.h b/imgui.h index 61f6033a8..60d027e0c 100644 --- a/imgui.h +++ b/imgui.h @@ -1707,13 +1707,13 @@ struct ImFontAtlas // Members //------------------------------------------- + ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_) ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure. int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. // [Internal] // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you. - ImFontAtlasFlags Flags; // Build flags unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4 int TexWidth; // Texture width calculated during Build(). diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 037e5263a..cafe6e080 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1360,15 +1360,16 @@ static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_Count_][ ImFontAtlas::ImFontAtlas() { + Flags = 0x00; TexID = NULL; TexDesiredWidth = 0; TexGlyphPadding = 1; + TexPixelsAlpha8 = NULL; TexPixelsRGBA32 = NULL; TexWidth = TexHeight = 0; TexUvScale = ImVec2(0.0f, 0.0f); TexUvWhitePixel = ImVec2(0.0f, 0.0f); - Flags = 0x00; for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++) CustomRectIds[n] = -1; } diff --git a/misc/fonts/README.txt b/misc/fonts/README.txt index a3774ca77..70773fcad 100644 --- a/misc/fonts/README.txt +++ b/misc/fonts/README.txt @@ -80,6 +80,7 @@ In this document: - Mind the fact that some graphics drivers have texture size limitation. - Set io.Fonts.TexDesiredWidth to specify a texture width to minimize texture height (see comment in ImFontAtlas::Build function). + - Set io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight; to disable rounding the texture height to the next power of two. - You may reduce oversampling, e.g. config.OversampleH = 2 or 1. - Reduce glyphs ranges, consider calculating them based on your source data if this is possible. @@ -111,7 +112,7 @@ In this document: Offset font vertically by altering the io.Font->DisplayOffset value: ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels); - font->DisplayOffset.y += 1; // Render 1 pixel down + font->DisplayOffset.y = 1; // Render 1 pixel down ---------------------------------------