Imgui: [Emscripten] Problem Loading Fonts

Created on 17 Jan 2020  路  4Comments  路  Source: ocornut/imgui

Hi, I'm getting this error:
Assertion failed: (0) && "Could not load font file!", at: imgui_draw.cpp,1716,AddFontFromFileTTF

I have added a font in fonts folder beside the main.cpp file and compiled with
--preload-file fonts

set it with
ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);

emcc produced the .data file

also these options are not set or present
-s NO_FILESYSTEM=1 -DIMGUI_DISABLE_FILE_FUNCTIONS

font loads on Windows, having problems with Emscripten.

Most helpful comment

All 4 comments

However issue also exists in emscripten example. I will look into it.

Thanks. The PR by @Oipo solves it, just curious about what the @font is for in the preload asset option.

@wini3d emscripten follows the convention of localdir@asset_file_dir. So the @/fonts part tells emscripten to place the misc/fonts directory at /fonts in the virtual filesystem. Loading it from the executable then requires using the /fonts path.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DarkLinux picture DarkLinux  路  3Comments

namuda picture namuda  路  3Comments

BlackWatersInc picture BlackWatersInc  路  3Comments

bizehao picture bizehao  路  3Comments

dowit picture dowit  路  3Comments