-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hardcoded fonts scaling issues #7493
Conversation
@Rossmaxx, can you please point out what you think I am misunderstanding or confusing? It sounds like I broke something because I did not understand it when in fact I think I have a good understanding of the issues. The solution of this PR will likely break on HiDPI screens and will not look consistent across different systems. Results of a Perplexity sessionI had a chat with Perplexity AI about the topic which you can find here: The most important part is the second question which I will (partially) quote here for completeness: Q: Do I understand correctly that a given point size will effectively lead to rendering at different pixel sizes depending on the DPI of the display? A: Yes, you understand correctly. The relationship between point size and pixel size is indeed dependent on the display's DPI (Dots Per Inch). Here's a more detailed explanation:
The practical example in point 3 shows that specifying a point size of 12 points leads to different pixel sizes at which the font will be rendered depending on the DPI. I am aware that AI systems are not the single source of truth and might write wrong stuff. However, this matches with my already existing understanding. Furthermore, I'd also wonder why there should be a function to set text in point sizes if all that it would do would just be to multiply the point size with 4/3 to yield a pixel size. Example: LMMS' combo boxLet's use LMMS' own combo box as an example of how this might break. The combo box renders itself at a fixed height of 22 pixels: Line 54 in d703f39
This means that at 96 DPI a 12 point text will fit as it uses 16 pixels. However, the text will already be clipped at 192 DPI and 300 DPI because the 32 and 50 pixels of the text will not fit the combo box widget anymore. Proposal for a fixIn my opinion the way forward is to adjust the pixel sizes used by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes as this implementation will likely not fix the problems but introduce different ones (see above).
If my assumptions are correct then the text rendering of the combo box should start to break at DPIs of 158 and higher. Here's how to calculate the critical DPI for the used font size of 10 which will be interpreted as 10 points with this PR:
The formula calculates at which DPI a point size of 10 will map to 22 pixels. That's where these numbers are coming from. At 158 DPI the text will use the full vertical space of the combo box. Any higher DPI should make it exceed it. The following gives an overview of how the ratio of text height to combo box height should change for different DPI values:
|
So basically, the old implementation was correct for LMMS' usage because every other widget seems to have hardcoded sizes. The way i see it, the fonts are now corrected but the behaviour will become inconsistent because the rest of the widgets use pixel sizes. Even in other places, there seems to be a mix of pixel and point sizes. If i understand correctly, this PR goes from one regression to another. The best course for now would be to adjust the pixel sizes for better visibility. Though for hidpi support, we should eventually transition everything to use point sizes instead, which will be easier once we support svg graphics, but that's another issue. |
Assuming that you mean this commit with "old implementation". I think that it has worked because it's using the DPI as an additional factor (effectively One could also say that the fonts might look corrected on your system but that they will likely look broken on a HiDPI screen. Do you happen to know the DPI of you system? I assume that it's below 120 so that for example the fonts of the combo box will not exceed the rest of the combo box and have a nice ratio between font size and widget size. Would be interesting if someone with a very high DPI screen could test your PR and report if the combo boxes look okay.
Yes, that would be the best fix in my opinion. Because then for certain widgets everything would be defined in pixel sizes and thus it would always scale well with global fractional scaling settings and the visual ratios of the element would always be consistent.
Using point sizes for all widgets would mean that the widget implementations would need to be adjusted to take the font size that's set for a widget into account for example when they report their minimum sizes and paint themselves. I assume that's what Qt widgets do. |
What's your DPI, @messmerd? |
@michaelgregorius I have reverted the behaviour and manually changed the values per your suggestion. @messmerd and @musikBear is this still ok for you now? One follow up I would like to do is to specify the font sizes as constants and pass those. Agree or not? |
I would rather like that font-size was a CSS value or a user-choice in settings.
I cant see any screenie with the altered values |
Agree. It's something that I also did in my working copy when I started to work on it. I defined them per component, e.g. in
Then I used |
With the current branch the fonts are more readable but some screen are in dire need of more "breathing space". Here are some screenshots of how it looks on my system. InstrumentThe instrument view is a little bit wider now to the right and it seems that this is caused by the "Stacking and Arpeggio" tab because it is the only one that uses the full space. The screens in general look a bit crowded now. However, I think one thing that should be done anyway is to remove the fixed size for the instrument view and to let it size according to the layouts in the different tabs. It's a bit unfortunate that the size of the five other tabs is currently dictated by the minuscule size of the pixmapped instrument window. MixerPattern EditorTempo and Time |
This will not be possible as long as LMMS uses it's own custom widgets with hard-coded pixel sizes and hard-coded layouts, i.e. no Qt layouts. |
Is hardcoding a must? |
Michael says you need to hardcode font sizes because of the fact that rest of LMMS widgets (ie combobox, mixer line, instrument ui, text boxes, knob etc) are hardcoded in pixels and using properly scaled fonts will make the entire UI inconsistent. It's quite a paradox but we need to live with it. We can convert fonts back to point sizes but in order to do that, first the other widgets must become properly scaleable. I believe Michael wrote about it somewhere. |
I have extracted the common font values to constants. One other thing that i did is to rename the |
I somewhat fixed it in the latest commit by reducing the knob size. The issue still partially exists. It just looks better.
As an intermediate step, we can center all the instrument sub widgets (and if possible, let the tabs take full space of it). That's beyond scope of this PR however. updated screenshot: |
@michaelgregorius regarding knobs, I believe there's a |
@Rossmaxx, there's one last remark. I think after that it would be good to go for me. |
The dial uses an I think I already have an idea for an improvement of the existing class and might give it a try once this PR is merged. |
Remove the include of lmms_math again which was introduced by a manual merge conflict resolution via GitHub's GUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now.
@Rossmaxx, is this ready to merge or do you prefer to wait for another review? |
It's actually ready for merge but it would help if more people reviewed the fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand any of this stuff, but the changes seem fine and it fixes the problems I had on my machine, so I'm going to approve it
@messmerd I didn't notice that. Can you find any other such clippings, so that I can sort those out before merge. But fixing that with shrinking font size won't help as the font there is already too small. |
Fix a problem with cutoff text in Vectorscope. During the constructor call of `LedCheckBox` the method `LedCheckBox::onTextUpdated` is triggered which sets a fixed size that fits the pixmap and the text. After instantiating the two instances in `VecControlsDialog` the constructor then set a minimum size which overrode the fixed size that was previously set. This then led to text that was cutoff.
Fixed with commit 0823bf1. |
I'll merge this within 2 days if no one objects. |
Latest builds for testing. |
I get too much clutter installing/ uninstalling (rinse repeat) For next to daily tests of new versions we need a way to not need to install / uninstall over and over -iow : we need a zip-version as in #7006 |
Yeah, sure, as soon as I get my laptop set up. |
I can understand your concern. You actually misunderstood the 7zip method. You actually unzip the installer and you can go into the unzipped folder and run lmms.exe. If you have any more doubts, feel free to ask. |
* changed font sizes to better values * rename gui_templates.h to FontHelper.h * replace hardcoded values with constants * make knob labels use small font * code review from michael * more consolidation * Fix text problem in Vectorscope Fix a problem with cutoff text in Vectorscope. During the constructor call of `LedCheckBox` the method `LedCheckBox::onTextUpdated` is triggered which sets a fixed size that fits the pixmap and the text. After instantiating the two instances in `VecControlsDialog` the constructor then set a minimum size which overrode the fixed size that was previously set. This then led to text that was cutoff. --------- Co-authored-by: Michael Gregorius <[email protected]>
Fixes a regression from #7185
The regression seems to have been caused by missing calculation between point font sizes to pixel sizes. I manually changed the values.