From b74cc23dc478f2c4260e2e4269c8450e3d5c450e Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 5 Jun 2020 15:39:17 -0700 Subject: UI: Ability to Print Bold and Italics Adds the ability to print text in bold or italics style, synthesized from a single base UI font. Differential Revision: https://developer.blender.org/D7893 Reviewed by Brecht Van Lommel --- source/blender/blenfont/intern/blf_thumbs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenfont/intern/blf_thumbs.c') diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index 37eed29f6fe..6aa39e3aa71 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -66,6 +66,7 @@ void BLF_thumb_preview(const char *filename, int font_shrink = 4; FontBLF *font; + GlyphCacheBLF *gc; int i; /* Create a new blender font obj and fill it with default values */ @@ -96,9 +97,9 @@ void BLF_thumb_preview(const char *filename, int draw_str_i18n_nbr = 0; blf_font_size(font, (unsigned int)MAX2(font_size_min, font_size_curr), dpi); - - /* font->glyph_cache remains NULL if blf_font_size() failed to set font size */ - if (!font->glyph_cache) { + gc = blf_glyph_cache_find(font, font->size, font->dpi); + /* There will be no matching glyph cache if blf_font_size() failed to set font size. */ + if (!gc) { break; } @@ -106,7 +107,7 @@ void BLF_thumb_preview(const char *filename, font_size_curr -= (font_size_curr / font_shrink); font_shrink += 1; - font->pos[1] -= font->glyph_cache->ascender * 1.1f; + font->pos[1] -= gc->ascender * 1.1f; /* We fallback to default english strings in case not enough chars are available in current * font for given translated string (useful in non-latin i18n context, like Chinese, -- cgit v1.2.3