Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2021-08-11 23:55:58 +0300
committerHarley Acheson <harley.acheson@gmail.com>2021-08-11 23:55:58 +0300
commitcd1bb63159215396662ce49c8bc8d6d437114093 (patch)
treedb30bbf6a81ebe2a642c5da72e4017010389be65 /source/blender/blenfont
parentbb487bc2bc82c02922722efb3ca1d2570d907ad9 (diff)
BLF: Do Not Cache Unused Rendered Glyphs
The loading of a font size or style renders bitmaps of the characters 0-255 and stores them in a cache. But glyphs 128-255 in this cache are not accessible. What used to be ansi high-bit characters are now multi- byte UTF-8 sequences. Therefore this patch reduces the glyph_ascii_table size to 128 and only caches characters 32-127, the visible portion of ASCII, which greatly reduces the time to load a font. See D12189 for more details. Differential Revision: https://developer.blender.org/D12189 Reviewed by Campbell Barton
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_font.c3
-rw-r--r--source/blender/blenfont/intern/blf_internal_types.h2
2 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 6e2be4a8353..8e306730e3c 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -317,7 +317,8 @@ static GlyphBLF **blf_font_ensure_ascii_table(FontBLF *font, GlyphCacheBLF *gc)
/* build ascii on demand */
if (glyph_ascii_table['0'] == NULL) {
GlyphBLF *g;
- for (uint i = 0; i < 256; i++) {
+ /* Skip control characters and just cache rendered glyphs for visible ASCII range. */
+ for (uint i = 32; i < 128; i++) {
g = blf_glyph_search(gc, i);
if (!g) {
FT_UInt glyph_index = FT_Get_Char_Index(font->face, i);
diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h
index 36bb8769306..6816c97321d 100644
--- a/source/blender/blenfont/intern/blf_internal_types.h
+++ b/source/blender/blenfont/intern/blf_internal_types.h
@@ -71,7 +71,7 @@ typedef struct GlyphCacheBLF {
ListBase bucket[257];
/* fast ascii lookup */
- struct GlyphBLF *glyph_ascii_table[256];
+ struct GlyphBLF *glyph_ascii_table[128];
/* texture array, to draw the glyphs. */
GPUTexture *texture;