Page MenuHome

BLF: Combine blf_font_new code with _from_mem
AbandonedPublic

Authored by Harley Acheson (harley) on Aug 26 2021, 6:59 PM.

Details

Summary

Simplify FontBLF creation by combining code of blf_font_new with
blf_font_new_from_mem.


This patch fixes an error of mine, but one that has no serious effects. I have made changes to blf_font_new (D12274 & D12124) without noticing the almost identical code of blf_font_new_from_mem. This omission would mean that a font loaded from a memory pointer would not be able to use odd fonts like Wingdings. Nor would they kern, although I think all usages of this type of font loading are currently monospaced so this won't matter.

But my mistake of not noticing this would not occur had there not been two separate functions to being with. They are almost identical except for a single line so best if they share the majority of their code.

Secondly, we need to (eventually) get to a single point of font creation anyway if we implement FreeType's caching system. With that we have a single function to call to load/create faces and just a single callback where we will have to use either FT_New_Face or FT_New_Memory_Face depending on what is in the FontBLF. So this gets us closer.

And nice that this is a net removal of code lines.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Aug 26 2021, 6:59 PM
Harley Acheson (harley) created this revision.

Abandoning. Turns out that blf_font_new_from_mem() is not used at all. Will post a patch that removes it instead. Thanks Hans!