AndroidSurfaceImgui
AndroidSurfaceImgui copied to clipboard
设置字体问题
貌似设置字体有点问题 #include "Global.h" #include "AImGui.h" #include "font_data.h"
#include
int main() { android::AImGui imgui(android::AImGui::Options { .renderType = android::AImGui::RenderType::RenderNative, .autoUpdateOrientation = true });
ImGuiIO& io = ImGui::GetIO();
ImFont *font = io.Fonts->AddFontFromMemoryTTF(
(void*) _binary_font_ttf_start,
_binary_font_ttf_end - _binary_font_ttf_start,
24.0f,
nullptr,
io.Fonts->GetGlyphRangesChineseSimplifiedCommon()
);
IM_ASSERT(font != nullptr);
if (!imgui) {
LogInfo("[-] ImGui initialization failed");
return -1;
}
bool state = true;
std::thread processInputEventThread(
[&] {
while (state) {
imgui.ProcessInputEvent();
}
}
);
while (state) {
imgui.BeginFrame();
{
ImGui::Begin("Hello, world!", &state);
ImGui::Text("你好");
ImGui::End();
}
imgui.EndFrame();
}
if (processInputEventThread.joinable()) {
processInputEventThread.join();
}
return 0;
} 这是代码 用的是内存字体 内存字体测试过是没有问题的 在原版imgui是可以正常设置的
改成这样试试
ImGuiIO& io = ImGui::GetIO();
ImFont *font = io.Fonts->AddFontFromMemoryTTF(
(void*) _binary_font_ttf_start,
_binary_font_ttf_end - _binary_font_ttf_start,
24.0f,
nullptr,
io.Fonts->GetGlyphRangesChineseSimplifiedCommon()
);
IM_ASSERT(font != nullptr);
io.FontDefault = font;
io.Fonts->Build();
LogDebug("Font: %p", font);
LogDebug("Font size: %f", font->FontSize);
LogDebug("Font name: %s", font->GetDebugName());
LogDebug("Font size: %d", font->Glyphs.Size);
@Bzi-Han 可以了 谢谢大佬