posit-dev / brand-yml

Unified branding with a single yaml file.
https://posit-dev.github.io/brand-yml/
MIT License
1 stars 0 forks source link

Make it very easy to quickly set font-family #21

Open gadenbuie opened 1 month ago

gadenbuie commented 1 month ago

As proposed by @cpsievert, we could make it very easy to set font families by letting typography.{base,headings,monospace} take a string that we'd map to the family property.

typography:
  fonts:
    - family: Open Sans
      source: google
    - family: Roboto Slab
      source: google
    - family: Fira Code
      source: google
  base: Open Sans
  headings: Roboto Slab
  monospace: Fira Code

For someone who just wants to pick fonts quickly even this is still a bit of boilerplate. In pkgdown and rmarkdown, we've used a syntax like this to declare in-place Google fonts:

typography:
  base: { google: Open Sans }
  headings: { google: Roboto Slab }
  monospace: { google: Fira Code }

Instead of this, I wonder, if we're comfortable making Google Fonts the default, we could automatically add Google Font declarations for font families that don't have a counterpart in typography.fonts and are a single font family name.

With this approach, in the following example we'd use Roboto Slab and Fira Code from Google Fonts but rely on locally-installed Open Sans (i.e. opting out of Google Fonts).

typography:
  fonts:
    - family: Open Sans
      source: file
  base: Open Sans
  headings: Roboto Slab
  monospace: Fira Code
gadenbuie commented 1 week ago
typography:
  fonts:
    - family: Open Sans
      source: system
  base: Open Sans
  headings: Roboto Slab
  monospace: Fira Code
  1. headings: Roboto Slab as a shortcut for headings: {family: "Roboto Slab"}
  2. Undeclared fonts come from some default location. brand_yaml (Shiny) will use Google Fonts by default, Quarto will use system.
  3. A font with source: system says "don't do anything to resolve this font".
cscheid commented 1 week ago

Quarto now uses the following schemas:

https://github.com/quarto-dev/quarto-cli/blob/c0c320d9433dc6b0065e88186d0f2f9f1e5afa07/src/resources/schema/definitions.yml#L2763-L2777

(other related schemas were similarly changed.)

gadenbuie commented 3 days ago

brand_yaml added BrandTypographyFontSystem in https://github.com/posit-dev/brand-yaml/commit/f934ef99f807c91609c5204f62d33467a60f5040

gadenbuie commented 3 days ago

And the default font source is now configurable via the BRAND_YAML_DEFAULT_FONT_SOURCE envvar in 57fb01da367e4c262e05e43defdc1fd8e104d8cd and "system" is the new default after #28.