-
Notifications
You must be signed in to change notification settings - Fork 304
Add helper to load font #448
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
Conversation
Concept ACK. |
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.
Approach ACK 44f948f.
src/qt/guiutil.cpp
Outdated
@@ -272,6 +272,12 @@ bool hasEntryData(const QAbstractItemView *view, int column, int role) | |||
return !selection.at(0).data(role).toString().isEmpty(); | |||
} | |||
|
|||
void loadFont(const QString& file_name) |
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.
Why not return id
for generality?
From Qt docs:
An ID is returned that can be used to remove the font again with
removeApplicationFont()
or to retrieve the list of family names contained in the font.
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.
The helper is meant for our use case: load font; ensure it is valid; remains loaded while the application runs.
Happy to add the return value, but at the moment it is discarded at the call site.
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.
Concept ACK
This PR introduces a new loadFont function, which along with adding the font, also asserts that it has been properly added to the QFontDatabase. I agree with the changes in the PR because this function eliminates any chance of font not being correctly added to the Application.
44f948f
to
98f423d
Compare
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.
ACK 98f423d, tested on Linux Mint 20.2 (Qt 5.12.8).
98f423d
to
d54ec27
Compare
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.
re-ACK d54ec27
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.
Tested ACK d54ec27. Refactoring the code and defining loadFont()
in src/qt/guiutil.cpp
reduces redundant imports of the QFontDatabase
and is a better design.
Fonts in the application remain consistent in both the PR and master.
Master | PR |
---|---|
![]() |
![]() |
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.
ACK d54ec27
Changes since my last review:
- The added function has been renamed from
loadFont
->LoadFont
according to the name convention - QStringLiteral macro is now used to ensure the input string is allocated statically.
- const keyword is used for the id variable to indicate that it is not modified.
- The fileName has been corrected to file_name in the comment.
Why do we want to abort if it fails?? |
Originally submitted as bitcoin-core/gui-qml#49.