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

Blurry font rendering on a high DPI display #292

Closed
efermi opened this issue May 24, 2021 · 14 comments · Fixed by #293
Closed

Blurry font rendering on a high DPI display #292

efermi opened this issue May 24, 2021 · 14 comments · Fixed by #293

Comments

@efermi
Copy link

efermi commented May 24, 2021

With the Qt version of the app on a high DPI display the text in the book's canvas is blurry, not rendered properly.
App version: 3.2.57-1
O/S: Manjaro Linux
Global scaling factor: 2

How it looks compared to unscaled (bottom):
Screenshot_20210524_162930
Screenshot_20210524_163117

@virxkane
Copy link
Collaborator

virxkane commented May 24, 2021

@efermi Can you test 3.2.57 with this patch from #293?
https://patch-diff.githubusercontent.com/raw/buggins/coolreader/pull/293.patch

Edit:
With this patch toolbar icons not scaled too.

@efermi
Copy link
Author

efermi commented May 24, 2021

Works for me, although the UI widgets remain unscaled.
Screenshot_20210524_222024

@virxkane
Copy link
Collaborator

UI widgets remain unscaled.

Menu, setting dialog, about dialog is scaled. Not scaled toolbar icons, scrollbar. Or something else?
I don't know about HiDPI in Qt5 enough, so for now it's all that I can do. Maybe someone will improve it.

@efermi
Copy link
Author

efermi commented May 24, 2021

The fonts are scaled, but not the widgets themselves. Compare patched and original (right):
Screenshot_20210524_231354
Without the patch everything is scaled properly except for the fonts on the book's canvas, and with the patch the fonts everywhere become scaled properly, but the widgets are left unscaled.

@virxkane
Copy link
Collaborator

The fonts are scaled, but not the widgets themselves.

Yes indeed.
Actually we have to disable HiDPI scaling for only one widget (CR3View), but I can't find how to do this.
So, disable it for all application widgets.

@virxkane
Copy link
Collaborator

@efermi Ok, should we apply this patch in upstream or it's too ugly?

@efermi
Copy link
Author

efermi commented May 25, 2021

I think you should, overall I consider this to be an improvement, fonts are rendered perfectly everywhere now. Only few widgets remain really hard to use, namely the toolbar and the scrollbar and I consider them to be less important than the text.

@virxkane
Copy link
Collaborator

@efermi

I think you should, overall I consider this to be an improvement, fonts are rendered perfectly everywhere now. Only few widgets remain really hard to use, namely the toolbar and the scrollbar and I consider them to be less important than the text.

This drawbacks fixed.
Please test this patch: True-HiDPI-support.zip
I'm too lazy to create a pull request, if you want to do it yourself.

@efermi
Copy link
Author

efermi commented Jan 16, 2022

I've tested the patch, everything looks right, thanks @virxkane! I'll try to put together a PR some time later if you don't do it yourself first.

@efermi
Copy link
Author

efermi commented Jan 16, 2022

Hello @virxkane, there is a bug with the color preview widget, the center of the square stays white, while only the border around it changes with the selected color.
Screenshot_20220116_205700

@virxkane
Copy link
Collaborator

Hello @virxkane, there is a bug with the color preview widget, the center of the square stays white, while only the border around it changes with the selected color.

Hello. Try next patch:

diff --git a/cr3qt/src/settings.cpp b/cr3qt/src/settings.cpp
index 9aff7b327..c676ee50a 100644
--- a/cr3qt/src/settings.cpp
+++ b/cr3qt/src/settings.cpp
@@ -887,6 +887,7 @@ void SettingsDlg::setBackground( QWidget * wnd, QColor cl )
 {
     QPalette pal( wnd->palette() );
     pal.setColor( QPalette::Window, cl );
+    pal.setColor( QPalette::Base, cl );
     wnd->setPalette( pal );
 }
 

@efermi
Copy link
Author

efermi commented Jan 16, 2022

This fixes it. I've also noticed that chapter marks in the page header are shorter now, is it also a bug?

@virxkane
Copy link
Collaborator

I've also noticed that chapter marks in the page header are shorter now, is it also a bug?

I think - no.
Starting from PR #277, chapter markers are scaled according to DPI, when using the patch in #292 (comment) DPI is set based on screen parameters.

void CR3View::updateDefProps()
{
    _data->_props->setStringDef( PROP_WINDOW_FULLSCREEN, "0" );
    _data->_props->setStringDef( PROP_WINDOW_SHOW_MENU, "1" );
    _data->_props->setStringDef( PROP_WINDOW_SHOW_SCROLLBAR, "1" );
    _data->_props->setStringDef( PROP_WINDOW_TOOLBAR_SIZE, "1" );
    _data->_props->setStringDef( PROP_WINDOW_SHOW_STATUSBAR, "0" );
    _data->_props->setStringDef( PROP_APP_START_ACTION, "0" );

#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
    QScreen* screen = this->screen();
#else
    QScreen* screen = QGuiApplication::primaryScreen();
#endif
    lString32 str;
    int d = (int)screen->logicalDotsPerInch();
    // special workaround for MacOS
    if (72 == d)
        d = 96;
    str.appendDecimal(d);
    _data->_props->setString( PROP_RENDER_DPI, str );
    // But we don't apply PROP_RENDER_SCALE_FONT_WITH_DPI property,
    // since for now we are setting the font size in pixels.
#endif

    QStringList styles = QStyleFactory::keys();
    QStyle * s = QApplication::style();
    QString currStyle = s->objectName();
    CRLog::debug("Current system style is %s", currStyle.toUtf8().data() );
    QString style = cr2qt(_data->_props->getStringDef( PROP_WINDOW_STYLE, currStyle.toUtf8().data() ));
    if ( !styles.contains(style, Qt::CaseInsensitive) )
        _data->_props->setString( PROP_WINDOW_STYLE, qt2cr(currStyle) );
}

@efermi
Copy link
Author

efermi commented Jan 16, 2022

All right then, I'll submit the PR shortly.

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 a pull request may close this issue.

2 participants