From 64e5f83133742c622e9c44b80f86d744a0dab05d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 26 Mar 2018 14:38:47 +0200 Subject: BLF: Don't use user preferences BLF is a low level module, which might (and is) used without Blender. Thanks Campbell for review! --- source/blender/blenfont/BLF_api.h | 4 ++++ source/blender/blenfont/intern/blf.c | 11 +++++++++++ source/blender/blenfont/intern/blf_glyph.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 8c8aef3de57..f31c132c973 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -33,6 +33,7 @@ #define __BLF_API_H__ #include "BLI_compiler_attrs.h" +#include "BLI_sys_types.h" struct rctf; struct ColorManagedDisplay; @@ -43,6 +44,9 @@ void BLF_exit(void); void BLF_default_dpi(int dpi); void BLF_default_set(int fontid); +void BLF_antialias_set(bool enabled); +bool BLF_antialias_get(void); + void BLF_cache_clear(void); int BLF_load(const char *name) ATTR_NONNULL(); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 5bd62980b6d..b45e52f29fd 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -84,6 +84,7 @@ static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; static int global_font_default = -1; static int global_font_points = 11; static int global_font_dpi = 72; +static bool global_use_antialias = true; /* XXX, should these be made into global_font_'s too? */ int blf_mono_font = -1; @@ -175,6 +176,16 @@ void BLF_default_set(int fontid) } } +void BLF_antialias_set(bool enabled) +{ + global_use_antialias = enabled; +} + +bool BLF_antialias_get(void) +{ + return global_use_antialias; +} + int BLF_load(const char *name) { FontBLF *font; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 24a75d667ef..c90e60bd6ef 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -218,7 +218,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) GlyphBLF *g; FT_Error err; FT_Bitmap bitmap, tempbitmap; - const bool is_sharp = (U.text_render & USER_TEXT_DISABLE_AA) != 0; + const bool is_sharp = !BLF_antialias_get(); int flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; FT_BBox bbox; unsigned int key; -- cgit v1.2.3