[Bf-blender-cvs] [18888b7b0c3] master: UI: use text hinting (now user preference)

Campbell Barton noreply at git.blender.org
Tue Jul 31 08:19:00 CEST 2018


Commit: 18888b7b0c3556d3a2177fe7693fda02bf2a8cb5
Author: Campbell Barton
Date:   Tue Jul 31 16:05:31 2018 +1000
Branches: master
https://developer.blender.org/rB18888b7b0c3556d3a2177fe7693fda02bf2a8cb5

UI: use text hinting (now user preference)

D3201 by @ambient w/ edits not to impact fonts used for rendering
(only change display for UI text).

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/interface/interface_style.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index ee1dcae29a1..e0902dd8636 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -539,6 +539,8 @@ class USERPREF_PT_system(Panel):
 
         col.label(text="Text Draw Options:")
         col.prop(system, "use_text_antialiasing")
+        if system.use_text_antialiasing:
+            col.prop(system, "use_text_hinting")
 
         col.separator()
 
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index eabc5150424..9a09ae67601 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -521,6 +521,28 @@ void uiStyleInit(void)
 
 	BLF_size(blf_mono_font, 12 * U.pixelsize, 72);
 
+	/* Set default flags based on UI preferences (not render fonts) */
+	{
+		int flag_enable = 0, flag_disable = 0;
+		if ((U.text_render & USER_TEXT_DISABLE_HINTING) == 0) {
+			flag_enable |= BLF_HINTING;
+		}
+		else {
+			flag_disable |= BLF_HINTING;
+		}
+
+		for (font = U.uifonts.first; font; font = font->next) {
+			if (font->blf_id != -1) {
+				BLF_enable(font->blf_id, flag_enable);
+				BLF_disable(font->blf_id, flag_disable);
+			}
+		}
+		if (blf_mono_font != -1) {
+			BLF_enable(blf_mono_font, flag_enable);
+			BLF_disable(blf_mono_font, flag_disable);
+		}
+	}
+
 	/**
 	 * Second for rendering else we get threading problems,
 	 *
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 2d52c1a67de..6f0f97261ee 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -804,7 +804,8 @@ typedef enum eWM_DrawMethod {
 /* text draw options
  * UserDef.text_render */
 typedef enum eText_Draw_Options {
-	USER_TEXT_DISABLE_AA	= (1 << 0),
+	USER_TEXT_DISABLE_AA	  = (1 << 0),
+	USER_TEXT_DISABLE_HINTING = (1 << 1),
 } eText_Draw_Options;
 
 /* tw_flag (transform widget) */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 487f62cdfe6..739303e20ea 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -447,6 +447,7 @@ static void rna_userdef_temp_update(Main *UNUSED(bmain), Scene *UNUSED(scene), P
 static void rna_userdef_text_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
 {
 	BLF_cache_clear();
+	UI_reinit_font();
 	WM_main_add_notifier(NC_WINDOW, NULL);
 }
 
@@ -4212,6 +4213,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Text Anti-aliasing", "Draw user interface text anti-aliased");
 	RNA_def_property_update(prop, 0, "rna_userdef_text_antialiasing_update");
 
+	prop = RNA_def_property(srna, "use_text_hinting", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "text_render", USER_TEXT_DISABLE_HINTING);
+	RNA_def_property_ui_text(prop, "Text Hinting", "Draw user interface text with hinting");
+	RNA_def_property_update(prop, 0, "rna_userdef_text_update");
+
 	prop = RNA_def_property(srna, "select_method", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "gpu_select_method");
 	RNA_def_property_enum_items(prop, gpu_select_method_items);



More information about the Bf-blender-cvs mailing list