impr: Attempt loading of full unicode plane from font if possible
This commit is contained in:
parent
ec2934b4b8
commit
daadc2ea71
@ -14,6 +14,7 @@
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <imgui_impl_opengl3_loader.h>
|
||||
#include <fonts/fontawesome_font.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
@ -278,7 +279,7 @@ namespace hex::init {
|
||||
std::uint8_t *px;
|
||||
int w, h;
|
||||
io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 11.0_scaled, &cfg, fontAwesomeRange);
|
||||
io.Fonts->GetTexDataAsRGBA32(&px, &w, &h);
|
||||
io.Fonts->GetTexDataAsAlpha8(&px, &w, &h);
|
||||
|
||||
// Create new font atlas
|
||||
GLuint tex;
|
||||
@ -286,7 +287,7 @@ namespace hex::init {
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA8, GL_UNSIGNED_INT, px);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, px);
|
||||
io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(tex));
|
||||
}
|
||||
|
||||
|
@ -118,28 +118,38 @@ namespace hex::init {
|
||||
// Setup basic font configuration
|
||||
auto fonts = IM_NEW(ImFontAtlas)();
|
||||
ImFontConfig cfg = {};
|
||||
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
|
||||
cfg.OversampleH = cfg.OversampleV = 2, cfg.PixelSnapH = true;
|
||||
cfg.SizePixels = fontSize;
|
||||
|
||||
fonts->Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;
|
||||
|
||||
// Configure font glyph ranges that should be loaded from the default font and unifont
|
||||
ImVector<ImWchar> ranges;
|
||||
{
|
||||
ImFontGlyphRangesBuilder glyphRangesBuilder;
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesDefault());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesJapanese());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesChineseFull());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesCyrillic());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesKorean());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesThai());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesVietnamese());
|
||||
|
||||
{
|
||||
constexpr static ImWchar controlCodeRange[] = { 0x0000, 0x001F, 0 };
|
||||
constexpr static ImWchar controlCodeRange[] = { 0x0001, 0x001F, 0 };
|
||||
constexpr static ImWchar extendedAsciiRange[] = { 0x007F, 0x00FF, 0 };
|
||||
|
||||
glyphRangesBuilder.AddRanges(controlCodeRange);
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesDefault());
|
||||
glyphRangesBuilder.AddRanges(extendedAsciiRange);
|
||||
}
|
||||
|
||||
if (loadUnicode) {
|
||||
constexpr static ImWchar fullRange[] = { 0x0100, 0xFFEF, 0 };
|
||||
|
||||
glyphRangesBuilder.AddRanges(fullRange);
|
||||
} else {
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesJapanese());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesChineseFull());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesCyrillic());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesKorean());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesThai());
|
||||
glyphRangesBuilder.AddRanges(fonts->GetGlyphRangesVietnamese());
|
||||
}
|
||||
|
||||
glyphRangesBuilder.BuildRanges(&ranges);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user