imgui中文字体库导入乱码问题
1.中文字体库导入乱码问题
1.修改clion中的文件编码配置
2.按住 Ctrl+Shift+Alt+/,选中Registry…,然后取消run.processes.with.pty
3.cmakelist.txt导入字体文件,注意不要加u8了,不然会乱码
#字体文件
include_directories(
${PROJECT_SOURCE_DIR}/include/fonts
)
然后main.cpp文件中:
// 使用内存加载字体
ImFont* font = io.Fonts->AddFontFromMemoryTTF((void*)AlimamaFangYuan_data, AlimamaFangYuan_size, 22.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
if (!font) {
std::cerr << "Failed to load font." << std::endl;
} else {
std::cout << "Font loaded successfully." << std::endl;
std::cout << "测试中文输出" << std::endl;
}