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

Fonts in generated instruction depend on system DPI setting #292

Closed
riazanovskiy opened this issue Jun 22, 2019 · 8 comments
Closed

Fonts in generated instruction depend on system DPI setting #292

riazanovskiy opened this issue Jun 22, 2019 · 8 comments
Assignees
Milestone

Comments

@riazanovskiy
Copy link

riazanovskiy commented Jun 22, 2019

Subject

Although #267 is fixed, LPub output still depends on system DPI setting. For instance, the first page was generated with 100% scaling
instruction-lpub_page_103
and the second one was generated with 175% scaling
instruction-lpub_page_103-dpi175

LPub is a kind of compiler, its output should only depend on mpd source file (and LPub configuration files), not on system scaling setting, which is supposed to affect only UI elements
image

Environment

LPub 2.3.12 under Windows 10

Workaround

Right now I switch scaling to 100%, generate PDF with LPub, and look through it while fixing the instruction in LPub with scaling switched back to 175% (otherwise the interface elements are too small for me to read). This workflow is rather slow.

It is also possible to manually set the step number font settings to counter the scaling change.

@trevorsandy
Copy link
Owner

Thank you for reporting this behaviour.

Indeed, there is more to be done to make the LPub3D generated content completely autonomous from the system DPI scaling as I have indicated in my last #267 comment.

Cheers,

@trevorsandy
Copy link
Owner

Corrected.

Going back to #267...

I compute the style rect scale ratio by dividing the system DPI against the constant of 96 DPI.

However, this is not enough...

I noticed there are several other fixed-size items that will have to be manually scaled - notably the page background, and CSI image. The scene ruler should also be adjusted. So there is more to be done...

Qt uses the DPI settings in several other places to determine the size metrics (e.g. in layouts, to determine spacing around items and the like). Consequently, I have decided to force Qt to ignore completely the OS DPI settings and default to 96 fake-DPIs everywhere by doing:

QApplication::setAttribute(Qt::AA_Use96Dpi);

before instantiating the QApplication.

Qt::AA_Use96Dpi will...

Assume the screen has a resolution of 96 DPI rather than using the OS-provided resolution. This will cause font rendering to be consistent in pixels-per-point across devices rather than defining 1 point as 1/72 inch.

Consequently, I rolled back setting the style rect size using the 'dpiRatio()' implemented in #267.

Do not hesitate if you encounter any unexpected behaviour caused by this correction.

Here is a shot of the UI at 175% scale on Windows.

Screenshot - 28_06_2019 , 04_04_58

...and at 100%

Screenshot - 28_06_2019 , 04_00_46

Cheers,

@riazanovskiy
Copy link
Author

Sorry, I could not verify it is working :/

Should I enable something?
I downloaded CI build (windows portable x86_64 zip) from this commit trevorsandy/lpub3d-ci@e8ffed5
and got different images and 100% and 175% scaling

instruction-lpub_page_3-100
instruction-lpub_page_3-175

@trevorsandy trevorsandy reopened this Jun 30, 2019
@trevorsandy
Copy link
Owner

I imagine there must be settings other than 'Scale and Layout' contributing to this behaviour. On my Windows 10 environment, the behaviour is as illustrated above. For me, there is no change in the annotation text font at scale above 100% so I'm not sure what else to look at.

Cheers,

@riazanovskiy
Copy link
Author

riazanovskiy commented Jun 30, 2019

Could you please tell if the file you used to get the screenshots above had

0 !LPUB RESOLUTION GLOBAL ??? DPI

line? And if not, what is your default setting? Maybe those are deduced differently on my machine and on yours

@trevorsandy
Copy link
Owner

I used this model file for the shots above. It did not have the 0 !LPUB RESOLUTION GLOBAL ??? DPI meta command.

Cheers,

@riazanovskiy
Copy link
Author

And what is your default LPub DPI setting here?

image

so I'm not sure what else to look at

My hypothesis is that this value might differ

@trevorsandy
Copy link
Owner

I used the default setting - 150 DPI - just as you show in the shot.

Cheers,

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

No branches or pull requests

2 participants