Fonts in Chrome (for UI use)

2,829 views
Skip to first unread message

Rachel Blum

unread,
Apr 18, 2012, 9:16:26 PM4/18/12
to Chromium-dev
I'm currently trying to find out how to get a consistent look across Views, GTK and Cocoa for a dialog that uses more than one font. (I know, "Good luck!" ;)

I've run into a few questions so far:

* Is there a way to actually get a consistent look via ResourceBundle::GetFont(), or is each platform free to choose whatever font size/weight/family it wants?

* If I wanted to get the size consistent, what is the proper way to set a font size? Views seems to like GetDerivedFont(), gtk likes ForceFontSizePixels(), and so far I haven't found Cocoa examples that don't use nibs

* What is our actual font size? It seems that for GTK we basically use points and assume 96dpi? Is GetDerivedFont() using points or pixels?

Rachel

Ben Goodger (Google)

unread,
Apr 18, 2012, 9:55:36 PM4/18/12
to gr...@chromium.org, Chromium-dev
In UI, we use the system font. We choose larger and smaller fonts based on that benchmark, so that when the user changes their system setting to specify "large fonts" "small fonts" etc everything continues to work. Back when we had native dialog boxes, we sized them based on the width of the default font, so that when you did this they'd resize too.

I don't think you can get a 100% pixel perfect match per platform, even if you matched styles and fonts, because the platform rendering routines are different too. I don't believe 100% fidelity is desirable though, since we typically lean towards matching the system.

-Ben


Rachel

--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Rachel Blum

unread,
Apr 18, 2012, 11:29:00 PM4/18/12
to Ben Goodger (Google), Chromium-dev
On Wed, Apr 18, 2012 at 6:55 PM, Ben Goodger (Google) <b...@chromium.org> wrote:
In UI, we use the system font.

But we seem to manually choose font sizes in at least some cases... But basically, you're saying we should use ResourceBundle::GetFont()?

Rachel
 
 
I don't think you can get a 100% pixel perfect match per platform, even if you matched styles and fonts, because the platform rendering routines are different too. I don't believe 100% fidelity is desirable though, since we typically lean towards matching the system.

I'm not looking for pixel-perfect, but I'd like "not completely different". If there wasn't a heading font that's larger than the rest, I'd be fine with just system font. 

Rachel

Nico Weber

unread,
Apr 18, 2012, 11:31:59 PM4/18/12
to gr...@chromium.org, Ben Goodger (Google), Chromium-dev
You can look at the old "about chrome" dialog. That contained bold and
italic text and was implemented in native UI on win, gtk, and cocoa.
Just check out a revision from 2-3 months ago :-)

Nico

Evan Martin

unread,
Apr 19, 2012, 11:06:07 AM4/19/12
to gr...@chromium.org, Chromium-dev
Dialogs that use native API are supposed to look like native dialogs.
On Linux you can't rely on any particular font name being available
and you can't rely on any particular native font size. (Some people
really do have their systems set up like
http://people.gnome.org/~eitani/csun2010/images/large_fonts.png )

When you create a GTK label or button or whatever, you can use the
..._set_markup() APIs which let you specify the contents in an
HTML-like form. Use '<span size="large">My text</span>' for large
text.

Peter Kasting

unread,
Apr 19, 2012, 2:07:22 PM4/19/12
to gr...@chromium.org, Ben Goodger (Google), Chromium-dev
On Wed, Apr 18, 2012 at 8:29 PM, Rachel Blum <gr...@chromium.org> wrote:
I don't think you can get a 100% pixel perfect match per platform, even if you matched styles and fonts, because the platform rendering routines are different too. I don't believe 100% fidelity is desirable though, since we typically lean towards matching the system.

I'm not looking for pixel-perfect, but I'd like "not completely different".

Why?

Or to be clearer -- if using the default system font/size/style results in more fidelity to native dialogs but dramatic differences between platforms, why would we think that a bad thing?

PK

Rachel Blum

unread,
Apr 19, 2012, 2:21:06 PM4/19/12
to Peter Kasting, Ben Goodger (Google), Chromium-dev
 
I'm not looking for pixel-perfect, but I'd like "not completely different".

Why?

Or to be clearer -- if using the default system font/size/style results in more fidelity to native dialogs but dramatic differences between platforms, why would we think that a bad thing?

I consider that a bad thing since dramatic differences _should_ mean (possibly) a different design. (I.e. you might want to change margins, alignments, etc.). I'm not a UI/UX person, so I have limited ability to do so. But I care enough about UI/UX that it nags me every single time I see it. 

That's OK. I can live with that. I was _hoping_ we had addressed this issue, but I don't need it fixed.

Rachel

Peter Kasting

unread,
Apr 19, 2012, 2:24:12 PM4/19/12
to Rachel Blum, Ben Goodger (Google), Chromium-dev
On Thu, Apr 19, 2012 at 11:21 AM, Rachel Blum <gr...@chromium.org> wrote:
I'm not looking for pixel-perfect, but I'd like "not completely different".

Why?

Or to be clearer -- if using the default system font/size/style results in more fidelity to native dialogs but dramatic differences between platforms, why would we think that a bad thing?

I consider that a bad thing since dramatic differences _should_ mean (possibly) a different design. (I.e. you might want to change margins, alignments, etc.).

That's true, but the standard for those is also "look as native as possible".  So if we use native fonts on each platform but a constant hardcoded set of values for other UI metrics, which differ from platform values, and we wind up with dialogs that look weird, the answer is probably that we should have adjusted those other constants as well.

PK 
Reply all
Reply to author
Forward
0 new messages