- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用 ImGui 作为前端的小脚本上开发翻译。我需要扩展的 unicode 字符集以在将要使用的字体中可用。由于此脚本是通过 DLL 注入(inject)的,因此无法使用(我认为是。我完全没有使用 C++ 的经验。):
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
从ttf文件添加字体导致数据== NULL的错误;
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
if (!data)
{
IM_ASSERT(0); // Could not load file.
return NULL;
}
我也尝试过使用 io.Fonts->AddFontFromMemoryCompressedBase85TTF 并通过包含的 binary_to_compressed_c 编译字体,但输出太大以至于我得到:
fatal error C1091: compiler limit: string exceeds 65535 bytes in length
但是函数不接受除 char* 之外的任何类型。我正在将字符连接成字符串,然后通过 str() 和 c_str() 重新组装它,但应用程序在注入(inject)后崩溃了。这是从 ImGui 处理 base85 转换的函数:
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
{
int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
void* compressed_ttf = ImGui::MemAlloc((size_t)compressed_ttf_size);
Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges);
ImGui::MemFree(compressed_ttf);
return font;
}
我该如何解决这个问题?我已经尝试了一切,但没有任何效果。只有将较小的字符传递给编译函数才有效(尝试使用捆绑的 Cousine_Regular.ttf)。
最佳答案
我已经找到了这个问题的解决方法。如果你真的需要使用 BASE85,仍然没有答案,但你可以通过转换为 int 类型来增加大小限制(不要将 -base85 放在 binary_to_compressed_c.exe 中)然后将结果表插入头文件并使用 ImGui 提供的说明,如下所示:
头文件:
// File: 'DroidSans.ttf' (190044 bytes)
// Exported using binary_to_compressed_c.cpp
static const unsigned int droid_compressed_size = 134345;
static const unsigned int droid_compressed_data[134348 / 4] =
您的导入/渲染文件:
static const ImWchar ranges[] = { 0x0020, 0x00FF, 0x0100, 0x017F, 0 };
//Because I need extended characters im passing my array to function.
io.Fonts->AddFontFromMemoryCompressedTTF(droid_compressed_data, droid_compressed_size, 16.0f, NULL, ranges);
这就解决了从 string 转换为 char 以及其他与 base85 导入相关的问题。
关于c++ - 在 ImGui 中嵌入大于字符大小的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48939406/
我在一个涉及打开多个窗口的项目中使用 GLFW 和 ImGui。到目前为止,我已经进行了设置,以便每次必须打开一个新窗口时,我都会生成一个线程来创建自己的 GLFW 窗口和 OpenGL 上下文。线程
我正在 ImGui 中创建文本。它会自动右对齐,我如何让一个文本在中心对齐? ImGui::Text("Example Text"); 我不相信有一个功能可以做到这一点。我知道你可以为一个盒子或小部件
我想在dear imgui的窗口中创建一个带有图标和文字的按钮,但是没有找到相关的界面。 enter image description here 最佳答案 你可以看看 iconfont https:
ImGui::GetWindowDrawList()->AddRect(ImVec2(ModelEspInfo[i].pOutX, ModelEspInfo[i].pOutY), 5750 / Mod
假设我创建了一个包含以下内容的表: ImGui::Columns(3); ImGui::Text("Header 1"); ImGui::NextColumn(); ImGui::Text("Head
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我在使用 ImGui 作为前端的小脚本上开发翻译。我需要扩展的 unicode 字符集以在将要使用的字体中可用。由于此脚本是通过 DLL 注入(inject)的,因此无法使用(我认为是。我完全没有使用
如何制作 Dear ImGui - 创建的窗口完全适合“背景”?我的意思是当我们创建一个窗口时,它也在一些渲染场景或背景中。我想模仿 Qt 等其他框架创建的窗口,使其更像桌面应用程序,而不仅仅是在某些
是否可以使用“dear imgui”让两个按钮具有相同的按钮文本? 因为生成两个或多个 ImGui::Button("PRESS") 将导致只有第一个对选择使用react(在 GCC/Win64/Mi
我有一个使用 OpenGL 创建的 960x540 窗口。在这里渲染一个纹理并使用 imgui实现一个 slider ,让我在运行时转换 x、y 和 z 位置。 int window_width =
如何使用 dear imgui 填充两条贝塞尔曲线之间的区域? 我使用 ImDrawList API 绘制曲线,如下所示: ImVec2 p0(10, 100); ImVec2 c1(
我正在学习 TheCherno 的 OpenGL 教程(尽管我已经继续并修改了一些内容)。我在 MacOS mojave 上使用 OpenGL 2.1。然而,当我到达教程的 ImGui 部分时,事情开
我完成了基于 Dear ImGui DrawList 渲染 2d 对象的类,因为它可以绘制许多不同的对象变体,这要归功于索引 vector 动态数组并且仍然保持良好的优化。亲爱的 ImGui 可以渲染
目前,如果我的窗口足够小,我的 Dear ImGui 应用程序(主要是带有一些自定义 OpenGL 渲染的演示窗口)运行速度约为 2000 fps。如何将其限制为显示器刷新率(甚至仅为 60fps)?
对 ImGui::InputText() 的调用需要一个 char 数组,我需要从 std::string 初始化该数组,然后将内容传输回 std::string。最简单的形式: char buf[2
我是 ImGui 库的新手,最近我一直在试用其中包含的示例。在我将 gl3w 的 include(和函数)更改为 glad(我想使用的加载器)之前,一切都很顺利。当我在两个加载器之间交换时,我在 im
我正在尝试使用 Dear IMGUI 为 DirectX 12 游戏制作一个简单的帧计数器。我只是想覆盖一个小的透明窗口,在游戏过程中显示帧的顺序。为此,我 Hook Present(),所以我可以得
在 imgui 中,您可以设置键码以供以后查找,看起来像 io.KeyMap[ImGuiKey_Enter] = WXK_RETURN; 我该怎么做 io.KeyMap[ImGuiKey_Enter]
我使用以下命令在 Windows 10 上安装了 Dear ImGui: vcpkg install imgui:x64-windows 仅安装: imgui[core]:x64-windows ->
我是一名优秀的程序员,十分优秀!