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

Embed monospaced font #79

Merged
merged 4 commits into from
Feb 22, 2021
Merged

Embed monospaced font #79

merged 4 commits into from
Feb 22, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Aug 28, 2020

Qt does not guarantee that the actual applied font matches to the requested one.
It was noted (bitcoin/bitcoin#16432 (comment)):

the monospace font looks a bit weird no macOS

... because it is not monospaced.
Also some discrepancies I've noted on Windows while testing Qt 5.15 (#19716).

Of course, we could check the actual font with QFontInfo, and try to choose another font.
But this PR suggests to just embed a monospaced font, and get the GUI look (partially) independent from a platform.

Roboto Mono was chosen after discussion with Bitcoin Design community, and due to its Apache License, Version 2.0.

Changes are scoped to the Overview page only.


Screenshots on macOS 10.15.6 (images are simulated by code patching):


More screenshots added after #79 (comment):

  • Linux Mint 20.1 + Cinnamon DE

DeepinScreenshot_select-area_20210221205410

  • Windows 10 (with depends)

DeepinScreenshot_select-area_20210221205056

  • macOS Big Sur (with depends)

DeepinScreenshot_select-area_20210221202917

@hebasto
Copy link
Member Author

hebasto commented Aug 28, 2020

Many thanks to @GBKS !

@hebasto hebasto changed the title gui: Add IBM Plex Mono font Add IBM Plex Mono font Aug 28, 2020
@Sjors
Copy link
Member

Sjors commented Aug 30, 2020

Before and after screenshots on various OS's would be nice.

I'm generally not a fan of messing with the default font choices of operating systems / desktop environments. However, if upstream QT doesn't use a proper monospaced font for macOS, then it makes sense for at least that platform.

@hebasto
Copy link
Member Author

hebasto commented Aug 30, 2020

Just for record: another PR that embeds a font is bitcoin/bitcoin#16883.

@RandyMcMillan
Copy link
Contributor

RandyMcMillan commented Sep 3, 2020

There have been concerns about OFL Licensing in the past...

bitcoin/bitcoin#17311 (comment)

bitcoin/bitcoin#17311 (comment)

But if OFL isn't an issue - then fonts-liberation is a good candidate as well because
we can stay in one family of fonts and remain consistent across different presentations.

https://en.wikipedia.org/wiki/Liberation_fonts

@michaelfolkson
Copy link
Contributor

Looking for Concept (N)ACKs (plus comments if you have them) from designers cc @GBKS @Bosch-0 @johnsBeharry

@Bosch-0
Copy link

Bosch-0 commented Sep 3, 2020

Concept ACK

Though using Roboto Mono would be a better alternative:

IBM Plex Mono
image

Roboto Mono
image

image

@hebasto
Copy link
Member Author

hebasto commented Sep 3, 2020

About font sizes:

$ ls -go
total 380
-rw-rw-r-- 1 111532 Mar 11  2018 IBMPlexMono-Medium.ttf
-rw-rw-r-- 1  86820 May 13  2015 RobotoMono-Medium.ttf
-rw-rw-r-- 1 182172 May 13  2015 RobotoMono-VariableFont_wght.ttf

@hebasto hebasto changed the title Add IBM Plex Mono font Embed monospaced font Sep 3, 2020
@hebasto
Copy link
Member Author

hebasto commented Sep 3, 2020

It appears that Qt (at least 5.12.8) cannot work with variable fonts.
At least QFont::setWeight() (<weight>..</weight> in *.ui file) is noop for RobotoMono-VariableFont_wght.ttf.

@Bosch-0
Copy link

Bosch-0 commented Sep 3, 2020

Ahh that's a shame, not a huge issue though, as the mono font is only going to be used in a few places the benefits of using a variable font is negligible. The static medium Roboto Mono font style should be all we need to use.

I think the licensing issue with OFL still makes Roboto Mono a more suitable option than IBM Plex Mono.

@hebasto
Copy link
Member Author

hebasto commented Sep 3, 2020

Updated 15f37db -> 3fdd5b6 (pr79.01 -> pr79.02, diff):

  • used Roboto Mono instead of IBM Plex Mono as requested by @Bosch-0
  • changes are scoped only the Overview page as it is a clear visual bug fix

Going to update OP soon. OP updated.

@hebasto
Copy link
Member Author

hebasto commented Sep 3, 2020

@Sjors

Before and after screenshots on various OS's would be nice.

Done.

I'm generally not a fan of messing with the default font choices of operating systems / desktop environments. However, if upstream QT doesn't use a proper monospaced font for macOS, then it makes sense for at least that platform.

This is under discussion now in Bitcoin Design Community (https://github.com/BitcoinDesign, https://bitcoindesign.slack.com). Please join the discussion :)

@luke-jr
Copy link
Member

luke-jr commented Sep 3, 2020

Concept NACK to overriding the platform. If users don't like their platform's font choices, they should change it there.

Also concept NACK to moving discussion to a private proprietary platform.

@moneyball
Copy link
Contributor

I agree with @luke-jr that the bitcoin design community should not require Core contributors to join Slack in order to debate changes to the Core GUI (although developers are more than welcome to join the conversation there!). I think it is fine if there is discussion on Slack or video calls or any medium, but for any kind of formal proposal or discussion or debate, it should occur on GitHub as that is the existing process for the project.

@flack
Copy link
Contributor

flack commented Sep 20, 2020

Just my two cents for the screenshot in the OP: Using monospace for the balance numbers seems like a weird workaround (weird because you have two different fonts for the same line of information, the label in the normal UI font and then the number & unit in the monospace one). It would be much nicer to use a non-monospace font throughout that supports tabular figures (see https://www.fonts.com/content/learning/fontology/level-3/numbers/proportional-vs-tabular-figures). Or doesn't that work in Qt?

@hebasto
Copy link
Member Author

hebasto commented Sep 20, 2020

@flack

Just my two cents for the screenshot in the OP: Using monospace for the balance numbers seems like a weird workaround (weird because you have two different fonts for the same line of information, the label in the normal UI font and then the number & unit in the monospace one). It would be much nicer to use a non-monospace font throughout that supports tabular figures (see https://www.fonts.com/content/learning/fontology/level-3/numbers/proportional-vs-tabular-figures). Or doesn't that work in Qt?

Thanks! TIL. I didn't know about "tabular figures".

@RandyMcMillan
Copy link
Contributor

@hebasto -

The Roboto Family is an excellent choice as an embedded font (imo).
I believe we should be proactive and embed the entire family.
It would eliminate this unknown factor in Gui design moving forward.

Keep in mind - fonts do pose a security issue.
https://www.zdnet.com/article/google-open-sources-internal-tool-for-finding-font-related-security-bugs/
https://security.stackexchange.com/questions/91347/how-can-a-font-be-used-for-privilege-escalation

In essence - embedding fonts explicitly enhances determinism.

@hebasto
Copy link
Member Author

hebasto commented Feb 1, 2021

@luke-jr

Concept NACK to overriding the platform. If users don't like their platform's font choices, they should change it there.

Being a financial application the Bitcoin Core requires a monospaced/fixed-pitch font (or, at least, tabular figures font).

The Qt's font matching algorithm does not guarantee that:

A agree that user's ability to customize fonts is good. The question is how users could customize the monospaced font for Qt application now?

I'm not aware of such possibilities on Windows 10 and macOS 11.1. On Linux I used the qt5ct package, but it fails to customize the monospaced font.

If there are no ways to customize the monospaced font for Qt application, are you going to insist on your point?

@laanwj
Copy link
Member

laanwj commented Feb 1, 2021

The Roboto Family is an excellent choice as an embedded font (imo). I believe we should be proactive and embed the entire family.

Agree. Despite really disliking it on a conceptual level, I think 'ship your own fonts' is the modern way. The less assumptions we have to make about the operating system, platform, and what is already installed, the better.
This will also help in making fully static binaries. E.g. bitcoin/bitcoin#18110

(That is, for the distributed binaries. When building from source you can do whatever you like.)

@michaelfolkson
Copy link
Contributor

michaelfolkson commented Feb 1, 2021

Concept NACK to overriding the platform. If users don't like their platform's font choices, they should change it there.

If this is purely a design choice (there are no negative side effects to this change) I'm happy to leave to the designers. If the designers are a Concept ACK I'm a Concept ACK.

@laanwj
Copy link
Member

laanwj commented Feb 2, 2021

Code review and license review ACK 3fdd5b6
Please do update contrib/debian/copyright to explitily list the apache license for the embedded font files.

Changes are scoped to the Overview page only.

I think we have to replace all fixed-width fonts with this one, not just the overview page (not necessarily in thie PR ofcourse).

@jonasschnelli
Copy link
Contributor

Concept ACK 3fdd5b6 - please add the license attribution

@luke-jr
Copy link
Member

luke-jr commented Feb 4, 2021

The Qt's font matching algorithm does not guarantee that:

the monospaced font will be chosen at all (see bitcoin/bitcoin#16432 (comment))
the chosen monospaced font has expected style and weight (see #87 (comment))

We already have functional workarounds for these.

an upgrade of the system or Qt won't change the Bitcoin Core look unexpectedly

That's desirable and expected behaviour.

I'm not aware of such possibilities on Windows 10 and macOS 11.1.

Crazy. It looks like Windows 10 removed the ability for users to configure their fonts. But that's a Windows problem, not necessarily ours...

I'm not surprised Apple denies users choice.

Note that your suggestions here do NOT restore user choice, but instead make it even harder for them to configure it!

On Linux I used the qt5ct package, but it fails to customize the monospaced font.

It's right there in System Settings for me, as a "Fixed width" font choice.

Setting the "Monospace" font family in a `*.ui` file does not work on
macOS, at least on Big Sur with Qt 5.15 (neither via the "font" property
nor via the "styleSheet" property). Qt chooses the ".AppleSystemUIFont"
instead of ".AppleSystemUIFontMonospaced".

This change makes macOS choose the correct monospaced font.
@hebasto
Copy link
Member Author

hebasto commented Feb 21, 2021

Updated 3fdd5b6 -> 67f2631 (pr79.02 -> pr79.04):

@luke-jr
Copy link
Member

luke-jr commented Feb 21, 2021

added an option to opt-out embedded monospaced font in Menu -> Options-> Display as requested by @luke-jr (as I understand his idea)

That seems like a reasonable compromise.

Can you also not add the font to the repo, make it optional at build time (perhaps configurable?), and bundle it via depends?

@hebasto
Copy link
Member Author

hebasto commented Feb 21, 2021

Can you also not add the font to the repo, make it optional at build time (perhaps configurable?), and bundle it via depends?

What reasons do you see for that?

@luke-jr
Copy link
Member

luke-jr commented Feb 21, 2021

So that people who don't want this can build without it...

@laanwj
Copy link
Member

laanwj commented Feb 22, 2021

Tested ACK 67f2631

The option in the configuration dialog is really nicely done.

A configure option to build without internal fonts can be added later. IMO adding the font to the repository itself is fine. It's only 87kB, not worth the overhead of an external depends download.

@rebroad
Copy link
Contributor

rebroad commented May 1, 2021

image
I'm a little confused, what version is the "before" picture from? I'm running 0.21 and it's already a fixed font.

@hebasto
Copy link
Member Author

hebasto commented May 2, 2021

@rebroad

I'm a little confused, what version is the "before" picture from? I'm running 0.21 and it's already a fixed font.

I suppose your system is not macOS, right?

hebasto added a commit that referenced this pull request May 25, 2021
19d51a2 qt: Avoid unnecessary translations (Hennadii Stepanov)

Pull request description:

  Working on translation, I found these translations introduced in #79, that are unnecessary (assuming the universal nature of the "BTC" string).

ACKs for top commit:
  jarolrod:
    ACK 19d51a2

Tree-SHA512: b45551a54a323c5ba3779f4c1d7c8e7ec4d19a2e95fe70153f48234393bf1449a08e6bd24519ec035ebd4a98080a56af45e7a21546b47152e493b8e1b8f4345e
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.