[Bf-blender-cvs] [feaa61a9680] master: UI: Remove "Unfitted" Kerning Style Option

Harley Acheson noreply at git.blender.org
Thu Aug 19 04:49:43 CEST 2021


Commit: feaa61a9680844d0fdc5b9b1a1407819fbb6dc97
Author: Harley Acheson
Date:   Wed Aug 18 19:48:30 2021 -0700
Branches: master
https://developer.blender.org/rBfeaa61a9680844d0fdc5b9b1a1407819fbb6dc97

UI: Remove "Unfitted" Kerning Style Option

This patch removes the "Kerning Style" option for UI widget font
drawing and uses only the current default of "Fitted", since the other
option of "Unfitted" is just the result of truncation errors.

see D12231 for much more information.

Differential Revision: https://developer.blender.org/D12231

Reviewed by Campbell Barton

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

M	source/blender/blenfont/BLF_api.h
M	source/blender/blenfont/intern/blf_font.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_tooltip.c
M	source/blender/editors/interface/interface_style.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/python/generic/blf_py_api.c

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

diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index 7e92f79a523..eb3f9805240 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -271,7 +271,7 @@ void BLF_state_print(int fontid);
 #define BLF_ROTATION (1 << 0)
 #define BLF_CLIPPING (1 << 1)
 #define BLF_SHADOW (1 << 2)
