Page MenuHome

Fix T88799: 3DViewport Stats Column Measurements
ClosedPublic

Authored by Harley Acheson (harley) on Jun 4 2021, 7:40 PM.

Details

Summary

To draw the overlay stats in columns the strings must be measured to
find the longest one. In some circumstances this measurement can be
incorrect. We draw the text with a specific size yet do not explicitly
set the size before calling BLF_size. This patch properly sets the size
so the measurement will match what will be used for output.

See T88799 for examples of measurement failure.


Note that this one-line patch should look wrong to anyone without prior
experience with our (wonky) UI scaling code. The call to BLF_Size does
indeed need dpi multiplied by pixelsize. This is because U.dpi is not
actually DPI but dpi divided by U.pixelsize. Yes, our dpi changes if
you simply change to "wide lines". So this multiplication is needed to
get back actual dpi.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Jun 4 2021, 7:40 PM
Harley Acheson (harley) created this revision.

Makes sense, thanks for the fix.

As some point maybe it would make sense to abstract this line you just added.

This revision is now accepted and ready to land.Jun 9 2021, 6:38 PM

Does calling BLF_set_default resolve this issue?

This is used when the size needs to be known before drawing in region_draw_status_text, draw_seq_handle & UI_view2d_text_cache_draw.

If that works I think it's preferable.

@Campbell Barton (campbellbarton) - Does calling BLF_set_default resolve this issue?

Probably, as that does look very similar. Basically the same code, using global_font_dpi which is also set with U.dpi * U.pixelsize. Will test in couple hours.

@Campbell Barton (campbellbarton) - Yes BLF_set_default() works perfectly (and even returns the default font id).

Will commit.