From f8ade3c9b756dcbad2d14f0998c8334df417d303 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Fri, 22 Mar 2024 13:10:15 -0700 Subject: [PATCH] UI: Correction to Weight of 3D Viewport Overlay Text Currently the overlay text, like stats for example, are drawing with the widget_label font style size but using widget's weight. This is just because UI_fontstyle_set is not called. Without this call we can get a jiggling of the overlay text if these two styles differ in weight. This PR also makes an (unnoticeable) correction to the font id used in fontstyle_set_ex. uiFontStyle's uifont_id is not always the same id as regular font ids, but here they are confused. --- source/blender/editors/interface/interface_style.cc | 2 +- source/blender/editors/space_view3d/view3d_draw.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index e3fc95ba12c..a15fd5b1f6f 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -494,7 +494,7 @@ static void fontstyle_set_ex(const uiFontStyle *fs, const float dpi_fac) uiFont *font = uifont_to_blfont(fs->uifont_id); BLF_size(font->blf_id, fs->points * dpi_fac); - BLF_character_weight(fs->uifont_id, fs->character_weight); + BLF_character_weight(font->blf_id, fs->character_weight); } void UI_fontstyle_set(const uiFontStyle *fs) diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index 533b809a62a..076954f9046 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1506,7 +1506,10 @@ void view3d_draw_region_info(const bContext *C, ARegion *region) if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) { int xoffset = rect->xmin + (0.5f * U.widget_unit); int yoffset = rect->ymax - (0.1f * U.widget_unit); - BLF_default_size(UI_style_get()->widgetlabel.points); + + const uiFontStyle *fstyle = UI_FSTYLE_WIDGET_LABEL; + UI_fontstyle_set(fstyle); + BLF_default_size(fstyle->points); BLF_set_default(); if ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) { -- 2.30.2