@say_1 said in How to Optimize Font Memory Usage in Qt for MCUs 2.7.1 (fontcompiler-args not supported):
Hi everyone,
I'm working on a project using Qt for MCUs 2.7.1, and I'm currently facing a memory optimization issue related to fonts.
Setup Details:
Qt version: 2.7.1 (mandatory due to customer constraint)
Toolchain: IAR
Fonts used: TTF
.qmlproject is exported using a .bat file that calls qmlprojectexporter.exe
The generated file qul_font_engines.cpp alone is taking up around 3636 KB of memory, which is too large for our current memory constraints.
My goal is to bring this down under 1000 KB if possible.
What I've Already Tried (Please Don't Suggest These Again 🙂):
--fontcompiler-args option in the .bat file:
I tried using --fontcompiler-args "--chars=0123456789"
Result: Not supported in Qt for MCUs 2.7.1 → shows Unknown options: fontcompiler-args, chars
Verified fontcompiler.exe is present in 2.7.1, but CLI option is still not supported.
Cannot upgrade to Qt 2.8.0 or later due to customer-mandated toolchain freeze.
Tried setting font size lower in QML (font.pixelSize: 16) and limited font styles (font.bold/italic: false) → helped marginally but not enough.
Started reviewing QML files to eliminate unused text/glyphs.
What I'm Looking For:
Are there any other ways in Qt for MCUs 2.7.1 to reduce the font memory footprint without relying on unsupported CLI arguments?
Is there a way to use fontCompilerOptions inside .qmlproject or .qmlprojectconfig that can limit the character set?
Can I manually run fontcompiler.exe to generate .qulfnt files and use them directly in my .qmlproject?
Any other suggestions to significantly reduce qul_font_engines.cpp size?
Any advice or experience you can share would be greatly appreciated!
Thanks in advance
— Sayali
In Qt for MCUs, since fontcompiler-args isn’t supported, the best way to reduce memory usage is to limit the glyph range to only the characters your UI actually needs. Avoid embedding multiple font weights or large Unicode sets, as each variant increases flash consumption. You can also preprocess special fonts using subsetting tools (like pyftsubset) before importing them. Keeping fallback fonts disabled and minimizing font sizes will further optimize memory usage.