Skip to content

[ENH]: Cairo backends do not fully support HiDPI #21024

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

Closed
QuLogic opened this issue Sep 8, 2021 · 2 comments · Fixed by #21025
Closed

[ENH]: Cairo backends do not fully support HiDPI #21024

QuLogic opened this issue Sep 8, 2021 · 2 comments · Fixed by #21025

Comments

@QuLogic
Copy link
Member

QuLogic commented Sep 8, 2021

Problem

When running examples/misc/pythonic_matplotlib.py on a display set to 150% scaling, QtAgg looks like this:
Screenshot from 2021-09-08 19-37-51
But when running QtCairo, it looks like this:
Screenshot from 2021-09-08 19-38-00
The same thing occurs with the GTK*Cairo renderers in #20988.

Layout is done outside the renderer, so everything is in the right place. However, Cairo only knows about the physical DPI, and renders text and lines with it. Thus they are all the correct size at 200 DPI, but since that is scaled in half to 100 DPI, they all appear smaller than they should be.

Proposed solution

Somehow Agg backends handle this correctly, so we should copy whatever we do there to the Cairo backends.

Additional context and prior art

No response

@QuLogic
Copy link
Member Author

QuLogic commented Sep 9, 2021

Thus they are all the correct size at 200 DPI, but since that is scaled in half to 100 DPI, they all appear smaller than they should be.

Ah, I actually have this backwards. They are rendered at 100 DPI on a canvas that is actually 200 DPI. This is because Cairo renderers are created with the canvas and stay around for all time with the initial DPI, whereas the Agg renderers are created on draw (modulo some caching) and thus always have the correct DPI.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 9, 2021

Additionally, if you save the figure from the GUI, it outputs something that's about half the width and half the height that it should be.

@QuLogic QuLogic added this to the v3.5.0 milestone Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant