mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 05:06:59 +00:00
Docs: Improvements to description of using colored glyphes/emojis. (#4169, #3369) + Add Fonts to Metrics. Removed IMGUI_HAS_TABLE markers.
This commit is contained in:
parent
8877eab393
commit
c708299ca9
@ -83,6 +83,7 @@ Other Changes:
|
|||||||
par with original version. Now incorporating the correct revert.
|
par with original version. Now incorporating the correct revert.
|
||||||
- ImDrawList: Fixed PathArcTo() regression from 1.82 preventing use of counter-clockwise angles. (#4030, #3491) [@thedmd]
|
- ImDrawList: Fixed PathArcTo() regression from 1.82 preventing use of counter-clockwise angles. (#4030, #3491) [@thedmd]
|
||||||
- Demo: Improved popups demo and comments.
|
- Demo: Improved popups demo and comments.
|
||||||
|
- Metrics: Added "Fonts" section with same information as available in "Style Editor">"Fonts".
|
||||||
- Backends: SDL: Rework global mouse pos availability check listing supported platforms explicitly,
|
- Backends: SDL: Rework global mouse pos availability check listing supported platforms explicitly,
|
||||||
effectively fixing mouse access on Raspberry Pi. (#2837, #3950) [@lethal-guitar, @hinxx]
|
effectively fixing mouse access on Raspberry Pi. (#2837, #3950) [@lethal-guitar, @hinxx]
|
||||||
- Backends: Win32: Clearing keyboard down array when losing focus (WM_KILLFOCUS). (#2062, #3532, #3961)
|
- Backends: Win32: Clearing keyboard down array when losing focus (WM_KILLFOCUS). (#2062, #3532, #3961)
|
||||||
@ -104,6 +105,7 @@ Other Changes:
|
|||||||
- Examples: Vulkan: Prefer using discrete GPU if there are more than one available. (#4012) [@rokups]
|
- Examples: Vulkan: Prefer using discrete GPU if there are more than one available. (#4012) [@rokups]
|
||||||
- Examples: SDL2: Link with shell32.lib required by SDL2main.lib since SDL 2.0.12. [#3988]
|
- Examples: SDL2: Link with shell32.lib required by SDL2main.lib since SDL 2.0.12. [#3988]
|
||||||
- Examples: Android: Make Android example build compatible with Gradle 7.0. (#3446)
|
- Examples: Android: Make Android example build compatible with Gradle 7.0. (#3446)
|
||||||
|
- Docs: Improvements to description of using colored glyphes/emojis. (#4169, #3369)
|
||||||
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +14,9 @@ In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) fo
|
|||||||
- [Readme First](#readme-first)
|
- [Readme First](#readme-first)
|
||||||
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application)
|
||||||
- [Fonts Loading Instructions](#font-loading-instructions)
|
- [Fonts Loading Instructions](#font-loading-instructions)
|
||||||
- [Using Icons](#using-icons)
|
- [Using Icon Fonts](#using-icon-fonts)
|
||||||
- [Using FreeType Rasterizer](#using-freetype-rasterizer)
|
- [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype)
|
||||||
|
- [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis)
|
||||||
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
- [Using Custom Glyph Ranges](#using-custom-glyph-ranges)
|
||||||
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
- [Using Custom Colorful Icons](#using-custom-colorful-icons)
|
||||||
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
|
- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code)
|
||||||
@ -160,7 +161,7 @@ Some solutions:
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
## Using Icons
|
## Using Icon Fonts
|
||||||
|
|
||||||
Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application.
|
Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application.
|
||||||
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without having to change fonts back and forth.
|
A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without having to change fonts back and forth.
|
||||||
@ -197,7 +198,7 @@ Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
## Using FreeType Rasterizer
|
## Using FreeType Rasterizer (imgui_freetype)
|
||||||
|
|
||||||
- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read.
|
- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read.
|
||||||
- There is an implementation of the ImFontAtlas builder using FreeType that you can use in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder.
|
- There is an implementation of the ImFontAtlas builder using FreeType that you can use in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder.
|
||||||
@ -207,6 +208,28 @@ Here's an application using icons ("Avoyd", https://www.avoyd.com):
|
|||||||
|
|
||||||
##### [Return to Index](#index)
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
|
## Using Colorful Glyphs/Emojis
|
||||||
|
|
||||||
|
- Rendering of colored emojis is only supported by imgui_freetype with FreeType 2.10+.
|
||||||
|
- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag.
|
||||||
|
- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`.
|
||||||
|
- Not all types of color fonts are supported by FreeType at the moment.
|
||||||
|
- Stateful Unicode features such as skin tone modifiers are not supported by the text renderer.
|
||||||
|
|
||||||
|
![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png)
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
io.Fonts->AddFontFromFileTTF("../../../imgui_dev/data/fonts/NotoSans-Regular.ttf", 16.0f);
|
||||||
|
static ImWchar ranges[] = { 0x1, 0x1FFFF, 0 };
|
||||||
|
static ImFontConfig cfg;
|
||||||
|
cfg.OversampleH = cfg.OversampleV = 1;
|
||||||
|
cfg.MergeMode = true;
|
||||||
|
cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_LoadColor;
|
||||||
|
io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguiemj.ttf", 16.0f, &cfg, ranges);
|
||||||
|
```
|
||||||
|
|
||||||
|
##### [Return to Index](#index)
|
||||||
|
|
||||||
## Using Custom Glyph Ranges
|
## Using Custom Glyph Ranges
|
||||||
|
|
||||||
You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs.
|
||||||
@ -226,7 +249,7 @@ io.Fonts->Build(); // Build the atlas while
|
|||||||
|
|
||||||
## Using Custom Colorful Icons
|
## Using Custom Colorful Icons
|
||||||
|
|
||||||
**(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)**
|
As an alternative to rendering colorful glyphs using imgui_freetype with `ImGuiFreeTypeBuilderFlags_LoadColor`, you may allocate your own space in the texture atlas and write yourself into it. **(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)**
|
||||||
|
|
||||||
- You can use the `ImFontAtlas::AddCustomRect()` and `ImFontAtlas::AddCustomRectFontGlyph()` api to register rectangles that will be packed into the font atlas texture. Register them before building the atlas, then call Build()`.
|
- You can use the `ImFontAtlas::AddCustomRect()` and `ImFontAtlas::AddCustomRectFontGlyph()` api to register rectangles that will be packed into the font atlas texture. Register them before building the atlas, then call Build()`.
|
||||||
- You can then use `ImFontAtlas::GetCustomRectByIndex(int)` to query the position/size of your rectangle within the texture, and blit/copy any graphics data of your choice into those rectangles.
|
- You can then use `ImFontAtlas::GetCustomRectByIndex(int)` to query the position/size of your rectangle within the texture, and blit/copy any graphics data of your choice into those rectangles.
|
||||||
|
20
imgui.cpp
20
imgui.cpp
@ -4141,10 +4141,8 @@ void ImGui::Initialize(ImGuiContext* context)
|
|||||||
g.SettingsHandlers.push_back(ini_handler);
|
g.SettingsHandlers.push_back(ini_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
// Add .ini handle for ImGuiTable type
|
// Add .ini handle for ImGuiTable type
|
||||||
TableSettingsInstallHandler(context);
|
TableSettingsInstallHandler(context);
|
||||||
#endif // #ifdef IMGUI_HAS_TABLE
|
|
||||||
|
|
||||||
// Create default viewport
|
// Create default viewport
|
||||||
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
|
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
|
||||||
@ -7215,13 +7213,11 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
while (g.CurrentWindowStack.Size > 0)
|
while (g.CurrentWindowStack.Size > 0)
|
||||||
{
|
{
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow))
|
while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow))
|
||||||
{
|
{
|
||||||
if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name);
|
if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name);
|
||||||
EndTable();
|
EndTable();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
IM_ASSERT(window != NULL);
|
IM_ASSERT(window != NULL);
|
||||||
while (g.CurrentTabBar != NULL) //-V1044
|
while (g.CurrentTabBar != NULL) //-V1044
|
||||||
@ -10914,6 +10910,8 @@ static void MetricsHelpMarker(const char* desc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace ImGui { void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||||
|
|
||||||
void ImGui::ShowMetricsWindow(bool* p_open)
|
void ImGui::ShowMetricsWindow(bool* p_open)
|
||||||
{
|
{
|
||||||
if (!Begin("Dear ImGui Metrics/Debugger", p_open))
|
if (!Begin("Dear ImGui Metrics/Debugger", p_open))
|
||||||
@ -11109,14 +11107,20 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Details for Tables
|
// Details for Tables
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
if (TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
|
if (TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
|
||||||
{
|
{
|
||||||
for (int n = 0; n < g.Tables.GetSize(); n++)
|
for (int n = 0; n < g.Tables.GetSize(); n++)
|
||||||
DebugNodeTable(g.Tables.GetByIndex(n));
|
DebugNodeTable(g.Tables.GetByIndex(n));
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
#endif // #ifdef IMGUI_HAS_TABLE
|
|
||||||
|
// Details for Fonts
|
||||||
|
ImFontAtlas* atlas = g.IO.Fonts;
|
||||||
|
if (TreeNode("Fonts", "Fonts (%d)", atlas->Fonts.Size))
|
||||||
|
{
|
||||||
|
ShowFontAtlas(atlas);
|
||||||
|
TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
// Details for Docking
|
// Details for Docking
|
||||||
#ifdef IMGUI_HAS_DOCK
|
#ifdef IMGUI_HAS_DOCK
|
||||||
@ -11156,14 +11160,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
if (TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size()))
|
if (TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size()))
|
||||||
{
|
{
|
||||||
for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings))
|
for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings))
|
||||||
DebugNodeTableSettings(settings);
|
DebugNodeTableSettings(settings);
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
#endif // #ifdef IMGUI_HAS_TABLE
|
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_DOCK
|
#ifdef IMGUI_HAS_DOCK
|
||||||
#endif // #ifdef IMGUI_HAS_DOCK
|
#endif // #ifdef IMGUI_HAS_DOCK
|
||||||
@ -11237,7 +11239,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
// Overlay: Display Tables Rectangles
|
// Overlay: Display Tables Rectangles
|
||||||
if (cfg->ShowTablesRects)
|
if (cfg->ShowTablesRects)
|
||||||
{
|
{
|
||||||
@ -11264,7 +11265,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // #ifdef IMGUI_HAS_TABLE
|
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_DOCK
|
#ifdef IMGUI_HAS_DOCK
|
||||||
// Overlay: Display Docking info
|
// Overlay: Display Docking info
|
||||||
|
111
imgui_demo.cpp
111
imgui_demo.cpp
@ -54,6 +54,7 @@ Index of this file:
|
|||||||
// - sub section: ShowDemoWindowTables()
|
// - sub section: ShowDemoWindowTables()
|
||||||
// - sub section: ShowDemoWindowMisc()
|
// - sub section: ShowDemoWindowMisc()
|
||||||
// [SECTION] About Window / ShowAboutWindow()
|
// [SECTION] About Window / ShowAboutWindow()
|
||||||
|
// [SECTION] Font Viewer / ShowFontAtlas()
|
||||||
// [SECTION] Style Editor / ShowStyleEditor()
|
// [SECTION] Style Editor / ShowStyleEditor()
|
||||||
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar()
|
||||||
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
// [SECTION] Example App: Debug Console / ShowExampleAppConsole()
|
||||||
@ -1603,7 +1604,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
};
|
};
|
||||||
static int func_type = 0, display_count = 70;
|
static int func_type = 0, display_count = 70;
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::SetNextItemWidth(100);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::Combo("func", &func_type, "Sin\0Saw\0");
|
ImGui::Combo("func", &func_type, "Sin\0Saw\0");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::SliderInt("Sample count", &display_count, 1, 400);
|
ImGui::SliderInt("Sample count", &display_count, 1, 400);
|
||||||
@ -2393,7 +2394,7 @@ static void ShowDemoWindowLayout()
|
|||||||
// the POV of the parent window). See 'Demo->Querying Status (Active/Focused/Hovered etc.)' for details.
|
// the POV of the parent window). See 'Demo->Querying Status (Active/Focused/Hovered etc.)' for details.
|
||||||
{
|
{
|
||||||
static int offset_x = 0;
|
static int offset_x = 0;
|
||||||
ImGui::SetNextItemWidth(100);
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::DragInt("Offset X", &offset_x, 1.0f, -1000, 1000);
|
ImGui::DragInt("Offset X", &offset_x, 1.0f, -1000, 1000);
|
||||||
|
|
||||||
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x);
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x);
|
||||||
@ -2415,15 +2416,15 @@ static void ShowDemoWindowLayout()
|
|||||||
|
|
||||||
if (ImGui::TreeNode("Widgets Width"))
|
if (ImGui::TreeNode("Widgets Width"))
|
||||||
{
|
{
|
||||||
|
static float f = 0.0f;
|
||||||
|
static bool show_indented_items = true;
|
||||||
|
ImGui::Checkbox("Show indented items", &show_indented_items);
|
||||||
|
|
||||||
// Use SetNextItemWidth() to set the width of a single upcoming item.
|
// Use SetNextItemWidth() to set the width of a single upcoming item.
|
||||||
// Use PushItemWidth()/PopItemWidth() to set the width of a group of items.
|
// Use PushItemWidth()/PopItemWidth() to set the width of a group of items.
|
||||||
// In real code use you'll probably want to choose width values that are proportional to your font size
|
// In real code use you'll probably want to choose width values that are proportional to your font size
|
||||||
// e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc.
|
// e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc.
|
||||||
|
|
||||||
static float f = 0.0f;
|
|
||||||
static bool show_indented_items = true;
|
|
||||||
ImGui::Checkbox("Show indented items", &show_indented_items);
|
|
||||||
|
|
||||||
ImGui::Text("SetNextItemWidth/PushItemWidth(100)");
|
ImGui::Text("SetNextItemWidth/PushItemWidth(100)");
|
||||||
ImGui::SameLine(); HelpMarker("Fixed width.");
|
ImGui::SameLine(); HelpMarker("Fixed width.");
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
@ -5743,31 +5744,15 @@ void ImGui::ShowAboutWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] Style Editor / ShowStyleEditor()
|
// [SECTION] Font viewer / ShowFontAtlas()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - ShowStyleSelector()
|
|
||||||
// - ShowFontSelector()
|
// - ShowFontSelector()
|
||||||
// - ShowStyleEditor()
|
// - ShowFont()
|
||||||
|
// - ShowFontAtlas()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
// This isn't worth putting in public API but we want Metrics to use it
|
||||||
// Here we use the simplified Combo() api that packs items into a single literal string.
|
namespace ImGui { void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||||
// Useful for quick combo boxes where the choices are known locally.
|
|
||||||
bool ImGui::ShowStyleSelector(const char* label)
|
|
||||||
{
|
|
||||||
static int style_idx = -1;
|
|
||||||
if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
|
|
||||||
{
|
|
||||||
switch (style_idx)
|
|
||||||
{
|
|
||||||
case 0: ImGui::StyleColorsDark(); break;
|
|
||||||
case 1: ImGui::StyleColorsLight(); break;
|
|
||||||
case 2: ImGui::StyleColorsClassic(); break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Demo helper function to select among loaded fonts.
|
// Demo helper function to select among loaded fonts.
|
||||||
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
|
// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one.
|
||||||
@ -5796,7 +5781,7 @@ void ImGui::ShowFontSelector(const char* label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [Internal] Display details for a single font, called by ShowStyleEditor().
|
// [Internal] Display details for a single font, called by ShowStyleEditor().
|
||||||
static void NodeFont(ImFont* font)
|
static void ShowFont(ImFont* font)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
@ -5806,9 +5791,13 @@ static void NodeFont(ImFont* font)
|
|||||||
if (!font_details_opened)
|
if (!font_details_opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Display preview text
|
||||||
ImGui::PushFont(font);
|
ImGui::PushFont(font);
|
||||||
ImGui::Text("The quick brown fox jumps over the lazy dog");
|
ImGui::Text("The quick brown fox jumps over the lazy dog");
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
// Display details
|
||||||
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
|
ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font
|
||||||
ImGui::SameLine(); HelpMarker(
|
ImGui::SameLine(); HelpMarker(
|
||||||
"Note than the default embedded font is NOT meant to be scaled.\n\n"
|
"Note than the default embedded font is NOT meant to be scaled.\n\n"
|
||||||
@ -5826,9 +5815,10 @@ static void NodeFont(ImFont* font)
|
|||||||
if (const ImFontConfig* cfg = &font->ConfigData[config_i])
|
if (const ImFontConfig* cfg = &font->ConfigData[config_i])
|
||||||
ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
|
ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
|
||||||
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
|
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
|
||||||
|
|
||||||
|
// Display all glyphs of the fonts in separate pages of 256 characters
|
||||||
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
|
||||||
{
|
{
|
||||||
// Display all glyphs of the fonts in separate pages of 256 characters
|
|
||||||
const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text);
|
const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text);
|
||||||
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
|
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
|
||||||
{
|
{
|
||||||
@ -5883,6 +5873,50 @@ static void NodeFont(ImFont* font)
|
|||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||||
|
{
|
||||||
|
ImFont* font = atlas->Fonts[i];
|
||||||
|
ImGui::PushID(font);
|
||||||
|
ShowFont(font);
|
||||||
|
ImGui::PopID();
|
||||||
|
}
|
||||||
|
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||||
|
{
|
||||||
|
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
||||||
|
ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col);
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] Style Editor / ShowStyleEditor()
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// - ShowStyleSelector()
|
||||||
|
// - ShowStyleEditor()
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
||||||
|
// Here we use the simplified Combo() api that packs items into a single literal string.
|
||||||
|
// Useful for quick combo boxes where the choices are known locally.
|
||||||
|
bool ImGui::ShowStyleSelector(const char* label)
|
||||||
|
{
|
||||||
|
static int style_idx = -1;
|
||||||
|
if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
|
||||||
|
{
|
||||||
|
switch (style_idx)
|
||||||
|
{
|
||||||
|
case 0: ImGui::StyleColorsDark(); break;
|
||||||
|
case 1: ImGui::StyleColorsLight(); break;
|
||||||
|
case 2: ImGui::StyleColorsClassic(); break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||||
{
|
{
|
||||||
// You can pass in a reference ImGuiStyle structure to compare to, revert to and save to
|
// You can pass in a reference ImGuiStyle structure to compare to, revert to and save to
|
||||||
@ -6039,21 +6073,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
ImFontAtlas* atlas = io.Fonts;
|
ImFontAtlas* atlas = io.Fonts;
|
||||||
HelpMarker("Read FAQ and docs/FONTS.md for details on font loading.");
|
HelpMarker("Read FAQ and docs/FONTS.md for details on font loading.");
|
||||||
ImGui::PushItemWidth(120);
|
ImGui::ShowFontAtlas(atlas);
|
||||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
|
||||||
{
|
|
||||||
ImFont* font = atlas->Fonts[i];
|
|
||||||
ImGui::PushID(font);
|
|
||||||
NodeFont(font);
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
|
||||||
{
|
|
||||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
|
||||||
ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col);
|
|
||||||
ImGui::TreePop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below.
|
// Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below.
|
||||||
// (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds).
|
// (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds).
|
||||||
@ -6065,6 +6085,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
"rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n"
|
"rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n"
|
||||||
"Using those settings here will give you poor quality results.");
|
"Using those settings here will give you poor quality results.");
|
||||||
static float window_scale = 1.0f;
|
static float window_scale = 1.0f;
|
||||||
|
ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
|
||||||
if (ImGui::DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window
|
if (ImGui::DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window
|
||||||
ImGui::SetWindowFontScale(window_scale);
|
ImGui::SetWindowFontScale(window_scale);
|
||||||
ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything
|
ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything
|
||||||
@ -6084,7 +6105,7 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
|||||||
HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering).");
|
HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering).");
|
||||||
|
|
||||||
ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
|
ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
|
||||||
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
|
ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f");
|
||||||
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
|
if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f;
|
||||||
|
|
||||||
|
@ -2015,8 +2015,6 @@ struct ImGuiTabBar
|
|||||||
// [SECTION] Table support
|
// [SECTION] Table support
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef IMGUI_HAS_TABLE
|
|
||||||
|
|
||||||
#define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color.
|
#define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color.
|
||||||
#define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64.
|
#define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64.
|
||||||
#define IMGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2) // See TableSetupDrawChannels()
|
#define IMGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2) // See TableSetupDrawChannels()
|
||||||
@ -2266,8 +2264,6 @@ struct ImGuiTableSettings
|
|||||||
ImGuiTableColumnSettings* GetColumnSettings() { return (ImGuiTableColumnSettings*)(this + 1); }
|
ImGuiTableColumnSettings* GetColumnSettings() { return (ImGuiTableColumnSettings*)(this + 1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // #ifdef IMGUI_HAS_TABLE
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] ImGui internal API
|
// [SECTION] ImGui internal API
|
||||||
// No guarantee of forward compatibility here!
|
// No guarantee of forward compatibility here!
|
||||||
|
@ -28,3 +28,10 @@ See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad
|
|||||||
|
|
||||||
Small, thin anti-aliased fonts are typically benefiting a lots from Freetype's hinting:
|
Small, thin anti-aliased fonts are typically benefiting a lots from Freetype's hinting:
|
||||||
![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif)
|
![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif)
|
||||||
|
|
||||||
|
### Colorful glyphs/emojis
|
||||||
|
|
||||||
|
You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See
|
||||||
|
["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/edit/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md.
|
||||||
|
|
||||||
|
![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png)
|
||||||
|
Loading…
Reference in New Issue
Block a user