Skip to content

Conversation

@NazmusSayad
Copy link

ShareX Text Input box was broken on my two monitors.

1761420176.mp4
  • 4K, 150% Scaling
    IMG_20251026_011907_821

  • 1080P, 100% Scaling (Default, No Scaling)
    IMG_20251026_011929_273

I have tried to fix the problem.
But then found #5312. By configuring the DPI settings, it seems to be working (without my changes). But still, the texts seem too small on a high-resolution screen.
ShareX should think about this problem more seriously.

…roved font handling. Added ApplyDpiSafeLayout method to ensure proper scaling of UI elements based on device DPI. Updated font size calculation to use display points for better rendering across different DPI settings.
Copy link
Contributor

@RobertoAssumpcao RobertoAssumpcao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reviewing the changes related to the DPI/scaling behavior in the text-input form, and I’d like to clarify a few points to ensure the implementation behaves consistently across different displays.

About the DPI conversion formula
float displayPoints = Math.Max(1f, Options.Size * 72f / Math.Max(1, DeviceDpi));
Could you confirm what unit Options.Size is stored in?
If it is already in points, this conversion might actually be reducing the font size incorrectly.

If it represents pixel size at 96 DPI, then the more accurate formula should be:
Options.Size * 96f / DeviceDpi

Have we tested this logic on monitors with different DPIs? My concern is that the resulting font size may become too small on high-resolution displays, which seems related to the issue this PR is trying to address.

About the dynamic modification of Anchor properties
I also noticed the ApplyDpiSafeLayout() method adjusts the button anchors at runtime:
btnOK.Anchor = AnchorStyles.Bottom | (btnOK.Anchor & AnchorStyles.Right) | AnchorStyles.Left;
btnCancel.Anchor = AnchorStyles.Bottom | (btnCancel.Anchor & AnchorStyles.Right) | AnchorStyles.Left;
Changing anchors programmatically—especially in multiple places such as the constructor, Shown, OnDpiChanged, and nudTextSize_ValueChanged—can lead to unpredictable layout behavior.

Have we considered:

Wrapping layout updates with SuspendLayout() / ResumeLayout() to avoid flickering?

Setting anchors properly in the designer and using a TableLayoutPanel for more reliable responsive layout?

Introducing a guard flag (e.g., _isApplyingLayout) to prevent re-entrant calls?

I’m raising these points just to better understand the intent and ensure the layout behaves predictably across DPI changes. Thanks in advance for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants