UI: Allow Separate Configuration of Subpixel Antialiasing

Separate user configuration of subpixel antialiasing from the hinting
options. For example, this allows turning this on while hinting is
"None", or off when hinting is "Full".

Pull Request: https://projects.blender.org/blender/blender/pulls/113027
This commit is contained in:
Harley Acheson
2023-09-29 19:02:25 +02:00
committed by Harley Acheson
parent cfde3973d1
commit 82bfc41d0c
8 changed files with 22 additions and 4 deletions
+1
View File
@@ -235,6 +235,7 @@ class USERPREF_PT_interface_text(InterfacePanel, CenterAlignMixIn, Panel):
flow.prop(view, "use_text_antialiasing", text="Anti-Aliasing")
sub = flow.column()
sub.active = view.use_text_antialiasing
sub.prop(view, "use_text_render_subpixelaa", text="Subpixel Anti-Aliasing")
sub.prop(view, "text_hinting", text="Hinting")
flow.prop(view, "font_path_ui")
+2
View File
@@ -349,6 +349,8 @@ enum {
BLF_BAD_FONT = 1 << 16,
/** This font is managed by the FreeType cache subsystem. */
BLF_CACHED = 1 << 17,
/** At small sizes glyphs are rendered at multiple subpixel positions. */
BLF_RENDER_SUBPIXELAA = 1 << 18,
};
#define BLF_DRAW_STR_DUMMY_MAX 1024
+2 -2
View File
@@ -1121,8 +1121,8 @@ GlyphBLF *blf_glyph_ensure(FontBLF *font, GlyphCacheBLF *gc, const uint charcode
#ifdef BLF_SUBPIXEL_AA
GlyphBLF *blf_glyph_ensure_subpixel(FontBLF *font, GlyphCacheBLF *gc, GlyphBLF *g, int32_t pen_x)
{
if ((font->flags & (BLF_HINTING_NONE | BLF_MONOCHROME)) != 0) {
/* Not if we are in mono mode (aliased) or if not hinting. */
if (!(font->flags & BLF_RENDER_SUBPIXELAA) || (font->flags & BLF_MONOCHROME)) {
/* Not if we are in mono mode (aliased) or the feature is turned off. */
return g;
}
@@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 31
#define BLENDER_FILE_SUBVERSION 32
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
@@ -881,6 +881,10 @@ void blo_do_versions_userdef(UserDef *userdef)
userdef->animation_flag |= USER_ANIM_SHOW_CHANNEL_GROUP_COLORS;
}
if (!USER_VERSION_ATLEAST(400, 32)) {
userdef->text_render |= USER_TEXT_RENDER_SUBPIXELAA;
}
/**
* Versioning code until next subversion bump goes here.
*
@@ -440,7 +440,7 @@ void uiStyleInit()
/* Set default flags based on UI preferences (not render fonts) */
{
const int flag_disable = (BLF_MONOCHROME | BLF_HINTING_NONE | BLF_HINTING_SLIGHT |
BLF_HINTING_FULL);
BLF_HINTING_FULL | BLF_RENDER_SUBPIXELAA);
int flag_enable = 0;
if (U.text_render & USER_TEXT_HINTING_NONE) {
@@ -456,6 +456,9 @@ void uiStyleInit()
if (U.text_render & USER_TEXT_DISABLE_AA) {
flag_enable |= BLF_MONOCHROME;
}
if (U.text_render & USER_TEXT_RENDER_SUBPIXELAA) {
flag_enable |= BLF_RENDER_SUBPIXELAA;
}
LISTBASE_FOREACH (uiFont *, font, &U.uifonts) {
if (font->blf_id != -1) {
@@ -1338,6 +1338,8 @@ typedef enum eText_Draw_Options {
USER_TEXT_HINTING_NONE = (1 << 1),
USER_TEXT_HINTING_SLIGHT = (1 << 2),
USER_TEXT_HINTING_FULL = (1 << 3),
USER_TEXT_RENDER_SUBPIXELAA = (1 << 4),
} eText_Draw_Options;
/**
@@ -5180,6 +5180,12 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop, "Text Anti-Aliasing", "Smooth jagged edges of user interface text");
RNA_def_property_update(prop, 0, "rna_userdef_text_update");
prop = RNA_def_property(srna, "use_text_render_subpixelaa", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "text_render", USER_TEXT_RENDER_SUBPIXELAA);
RNA_def_property_ui_text(
prop, "Text Subpixel Anti-Aliasing", "Render text for optimal horizontal placement");
RNA_def_property_update(prop, 0, "rna_userdef_text_update");
prop = RNA_def_property(srna, "text_hinting", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "text_render");
RNA_def_property_enum_items(prop, text_hinting_items);