diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2022-09-24 03:36:49 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2022-09-24 03:36:49 +0300 |
commit | cd1631b17dd0e25a8a398fb00a982ca5f0633558 (patch) | |
tree | ee8d9cdb560c815ea86d952ef2f053c6435865c1 /source/blender/editors | |
parent | 88a602bc64fc2a86411d67881439a04486f95030 (diff) |
BLF: Refactor of DPI
Correction of U.dpi to hold actual monitor DPI. Simplify font sizing by
omitting DPI as API argument, always using 72 internally.
See D15961 for more details.
Differential Revision: https://developer.blender.org/D15961
Reviewed by Campbell Barton
Diffstat (limited to 'source/blender/editors')
18 files changed, 23 insertions, 23 deletions
diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index e892a989191..b5cbc92741e 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -66,7 +66,7 @@ static void icon_draw_rect_input_text( BLF_batch_draw_flush(); const int font_id = BLF_default(); BLF_color4fv(font_id, color); - BLF_size(font_id, font_size * U.pixelsize, U.dpi); + BLF_size(font_id, font_size * U.dpi_fac); float width, height; BLF_width_and_height(font_id, str, BLF_DRAW_STR_DUMMY_MAX, &width, &height); const float x = trunc(rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f)); diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 745a2201dc1..90572c45e8b 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -1343,7 +1343,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active) BLF_enable(fontid, BLF_ROTATION); BLF_rotation(fontid, M_PI_2); ui_fontscale(&fstyle_points, aspect); - BLF_size(fontid, fstyle_points * U.pixelsize, U.dpi); + BLF_size(fontid, fstyle_points * U.dpi_fac); /* Check the region type supports categories to avoid an assert * for showing 3D view panels in the properties space. */ diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index a6e37d3f36f..2c4d13e0717 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -254,7 +254,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region UI_fontstyle_set(&fstyle_mono); /* XXX: needed because we don't have mono in 'U.uifonts'. */ - BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.pixelsize, U.dpi); + BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.dpi_fac); rgb_float_to_uchar(drawcol, tip_colors[static_cast<int>(field->format.color_id)]); UI_fontstyle_draw(&fstyle_mono, &bbox, field->text, UI_TIP_STR_MAX, drawcol, &fs_params); } @@ -1133,7 +1133,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C, int font_id; if (field->format.style == uiTooltipFormat::Style::Mono) { - BLF_size(blf_mono_font, data->fstyle.points * U.pixelsize, U.dpi); + BLF_size(blf_mono_font, data->fstyle.points * U.dpi_fac); font_id = blf_mono_font; } else { diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index 904765f6dc4..3895a687033 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -496,5 +496,5 @@ void UI_fontstyle_set(const uiFontStyle *fs) { uiFont *font = uifont_to_blfont(fs->uifont_id); - BLF_size(font->blf_id, fs->points * U.pixelsize, U.dpi); + BLF_size(font->blf_id, fs->points * U.dpi_fac); } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 0a6feeb3665..c78279b7971 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -260,7 +260,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) int otype = RNA_enum_get(op->ptr, "offset_type"); opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE; opdata->segments = (float)RNA_int_get(op->ptr, "segments"); - float pixels_per_inch = U.dpi * U.pixelsize; + float pixels_per_inch = U.dpi; for (int i = 0; i < NUM_VALUE_KINDS; i++) { opdata->shift_value[i] = -1.0f; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 156698be567..d364aa2274f 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -495,7 +495,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) float numstr_size[2]; float posit[2]; const float bg_margin = 4.0f * U.dpi_fac; - const float font_size = 14.0f * U.pixelsize; + const float font_size = 14.0f; const int distance_precision = 4; /* Calculate distance and convert to string. */ @@ -516,7 +516,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) } BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, font_size, U.dpi); + BLF_size(blf_mono_font, font_size * U.dpi_fac); BLF_rotation(blf_mono_font, 0.0f); BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); @@ -565,7 +565,7 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, const float arc_size = 64.0f * U.dpi_fac; const float bg_margin = 4.0f * U.dpi_fac; const float cap_size = 4.0f * U.dpi_fac; - const float font_size = 14.0f * U.pixelsize; + const float font_size = 14.0f; const int angle_precision = 3; /* Angle arc in 3d space. */ @@ -646,7 +646,7 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, } BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, font_size, U.dpi); + BLF_size(blf_mono_font, font_size * U.dpi_fac); BLF_rotation(blf_mono_font, 0.0f); BLF_width_and_height(blf_mono_font, numstr, sizeof(numstr), &numstr_size[0], &numstr_size[1]); diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index adc07d0b411..4fe4b087042 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -357,7 +357,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion *UNUSED(ar), void *a GPU_matrix_push(); GPU_matrix_mul(cd->text_mat); - BLF_size(fontid, 10.0f * fstyle_points, U.dpi); + BLF_size(fontid, 10.0f * fstyle_points * U.dpi_fac); BLF_color3f(fontid, 1.0f, 1.0f, 1.0f); BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight); BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 25e16bee558..39e3c7a2f0a 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -3794,7 +3794,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f float font_dims[2] = {0.0f, 0.0f}; /* frame number */ - BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); + BLF_size(fontid, 11.0f * U.dpi_fac); BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 8f876f6a8a3..b7ca6334e35 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -343,7 +343,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *region) /* second pass: text */ y = (float)CHANNEL_FIRST; - BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); + BLF_size(fontid, 11.0f * U.dpi_fac); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float)(y - CHANNEL_HEIGHT_HALF); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index b9bd97260ef..ea286fd2c2d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -1034,7 +1034,7 @@ static void draw_marker_texts(SpaceClip *sc, return; } - BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); + BLF_size(fontid, 11.0f * U.dpi_fac); fontsize = BLF_height_max(fontid); if (marker->flag & MARKER_DISABLED) { diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 8a934396229..09bb895cffb 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -168,7 +168,7 @@ void ED_image_draw_info(Scene *scene, GPU_blend(GPU_BLEND_NONE); - BLF_size(blf_mono_font, 11.0f * U.pixelsize, U.dpi); + BLF_size(blf_mono_font, 11.0f * U.dpi_fac); BLF_color3ub(blf_mono_font, 255, 255, 255); SNPRINTF(str, "X:%-4d Y:%-4d |", x, y); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 9aa2b84169e..aee72860a0a 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -25,7 +25,7 @@ static void textview_font_begin(const int font_id, const int lheight) { /* Font size in relation to line height. */ - BLF_size(font_id, 0.8f * lheight, 72); + BLF_size(font_id, 0.8f * lheight); } typedef struct TextViewDrawState { diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 937db9951b4..98f10bfdfe5 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2714,7 +2714,7 @@ static void frame_node_draw_label(const bNodeTree &ntree, BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); /* clamp otherwise it can suck up a LOT of memory */ - BLF_size(fontid, MIN2(24.0f, font_size) * U.pixelsize, U.dpi); + BLF_size(fontid, MIN2(24.0f, font_size) * U.dpi_fac); /* title color */ int color_id = node_get_colorid(node); diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 435436611c5..5fce0709d10 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -327,7 +327,7 @@ static float get_column_width(const ColumnValues &values) { float data_width = get_default_column_width(values); const int fontid = UI_style_get()->widget.uifont_id; - BLF_size(fontid, UI_DEFAULT_TEXT_POINTS, U.dpi); + BLF_size(fontid, UI_DEFAULT_TEXT_POINTS * U.dpi_fac); const StringRefNull name = values.name(); const float name_width = BLF_width(fontid, name.data(), name.size()); return std::max<float>(name_width / UI_UNIT_X + 1.0f, data_width); @@ -341,7 +341,7 @@ static float get_column_width_in_pixels(const ColumnValues &values) static int get_index_column_width(const int tot_rows) { const int fontid = UI_style_get()->widget.uifont_id; - BLF_size(fontid, UI_style_get_dpi()->widget.points * U.pixelsize, U.dpi); + BLF_size(fontid, UI_style_get_dpi()->widget.points * U.dpi_fac); return std::to_string(std::max(0, tot_rows - 1)).size() * BLF_width(fontid, "0", 1) + UI_UNIT_X * 0.75; } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index a976bb6c34b..3cff9a25bba 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -57,7 +57,7 @@ static void text_draw_context_init(const SpaceText *st, TextDrawContext *tdc) static void text_font_begin(const TextDrawContext *tdc) { - BLF_size(tdc->font_id, (float)tdc->lheight_px, 72); + BLF_size(tdc->font_id, (float)tdc->lheight_px); } static void text_font_end(const TextDrawContext *UNUSED(tdc)) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c index 73ac3f3a1d8..70afb0eaff1 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c @@ -118,7 +118,7 @@ static void gizmo_axis_draw(const bContext *C, wmGizmo *gz) font.id = BLF_default(); BLF_disable(font.id, BLF_ROTATION | BLF_SHADOW | BLF_MATRIX | BLF_ASPECT | BLF_WORD_WRAP); BLF_enable(font.id, BLF_BOLD); - BLF_size(font.id, AXIS_TEXT_SIZE, 72); + BLF_size(font.id, AXIS_TEXT_SIZE); BLF_position(font.id, 0, 0, 0); /* Calculate the inverse of the (matrix_final * matrix_offset). diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index d95d49dd982..2f5ca79a660 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -647,7 +647,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) GPU_line_width(1.0f); BLF_enable(blf_mono_font, BLF_ROTATION); - BLF_size(blf_mono_font, 14.0f * U.pixelsize, U.dpi); + BLF_size(blf_mono_font, 14.0f * U.dpi_fac); BLF_rotation(blf_mono_font, 0.0f); UI_GetThemeColor3ubv(TH_TEXT, color_text); diff --git a/source/blender/editors/util/ed_draw.c b/source/blender/editors/util/ed_draw.c index 7ec3d3c1ef4..0477f4dcf76 100644 --- a/source/blender/editors/util/ed_draw.c +++ b/source/blender/editors/util/ed_draw.c @@ -768,7 +768,7 @@ void ED_region_image_metadata_draw( GPU_matrix_translate_2f(x, y); GPU_matrix_scale_2f(zoomx, zoomy); - BLF_size(blf_mono_font, style->widgetlabel.points * 1.5f * U.pixelsize, U.dpi); + BLF_size(blf_mono_font, style->widgetlabel.points * U.dpi_fac); /* *** upper box*** */ |