Skip to content
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

Font scaling calculation for diagrams is wrong on Linux #1661

Closed
lwrage opened this Issue Dec 11, 2018 · 10 comments

Comments

Projects
None yet
2 participants
@lwrage
Copy link
Contributor

lwrage commented Dec 11, 2018

Summary

The current calculation decreases the font size for higher resolution displays.

Expected and Current Behavior

After upgrading to Eclipse 2018-09 as the basis for OSATE fonts in diagrams on my laptop are shown in smaller size. It turns out that the dpi calculation in SWT was changed for GTK >= 3.22.0 to report the real screen dpi based on resolution and screen size. The previous version reported 96 dpi (incorrect), now it is 158 dpi, which is the correct value.

The calculation in

final int fontSizeInPoints = (int)(Math.round(unscaledFontSize*96.0/device.getDPI().y*10.0)/10.0);

is wrong as it decreases the font size for resolutions > 96 dpi.

Environment

  • OSATE Version: 2.4.0 SNAPSHOT
  • Operating System: Kubuntu 18.04 with GTK 3.22.30

required by #1466

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 11, 2018

Changing form 96/dpi to dpi/96 results in too large fonts. There is an X dpi setting (which is set to 96 dpi), but there seems to be no way to get that setting using a public OS independent method in SWT.

One solution would be to

  • fix the calculation
  • add a preference setting that allows the user additional control of font scaling and change the calculation to unscaledFontSize * device.getDPI().y / 96.0 * <scaling factor from preference>.
@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 11, 2018

Need to test on Windows and macOS.

@philip-alldredge

This comment has been minimized.

Copy link
Collaborator

philip-alldredge commented Dec 11, 2018

To provide some additional background information: that calculation was added to attempt to provide a consistent font size in pixels/diagram units. This is important because that is the only way to ensure that opening the diagram on multiple machines results in a consistent diagram. If the size of labels change with respect to the size of other diagram elements, then containers will be resized, shapes will overlap and the diagram will not look the same.

It sounds like there has been in a change in out DPI is handled compared to previous versions so I fix is likely required. I am only mentioning these details as a warning against potential issues. Different versions of windows have different mechanisms for handling DPI and scaling depending on the monitor and the text size settings.

A preference to allow the user to adjust things may result in the same problems this was originally intended to avoid. For example if the user chooses to adjust the text size, it will result in apparently broken diagrams when sharing diagrams between others.

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 11, 2018

Are shape sizes in the GE given in pixels or diagram units that are mapped to pixels based on DPI?

@philip-alldredge

This comment has been minimized.

Copy link
Collaborator

philip-alldredge commented Dec 11, 2018

Shapes are in diagram units which are effectively pixels.

Text can be scaled by the OS, Low Level UI Toolkit(GTK/Win32), or SWT depending on settings, environment variables, and operating system and eclipse version.

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 11, 2018

So the automatic diagram layout depends on the size of the labels, which makes sense.

Is the "correct" way to deal with a higher resolution display, then, to automatically decrease the font size (as it is done today) and have the user increase the diagram zoom level until the labels are readable? Is the diagram layout independent of the zoom level?

@philip-alldredge

This comment has been minimized.

Copy link
Collaborator

philip-alldredge commented Dec 11, 2018

Yes. In general, shapes are resized to accommodate their labels.

Yes, the intended way of dealing with higher resolution display and/or custom text sizes at the OS level is to automatically decrease the font size so that the result of rendering the entire diagram is the same on all platforms. This isn't entirely possible because SWT doesn't support floating point font sizes.

Yes, it is intended that the user will need to adjust the zoom level until the diagram is readable. Zoom level only affects the user's display of the diagram and does not affect the diagram itself.

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 11, 2018

The remaining issue is then that we end up with different font sizes (as rendered in the diagram) depending on the GTK version on Linux.

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 14, 2018

Physical measurements show that font scaling is automatically applied on Linux. If the GE font scaling is NOT applied, label and font sizes are as expected. With the GE font scaling the scaling factor (96/158 in my case) is applied twice, resulting in the tiny fonts.
In Oxygen the scaling factor was applied only once because SWT reported a fake 96 dpi. Maybe the fix is to turn of GE font scaling on Linux.

@lwrage

This comment has been minimized.

Copy link
Contributor Author

lwrage commented Dec 14, 2018

On macOS the reported DPI is not the physical DPI, e.g., a laptop with retina display (2560x 1600) reports a DPI of 72x72.

@wafflebot wafflebot bot added the in progress label Dec 18, 2018

@lwrage lwrage added this to the 2.4.0 milestone Jan 3, 2019

@wafflebot wafflebot bot added review and removed in progress labels Feb 7, 2019

@lwrage lwrage changed the title Font scaling calculation for diagrams is wrong Font scaling calculation for diagrams is wrong on Linux Feb 11, 2019

@lwrage lwrage closed this in #1683 Feb 11, 2019

@wafflebot wafflebot bot removed the review label Feb 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.