Open N1ceL opened 4 years ago
Hello,
With FreeType you can use only same flags on every font. I think better to delete "extra_flags" ... And change: if (!font_face.InitFont(ft_library, cfg, extra_flags)) to if (!font_face.InitFont(ft_library, cfg, cfg.RasterizerFlags))
I don't think that's correct, InitFont()
already does:
UserFlags = cfg.RasterizerFlags | extra_user_flags;
So if you leave extra_user_flags
to zero so you can configure flags for each font separately.
- FreeType and IsDirty().
You are referring to a wip/experimental branch commits those are not supported as this point, I don't think shadows rebuilt have been tested with FreeType yet, we were focused with designing the back-end side protocol. We'll look at this part eventually.
- Error in fonts. I think better to delete error here https://github.com/ocornut/imgui/blob/master/imgui_draw.cpp#L1903
I don't know what this line is referring to (best to copy the code line) but I assume you mean the IM_ASSERT_USER_ERROR(0, "Could not load font file!");
error. I agree and think we could add a config flags to disable this assert. However your app can still test for file existence if it wants to dynamically select font.
- It would be good to add one more variable to ImFontConfig struct.
Yes-ish, when we support dynamic rebuild I think we'll prefer to keep font data in memory so that shouldn't be a real issue.
Will look at all those in details later, thanks for the feedback!
With FreeType you can use only same flags on every font. I think better to delete "extra_flags" from here https://github.com/ocornut/imgui/blob/master/misc/freetype/imgui_freetype.cpp#L651-L673 and here https://github.com/ocornut/imgui/blob/master/misc/freetype/imgui_freetype.cpp#L323 And change:
if (!font_face.InitFont(ft_library, cfg, extra_flags))
toif (!font_face.InitFont(ft_library, cfg, cfg.RasterizerFlags))
here https://github.com/ocornut/imgui/blob/master/misc/freetype/imgui_freetype.cpp#L362FreeType and IsDirty(). FreeType fonts conflicts with IsDirty() here (imgui with shadows): https://github.com/ocornut/imgui/blob/features/shadows/imgui_draw.cpp#L2635 https://github.com/ocornut/imgui/blob/features/shadows/imgui_draw.cpp#L2656 Removing these functions from the checks helps.
Error in fonts. I think better to delete error here https://github.com/ocornut/imgui/blob/master/imgui_draw.cpp#L1903 Because its better to go the way of installing a different font if the first one is not found.
It would be good to add one more variable to ImFontConfig struct. char FontPath[256]; //// memcpy(font_cfg.FontPath, filename+ '\x0', strlen(filename) + 1); This struct has all the data needed to rebuild the font except FontPath.
Somthings to ImFontConfig.
This can be used for font rebuilding (because rebuilded FontData saves repeatedly and after a certain number of rebuild program eats 1.5 GB of RAM, originally it was 40 MB)
I hope I was able to help a little with something. https://i.imgur.com/qdBhvqQ.mp4