ImFontAtlasBuildWithStbTrueType assertion with Gcc 13+ #7856

Closed
opened 2024-08-03 10:18:56 +00:00 by smallstepforman · 0 comments
smallstepforman commented 2024-08-03 10:18:56 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

v1.91.1

Back-ends:

OpenGL / glfw3

Compiler, OS:

gcc 13.2 and higher

Full config/build information:

No response

Details:

With older Gcc compilers (11, 12) and with VS 2022, I have working code which appends a range of glyphs to StbTruetype. Using gcc compiler 13 and 14, I get an assertion in imgui_draw.cpp:2819 bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas *) Assertion 'src_range[0] <= src_range[1]' failed.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

static const ImWchar kAdditionalUnicodeChars[] =
	{
		0x00a1/*¡*/, 0x00a2/*¢*/, 0x00a9/*©*/, 0x00ae/*®*/, 0x00b1/*±*/, 0x00bf/*¿*/, 0x00c3/*Ã*/, 0x00c9/*É*/, 0x00cd/*Í*/, 0x00d1/*Ñ*/,
		0x00d3/*Ó*/, 0x00da/*Ú*/, 0x00e1/*á*/, 0x00e9/*é*/, 0x00ed/*í*/, 0x00f1/*ñ*/, 0x00f3/*ó*/, 0x00fa/*ú*/, 0x0e3f/*฿*/, 0x2018/*‘*/,
		0x2019/*’*/, 0x201b/*‛*/, 0x201c/*“*/, 0x20ac/*€*/, 0x20b1/*₱*/, 0x2122/*™*/,
	};
	fFonts[0] = io.Fonts->AddFontFromFileTTF("../../Resources/ProximaNova-Regular.ttf", 48);
	fFonts[1] = io.Fonts->AddFontFromFileTTF("../../Resources/ProximaNova-Regular.ttf", 32);
	fFonts[2] = io.Fonts->AddFontFromFileTTF("../../Resources/DejaVuSerif.ttf", 28, &config, kAdditionalUnicodeChars);  // Crashes here with Gcc 13/14, but works fine with VS2022 and GCC 11/12.
### Version/Branch of Dear ImGui: v1.91.1 ### Back-ends: OpenGL / glfw3 ### Compiler, OS: gcc 13.2 and higher ### Full config/build information: _No response_ ### Details: With older Gcc compilers (11, 12) and with VS 2022, I have working code which appends a range of glyphs to StbTruetype. Using gcc compiler 13 and 14, I get an assertion in imgui_draw.cpp:2819 bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas *) Assertion 'src_range[0] <= src_range[1]' failed. ### Screenshots/Video: _No response_ ### Minimal, Complete and Verifiable Example code: ```cpp static const ImWchar kAdditionalUnicodeChars[] = { 0x00a1/*¡*/, 0x00a2/*¢*/, 0x00a9/*©*/, 0x00ae/*®*/, 0x00b1/*±*/, 0x00bf/*¿*/, 0x00c3/*Ã*/, 0x00c9/*É*/, 0x00cd/*Í*/, 0x00d1/*Ñ*/, 0x00d3/*Ó*/, 0x00da/*Ú*/, 0x00e1/*á*/, 0x00e9/*é*/, 0x00ed/*í*/, 0x00f1/*ñ*/, 0x00f3/*ó*/, 0x00fa/*ú*/, 0x0e3f/*฿*/, 0x2018/*‘*/, 0x2019/*’*/, 0x201b/*‛*/, 0x201c/*“*/, 0x20ac/*€*/, 0x20b1/*₱*/, 0x2122/*™*/, }; fFonts[0] = io.Fonts->AddFontFromFileTTF("../../Resources/ProximaNova-Regular.ttf", 48); fFonts[1] = io.Fonts->AddFontFromFileTTF("../../Resources/ProximaNova-Regular.ttf", 32); fFonts[2] = io.Fonts->AddFontFromFileTTF("../../Resources/DejaVuSerif.ttf", 28, &config, kAdditionalUnicodeChars); // Crashes here with Gcc 13/14, but works fine with VS2022 and GCC 11/12. ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#7856
No description provided.