mirror of https://github.com/bkaradzic/bgfx
Switched to Roboto font. Added mono font.
This commit is contained in:
parent
3dd6bc237b
commit
dda0de635e
|
@ -1,4 +1,4 @@
|
|||
static const uint8_t s_iconsFontAwesome[80776] =
|
||||
static const uint8_t s_iconsFontAwesomeTtf[80776] =
|
||||
{
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x80, 0x00, 0x03, 0x00, 0x60, 0x46, 0x46, 0x54, 0x4d, // ...........`FFTM
|
||||
0x66, 0x1f, 0x16, 0xdb, 0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 0x00, 0x1c, 0x47, 0x44, 0x45, 0x46, // f...........GDEF
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
static const uint8_t s_iconsKenney[46184] =
|
||||
static const uint8_t s_iconsKenneyTtf[46184] =
|
||||
{
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x80, 0x00, 0x03, 0x00, 0x30, 0x4f, 0x53, 0x2f, 0x32, // ...........0OS/2
|
||||
0x0f, 0x12, 0x07, 0x0b, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x60, 0x63, 0x6d, 0x61, 0x70, // ...........`cmap
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include "fs_imgui_image_swizz.bin.h"
|
||||
|
||||
// embedded font
|
||||
#include "droidsans.ttf.h"
|
||||
#include "roboto_regular.ttf.h"
|
||||
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4244); // warning C4244: '=' : conversion from '' to '', possible loss of data
|
||||
|
||||
|
@ -451,7 +451,7 @@ struct Imgui
|
|||
return bgfx::createTexture2D(uint16_t(_width), uint16_t(_height), 0, bgfx::TextureFormat::BGRA8, 0, mem);
|
||||
}
|
||||
|
||||
ImguiFontHandle create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
|
||||
ImguiFontHandle create(float _fontSize, bx::AllocatorI* _allocator)
|
||||
{
|
||||
m_allocator = _allocator;
|
||||
|
||||
|
@ -463,16 +463,10 @@ struct Imgui
|
|||
}
|
||||
#endif // BX_CONFIG_ALLOCATOR_CRT
|
||||
|
||||
if (NULL == _data)
|
||||
{
|
||||
_data = s_droidSansTtf;
|
||||
_size = sizeof(s_droidSansTtf);
|
||||
}
|
||||
|
||||
IMGUI_create(_data, _size, _fontSize, m_allocator);
|
||||
IMGUI_create(_fontSize, m_allocator);
|
||||
|
||||
m_nvg = nvgCreate(1, m_view, m_allocator);
|
||||
nvgCreateFontMem(m_nvg, "default", (unsigned char*)_data, INT32_MAX, 0);
|
||||
nvgCreateFontMem(m_nvg, "default", (unsigned char*)s_robotoRegularTtf, INT32_MAX, 0);
|
||||
nvgFontSize(m_nvg, _fontSize);
|
||||
nvgFontFace(m_nvg, "default");
|
||||
|
||||
|
@ -606,7 +600,7 @@ struct Imgui
|
|||
m_missingTexture = genMissingTexture(256, 256, 0.04f);
|
||||
|
||||
#if !USE_NANOVG_FONT
|
||||
const ImguiFontHandle handle = createFont(_data, _fontSize);
|
||||
const ImguiFontHandle handle = createFont(s_robotoRegularTtf, _fontSize);
|
||||
m_currentFontIdx = handle.idx;
|
||||
#else
|
||||
const ImguiFontHandle handle = { bgfx::invalidHandle };
|
||||
|
@ -3262,9 +3256,9 @@ void imguiFree(void* _ptr, void*)
|
|||
BX_FREE(s_imgui.m_allocator, _ptr);
|
||||
}
|
||||
|
||||
ImguiFontHandle imguiCreate(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
|
||||
ImguiFontHandle imguiCreate(const void*, uint32_t, float _fontSize, bx::AllocatorI* _allocator)
|
||||
{
|
||||
return s_imgui.create(_data, _size, _fontSize, _allocator);
|
||||
return s_imgui.create(_fontSize, _allocator);
|
||||
}
|
||||
|
||||
void imguiDestroy()
|
||||
|
|
|
@ -133,13 +133,13 @@ inline uint32_t imguiRGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255)
|
|||
|
||||
BGFX_HANDLE(ImguiFontHandle);
|
||||
|
||||
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize=15.0f);
|
||||
ImguiFontHandle imguiCreateFont(const void* _data, float _fontSize = 18.0f);
|
||||
void imguiSetFont(ImguiFontHandle _handle);
|
||||
ImguiFontHandle imguiGetCurrentFont();
|
||||
|
||||
namespace bx { struct AllocatorI; }
|
||||
|
||||
ImguiFontHandle imguiCreate(const void* _data = NULL, uint32_t _size = 0, float _fontSize = 15.0f, bx::AllocatorI* _allocator = NULL);
|
||||
ImguiFontHandle imguiCreate(const void* _data = NULL, uint32_t _size = 0, float _fontSize = 18.0f, bx::AllocatorI* _allocator = NULL);
|
||||
void imguiDestroy();
|
||||
|
||||
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar = 0, uint8_t _view = 255);
|
||||
|
@ -280,6 +280,19 @@ namespace ImGui
|
|||
SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() );
|
||||
}
|
||||
|
||||
struct Font
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
Regular,
|
||||
Mono,
|
||||
|
||||
Count
|
||||
};
|
||||
};
|
||||
|
||||
void PushFont(Font::Enum _font);
|
||||
|
||||
} // namespace ImGui
|
||||
|
||||
#endif // IMGUI_H_HEADER_GUARD
|
||||
|
|
|
@ -8,11 +8,23 @@ include ../../../scripts/shader-embeded.mk
|
|||
droidsans.ttf.h: ../../runtime/font/droidsans.ttf
|
||||
@bin2c -f $(<) -o $(@) -n s_droidSansTtf
|
||||
|
||||
roboto_regular.ttf.h: ../../runtime/font/roboto-regular.ttf
|
||||
@bin2c -f $(<) -o $(@) -n s_robotoRegularTtf
|
||||
|
||||
robotomono_regular.ttf.h: ../../runtime/font/robotomono-regular.ttf
|
||||
@bin2c -f $(<) -o $(@) -n s_robotoMonoRegularTtf
|
||||
|
||||
icons_font_awesome.ttf.h: ../../runtime/font/fontawesome-webfont.ttf
|
||||
@bin2c -f $(<) -o $(@) -n s_iconsFontAwesome
|
||||
@bin2c -f $(<) -o $(@) -n s_iconsFontAwesomeTtf
|
||||
|
||||
icons_kenney.ttf.h: ../../runtime/font/kenney-icon-font.ttf
|
||||
@bin2c -f $(<) -o $(@) -n s_iconsKenney
|
||||
@bin2c -f $(<) -o $(@) -n s_iconsKenneyTtf
|
||||
|
||||
rebuild: droidsans.ttf.h icons_font_awesome.ttf.h icons_kenney.ttf.h
|
||||
fonts: droidsans.ttf.h \
|
||||
roboto_regular.ttf.h \
|
||||
robotomono_regular.ttf.h \
|
||||
icons_font_awesome.ttf.h \
|
||||
icons_kenney.ttf.h
|
||||
|
||||
rebuild: fonts
|
||||
@make -s --no-print-directory clean all
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "vs_ocornut_imgui.bin.h"
|
||||
#include "fs_ocornut_imgui.bin.h"
|
||||
|
||||
#include "roboto_regular.ttf.h"
|
||||
#include "robotomono_regular.ttf.h"
|
||||
#include "icons_kenney.ttf.h"
|
||||
#include "icons_font_awesome.ttf.h"
|
||||
|
||||
|
@ -45,8 +47,8 @@ struct FontRangeMerge
|
|||
|
||||
static FontRangeMerge s_fontRangeMerge[] =
|
||||
{
|
||||
{ s_iconsKenney, sizeof(s_iconsKenney), { ICON_MIN_KI, ICON_MAX_KI, 0 } },
|
||||
{ s_iconsFontAwesome, sizeof(s_iconsFontAwesome), { ICON_MIN_FA, ICON_MAX_FA, 0 } },
|
||||
{ s_iconsKenneyTtf, sizeof(s_iconsKenneyTtf), { ICON_MIN_KI, ICON_MAX_KI, 0 } },
|
||||
{ s_iconsFontAwesomeTtf, sizeof(s_iconsFontAwesomeTtf), { ICON_MIN_FA, ICON_MAX_FA, 0 } },
|
||||
};
|
||||
|
||||
class PlatformWindow : public ImGuiWM::PlatformWindow
|
||||
|
@ -361,7 +363,7 @@ struct OcornutImguiContext
|
|||
}
|
||||
}
|
||||
|
||||
void create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
|
||||
void create(float _fontSize, bx::AllocatorI* _allocator)
|
||||
{
|
||||
m_viewId = 255;
|
||||
m_allocator = _allocator;
|
||||
|
@ -449,15 +451,13 @@ struct OcornutImguiContext
|
|||
ImFontConfig config;
|
||||
config.FontDataOwnedByAtlas = false;
|
||||
config.MergeMode = false;
|
||||
config.MergeGlyphCenterV = true;
|
||||
// config.MergeGlyphCenterV = true;
|
||||
|
||||
io.Fonts->AddFontFromMemoryTTF( (void*)_data
|
||||
, _size
|
||||
, _fontSize
|
||||
, &config
|
||||
);
|
||||
m_font[ImGui::Font::Regular] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoRegularTtf, sizeof(s_robotoRegularTtf), _fontSize, &config);
|
||||
m_font[ImGui::Font::Mono ] = io.Fonts->AddFontFromMemoryTTF( (void*)s_robotoMonoRegularTtf, sizeof(s_robotoMonoRegularTtf), _fontSize, &config);
|
||||
|
||||
config.MergeMode = true;
|
||||
config.DstFont = m_font[ImGui::Font::Regular];
|
||||
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_fontRangeMerge); ++ii)
|
||||
{
|
||||
|
@ -482,9 +482,6 @@ struct OcornutImguiContext
|
|||
, bgfx::copy(data, width*height*4)
|
||||
);
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FrameRounding = 4.0f;
|
||||
|
||||
m_wm = BX_NEW(m_allocator, WindowManager);
|
||||
m_wm->Init();
|
||||
|
||||
|
@ -554,6 +551,8 @@ struct OcornutImguiContext
|
|||
// https://gist.github.com/dougbinks/8089b4bbaccaaf6fa204236978d165a9
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
style.FrameRounding = 4.0f;
|
||||
|
||||
// light style from Pacome Danhiez (user itamago)
|
||||
// https://github.com/ocornut/imgui/pull/511#issuecomment-175719267
|
||||
style.Colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
|
||||
|
@ -679,6 +678,7 @@ struct OcornutImguiContext
|
|||
bgfx::ProgramHandle m_program;
|
||||
bgfx::TextureHandle m_texture;
|
||||
bgfx::UniformHandle s_tex;
|
||||
ImFont* m_font[ImGui::Font::Count];
|
||||
WindowManager* m_wm;
|
||||
int64_t m_last;
|
||||
int32_t m_lastScroll;
|
||||
|
@ -802,9 +802,9 @@ void OcornutImguiContext::renderDrawLists(ImDrawData* _drawData)
|
|||
s_ctx.render(_drawData);
|
||||
}
|
||||
|
||||
void IMGUI_create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator)
|
||||
void IMGUI_create(float _fontSize, bx::AllocatorI* _allocator)
|
||||
{
|
||||
s_ctx.create(_data, _size, _fontSize, _allocator);
|
||||
s_ctx.create(_fontSize, _allocator);
|
||||
}
|
||||
|
||||
void IMGUI_destroy()
|
||||
|
@ -821,3 +821,11 @@ void IMGUI_endFrame()
|
|||
{
|
||||
s_ctx.endFrame();
|
||||
}
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
void PushFont(Font::Enum _font)
|
||||
{
|
||||
PushFont(s_ctx.m_font[_font]);
|
||||
}
|
||||
} // namespace ImGui
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace bx { struct AllocatorI; }
|
||||
|
||||
void IMGUI_create(const void* _data, uint32_t _size, float _fontSize, bx::AllocatorI* _allocator);
|
||||
void IMGUI_create(float _fontSize, bx::AllocatorI* _allocator);
|
||||
void IMGUI_destroy();
|
||||
void IMGUI_beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, int _width, int _height, char _inputChar, uint8_t _viewId);
|
||||
void IMGUI_endFrame();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
@ -721,7 +721,7 @@ int _main_(int _argc, char** _argv)
|
|||
|
||||
if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize) )
|
||||
{
|
||||
ImGui::SetWindowFontScale(1.2f);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui::Text(
|
||||
"texturev, bgfx texture viewer tool " ICON_KI_WRENCH "\n"
|
||||
|
|
Loading…
Reference in New Issue