ab_glyph titles will read the system title font using memory mapped buffers instead of reading to heap.
This lowers RAM usage of the since previously the system font would be saved in heap. For some system fonts this can be quite large and undesirable for rendering a title.
The disadvantage is currently the font must be parsed before each use instead of once at startup. It may be possible to improve this later with https://github.com/alexheretic/owned-ttf-parser/issues/11. In any case on my system render() time is relatively unaffected at 50-100µs so this doesn't seem a deal breaker.
Tests
My system title font is Cantarell-VF.otf (167K). Running the cargo run --example simple --release
Before: 570-720K memory
After: 400-550K memory
If I choose NotoSerifCJK-Bold.ttc (27M). Running the cargo run --example simple --release
Before: 27.8-27.9M memory
After: 400-550K memory
Bonus
I've also improved the FontPreference parsing so it can handle config like Noto Serif CJK HK Bold 12 as I noticed that wasn't working properly when I wanted to test it.
ab_glyph
titles will read the system title font using memory mapped buffers instead of reading to heap.This lowers RAM usage of the since previously the system font would be saved in heap. For some system fonts this can be quite large and undesirable for rendering a title.
The disadvantage is currently the font must be parsed before each use instead of once at startup. It may be possible to improve this later with https://github.com/alexheretic/owned-ttf-parser/issues/11. In any case on my system
render()
time is relatively unaffected at 50-100µs so this doesn't seem a deal breaker.Tests
My system title font is Cantarell-VF.otf (167K). Running the
cargo run --example simple --release
If I choose NotoSerifCJK-Bold.ttc (27M). Running the
cargo run --example simple --release
Bonus
I've also improved the
FontPreference
parsing so it can handle config likeNoto Serif CJK HK Bold 12
as I noticed that wasn't working properly when I wanted to test it.Resolves #17