-#define BLF_KERNING_DEFAULT (1 << 3)
+// #define BLF_FLAG_UNUSED_3 (1 << 3) /* dirty */
 #define BLF_MATRIX (1 << 4)
 #define BLF_ASPECT (1 << 5)
 #define BLF_WORD_WRAP (1 << 6)
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index d9396bd0f90..36eca3c00e6 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -355,9 +355,7 @@ BLI_INLINE GlyphBLF *blf_utf8_next_fast(
 
 #define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode) \
   const bool _has_kerning = FT_HAS_KERNING((_font)->face); \
-  const FT_UInt _kern_mode = (_has_kerning && !((_font)->flags & BLF_KERNING_DEFAULT)) ? \
-                                 FT_KERNING_UNFITTED : \
-                                 FT_KERNING_DEFAULT;
+  const FT_UInt _kern_mode = FT_KERNING_DEFAULT;
 
 BLI_INLINE void blf_kerning_step_fast(FontBLF *font,
                                       const FT_UInt kern_mode,
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6f2232fabe5..b8f324cba83 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3086,11 +3086,6 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
 
   UI_fontstyle_set(&fstyle);
 
-  if (fstyle.kerning == 1) {
-    /* for BLF_width */
-    BLF_enable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   ui_but_text_password_hide(password_str, but, false);
 
   if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) {
@@ -3141,10 +3136,6 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
     but->pos = glyph_data[1] + but->ofs;
   }
 
-  if (fstyle.kerning == 1) {
-    BLF_disable(fstyle.uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   ui_but_text_password_hide(password_str, but, true);
 }
 
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 97d01ac3763..a64797af24f 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1447,10 +1447,6 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
 
   is_alpha = (region->overlap && (theme_col_back[3] != 255));
 
-  if (fstyle->kerning == 1) {
-    BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   BLF_enable(fontid, BLF_ROTATION);
   BLF_rotation(fontid, M_PI_2);
   // UI_fontstyle_set(&style->widget);
@@ -1620,10 +1616,6 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
   GPU_line_smooth(false);
 
   BLF_disable(fontid, BLF_ROTATION);
-
-  if (fstyle->kerning == 1) {
-    BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
 }
 
 #undef TABS_PADDING_BETWEEN_FACTOR
diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c
index 10bc3760b42..a8f289702f8 100644
--- a/source/blender/editors/interface/interface_region_tooltip.c
+++ b/source/blender/editors/interface/interface_region_tooltip.c
@@ -1175,9 +1175,6 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
   data->wrap_width = min_ii(UI_TIP_MAXWIDTH * U.pixelsize / aspect, winx - (UI_TIP_PADDING * 2));
 
   font_flag |= BLF_WORD_WRAP;
-  if (data->fstyle.kerning == 1) {
-    font_flag |= BLF_KERNING_DEFAULT;
-  }
   BLF_enable(data->fstyle.uifont_id, font_flag);
   BLF_enable(blf_mono_font, font_flag);
   BLF_wordwrap(data->fstyle.uifont_id, data->wrap_width);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 88ab6a377d0..804156ba48c 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -83,7 +83,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
 
   style->paneltitle.uifont_id = uifont_id;
   style->paneltitle.points = UI_DEFAULT_TITLE_POINTS;
-  style->paneltitle.kerning = 1;
   style->paneltitle.shadow = 3;
   style->paneltitle.shadx = 0;
   style->paneltitle.shady = -1;
@@ -92,7 +91,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
 
   style->grouplabel.uifont_id = uifont_id;
   style->grouplabel.points = UI_DEFAULT_TITLE_POINTS;
-  style->grouplabel.kerning = 1;
   style->grouplabel.shadow = 3;
   style->grouplabel.shadx = 0;
   style->grouplabel.shady = -1;
@@ -101,7 +99,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
 
   style->widgetlabel.uifont_id = uifont_id;
   style->widgetlabel.points = UI_DEFAULT_TEXT_POINTS;
-  style->widgetlabel.kerning = 1;
   style->widgetlabel.shadow = 3;
   style->widgetlabel.shadx = 0;
   style->widgetlabel.shady = -1;
@@ -110,7 +107,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
 
   style->widget.uifont_id = uifont_id;
   style->widget.points = UI_DEFAULT_TEXT_POINTS;
-  style->widget.kerning = 1;
   style->widget.shadow = 1;
   style->widget.shady = -1;
   style->widget.shadowalpha = 0.5f;
@@ -164,9 +160,6 @@ void UI_fontstyle_draw_ex(const uiFontStyle *fs,
     BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
     BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
   }
-  if (fs->kerning == 1) {
-    font_flag |= BLF_KERNING_DEFAULT;
-  }
   if (fs_params->word_wrap == 1) {
     font_flag |= BLF_WORD_WRAP;
   }
@@ -278,19 +271,12 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs,
     BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
   }
 
-  if (fs->kerning == 1) {
-    BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
   BLF_disable(fs->uifont_id, BLF_ROTATION);
   BLF_disable(fs->uifont_id, BLF_CLIPPING);
   if (fs->shadow) {
     BLF_disable(fs->uifont_id, BLF_SHADOW);
   }
-  if (fs->kerning == 1) {
-    BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
 }
 
 /**
@@ -302,18 +288,10 @@ void UI_fontstyle_draw_rotated(const uiFontStyle *fs,
 void UI_fontstyle_draw_simple(
     const uiFontStyle *fs, float x, float y, const char *str, const uchar col[4])
 {
-  if (fs->kerning == 1) {
-    BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   UI_fontstyle_set(fs);
   BLF_position(fs->uifont_id, x, y, 0.0f);
   BLF_color4ubv(fs->uifont_id, col);
   BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
-
-  if (fs->kerning == 1) {
-    BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
 }
 
 /**
@@ -326,10 +304,6 @@ void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
                                        const float col_fg[4],
                                        const float col_bg[4])
 {
-  if (fs->kerning == 1) {
-    BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   UI_fontstyle_set(fs);
 
   {
@@ -357,10 +331,6 @@ void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
   BLF_position(fs->uifont_id, x, y, 0.0f);
   BLF_color4fv(fs->uifont_id, col_fg);
   BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
-
-  if (fs->kerning == 1) {
-    BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
 }
 
 /* ************** helpers ************************ */
@@ -405,21 +375,8 @@ const uiStyle *UI_style_get_dpi(void)
 
 int UI_fontstyle_string_width(const uiFontStyle *fs, const char *str)
 {
-  int width;
-
-  if (fs->kerning == 1) {
-    /* for BLF_width */
-    BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   UI_fontstyle_set(fs);
-  width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
-
-  if (fs->kerning == 1) {
-    BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
-  return width;
+  return (int)BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
 }
 
 int UI_fontstyle_height_max(const uiFontStyle *fs)
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index d3481c449ac..48f638dac33 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1576,11 +1576,6 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
   /* need to set this first */
   UI_fontstyle_set(fstyle);
 
-  if (fstyle->kerning == 1) {
-    /* for BLF_width */
-    BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   float strwidth = BLF_width(fstyle->uifont_id, str, max_len);
 
   if ((okwidth > 0.0f) && (strwidth > okwidth)) {
@@ -1674,10 +1669,6 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
     strwidth = BLF_width(fstyle->uifont_id, str, max_len);
   }
 
-  if (fstyle->kerning == 1) {
-    BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   BLI_assert(strwidth <= okwidth);
 
   return strwidth;
@@ -1736,11 +1727,6 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct
   /* need to set this first */
   UI_fontstyle_set(fstyle);
 
-  if (fstyle->kerning == 1) {
-    /* for BLF_width */
-    BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   /* define ofs dynamically */
   if (but->ofs > but->pos) {
     but->ofs = but->pos;
@@ -1785,10 +1771,6 @@ static void ui_text_clip_cursor(const uiFontStyle *fstyle, uiBut *but, const rct
       }
     }
   }
-
-  if (fstyle->kerning == 1) {
-    BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
 }
 
 /**
@@ -1806,11 +1788,6 @@ static void ui_text_clip_right_label(const uiFontStyle *fstyle, uiBut *but, cons
   /* need to set this first */
   UI_fontstyle_set(fstyle);
 
-  if (fstyle->kerning == 1) {
-    /* for BLF_width */
-    BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
-  }
-
   but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr));
   but->ofs = 0;
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list