This patch removes the need to lock the thread just to get to some
generic (not glyph-specific) font metrics.
For performance reasons we keep font glyphs in per-size caches in each font. For thread safety we bracket each access to GlyphCacheBLF with calls to blf_glyph_cache_acquire and blf_glyph_cache_release which set and release a spinlock.
However we do this unnecessarily when we just need font metrics that are not glyph specific. In these cases we now lock, find the cache that matches the current size, get a value we have previously saved, unlock.
But for the font metrics in this patch these values are exactly the same as can be found in the font->face directly as these are the current font metrics. There isn't a need to look in the cache and therefore no need to lock it. So for the following this is a matter of removing the saved value from GlyphCacheBLF and moving the code directly to where it is required:
- blf_font_height_max
- blf_font_width_max
- blf_font_descender
- blf_font_ascender
For blf_font_fixed_width we seem to call that a lot, so for this I added a member to FontBLF to cache this called fixed_width which is set only on blf_font_size. This is set a bit better than current code in that it gets the character advance without ever rendering it. And it uses the width of "0" rather than space, which is preferred behavior (CSS 'ch' width), falling back to 1/2 of an em if the font does not contain '0' (also CSS 'ch' recommendation). Of course this width is identical to current width for all monospaced fonts, but could come in handy if we ever want to mix in glyphs from proportional fonts (fallback).
Note that this patch also removes any use of blf_glyph_search outside of blf_glyph.c so this makes it static.