"Bootstrap" a toolkit-views Typography spec.
Under Harmony, we want to abstract away decisions about font selection.
Harmony has a set of styles as part of the spec that encapsulate:
- Font (typeface)
- Font size, weight and color
- Line spacing ("leading")
gfx::Font[List] can represent Font, size and weight, but not color or
line spacing. Also callers typically _never_ care about typeface, but
APIs using gfx::Font are unable to encapsulate this. One side-effect is
that a lot of callers use gfx::Font::Derive(..) rather than
ResourceBundle::GetFontWithDelta(..) and so miss out on caching
The typography concepts are split into "TextContext" and "TextStyle".
The former describes the location of the text, and the latter describes
its current state (e.g. Disabled) or other appearance (e.g. a Hyperlink)
in that context.
This CL exposes a set of abstract typography concepts at
views::style, and explores the impact on client code by refactoring
the views::Label constructor that takes a gfx::FontList to take a
Label::CustomFont instead. Where it makes sense, callers are migrated to
typography concepts rather than use Label::CustomFont.
The transformations typically look like:
- ui::ResourceBundle::MediumFont -> views::style::CONTEXT_DIALOG_TITLE "15pt"
- GetFontListWithDelta(ui::kTitleFontSizeDelta) ->
- GetFontListWithDelta(1) -> (chrome) CONTEXT_BODY_TEXT_LARGE "13pt"
- [default constructor] or ResourceBundle::BaseFont ->
CONTEXT_BODY_TEXT_LARGE or views::style::CONTEXT_LABEL "12pt"
- ui::ResourceBundle::SmallFont -> (chrome) CONTEXT_DEPRECATED_SMALL
(Harmony doesn't have an 11pt font in the spec)
- ui::ResourceBundle::BoldFont -> (chrome) STYLE_EMPHASIZED
(Harmony doesn't have a "bold" font in the spec)
These transformations, and the default TypographyProvider, are chosen to
effectively be a "no-op" so that no existing dialogs change font sizes
or other properties.
- Implement a Harmony TypographyProvider.
- Require all Label constructors to take a typography concept or
- Remove Label::SetFontList, Label::Set*Color, etc. (use typography or
merge into CustomFont).
- Remove gfx::FontList from the API of other toolkit-views classes.
- Audit remaining users of Label::CustomFont to see if they can be
replaced by Typography concepts.
- Remove ResourceBundle::FontStyle (SmallFont, etc.)
- Remove ui/default_style.h (ui::kFooFontSizeDelta, etc.)
53 files changed