diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-26 15:38:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-03-26 15:49:23 +0300 |
commit | 64e5f83133742c622e9c44b80f86d744a0dab05d (patch) | |
tree | 5d8848008f01c0aa788e3965f4ada84b6ce0dc12 /source | |
parent | 0476f8277ad58f99dd1ff213496c870d9c29f5d5 (diff) |
BLF: Don't use user preferences
BLF is a low level module, which might (and is) used without Blender.
Thanks Campbell for review!
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenfont/BLF_api.h | 4 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf.c | 11 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 4 |
5 files changed, 27 insertions, 2 deletions
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; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 0496de4dd6a..d813c095589 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -450,6 +450,12 @@ static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P WM_main_add_notifier(NC_WINDOW, NULL); } +static void rna_userdef_text_antialiasing_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + BLF_antialias_set((U.text_render & USER_TEXT_DISABLE_AA) == 0); + rna_userdef_text_update(bmain, scene, ptr); +} + static PointerRNA rna_Theme_space_generic_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceGeneric, ptr->data); @@ -4209,7 +4215,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "use_text_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "text_render", USER_TEXT_DISABLE_AA); RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased"); - RNA_def_property_update(prop, 0, "rna_userdef_text_update"); + RNA_def_property_update(prop, 0, "rna_userdef_text_antialiasing_update"); prop = RNA_def_property(srna, "select_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "gpu_select_method"); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 7df6deaecf6..e0b57effbe9 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -62,6 +62,8 @@ #include "BLT_translation.h" +#include "BLF_api.h" + #include "DNA_mesh_types.h" /* only for USE_BMESH_SAVE_AS_COMPAT */ #include "DNA_object_types.h" #include "DNA_space_types.h" @@ -339,6 +341,8 @@ static void wm_init_userdef(Main *bmain, const bool read_userdef_from_memory) /* update tempdir from user preferences */ BKE_tempdir_init(U.tempdir); + + BLF_antialias_set((U.text_render & USER_TEXT_DISABLE_AA) == 0); } |