feat: bump title sizes, add font_scale to logo functions, ship SVGs
R-CMD-check / R CMD check (push) Successful in 3m36s

- Change rel_large default from 16/14 to 20/14 (~1.43x) to match the
  Civilytics editorial design system. Subtitle now renders at 1.0x base
  instead of 0.86x.
- Switch axis.text to rel() sizing so all text elements cascade from the
  root font_size, enabling uniform scaling.
- Add font_scale parameter (default 1.1) to civilytics_logo(),
  add_logo(), and add_logo_ga() — inflates text by ~10% before
  arrangeGrob composition to compensate for viewport shrinkage.
- Ship SVG logo variants (mark, wordmark, pulse) in inst/img/ for
  Quarto/HTML templates.
- Add "Maintaining brand assets" section to README documenting inst/img/
  file inventory and update workflow.
- Document full font size hierarchy in theme_civilytics() roxygen.
This commit is contained in:
2026-05-19 12:51:23 -06:00
parent 34622ccf88
commit 31d3e2886d
26 changed files with 222 additions and 26 deletions
+6 -1
View File
@@ -4,7 +4,7 @@
\alias{add_logo}
\title{Add a logo to a ggplot2 object}
\usage{
add_logo(plot, logo, margin_param = NULL)
add_logo(plot, logo, margin_param = NULL, font_scale = 1.1)
}
\arguments{
\item{plot}{a ggplot2 grob}
@@ -12,6 +12,11 @@ add_logo(plot, logo, margin_param = NULL)
\item{logo}{a logo grob created by make_logo_grob()}
\item{margin_param}{a numeric specifying what margin to add or subtract to align the logo}
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text
sizes before composing the plot with the logo. Default `1.1` inflates
text by ~10 \% to compensate for the viewport shrinkage caused by
[gridExtra::arrangeGrob()]. Set to `1` to disable.}
}
\value{
a grob with a logo attached to it ready to plot
+13 -3
View File
@@ -2,9 +2,16 @@
% Please edit documentation in R/logo.R
\name{add_logo_ga}
\alias{add_logo_ga}
\title{Add a logo to a ggplot2 object}
\title{Add a logo to multiple ggplot2 objects}
\usage{
add_logo_ga(plot_list, logo, nrow = 1, widths = NULL, margin_param = NULL)
add_logo_ga(
plot_list,
logo,
nrow = 1,
widths = NULL,
margin_param = NULL,
font_scale = 1.1
)
}
\arguments{
\item{plot_list}{a list containing ggplot2 objects}
@@ -16,12 +23,15 @@ add_logo_ga(plot_list, logo, nrow = 1, widths = NULL, margin_param = NULL)
\item{widths}{an optional vector the same length as plot_list with the widths for each plot}
\item{margin_param}{a number giving the adjustment up or down to help manually align logo and captions}
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text
sizes before composing. Default `1.1`. See [add_logo()] for details.}
}
\value{
a grid object
}
\description{
Add a logo to a ggplot2 object
Add a logo to multiple ggplot2 objects
}
\note{
The resulting object needs to be drawn to the screen using grid.draw()
+13 -1
View File
@@ -8,7 +8,8 @@ civilytics_logo(
plot,
type = c("wordmark", "mark"),
variant = c("light", "dark"),
margin_param = NULL
margin_param = NULL,
font_scale = 1.1
)
}
\arguments{
@@ -22,6 +23,10 @@ civilytics_logo(
\item{margin_param}{Numeric or `NULL`. Manual margin adjustment passed to
[add_logo()].}
\item{font_scale}{Numeric. Inflate text sizes by this factor to compensate
for viewport shrinkage when composing with [gridExtra::arrangeGrob()].
Default `1.1` (~10 \% inflation). Set to `1` to disable.}
}
\value{
A grob (from [gridExtra::arrangeGrob()]) ready to draw with
@@ -59,5 +64,12 @@ library(ggplot2); library(grid)
theme_civilytics_dark()) |>
civilytics_logo(variant = "dark", type = "mark") |>
grid.draw()
# Disable font inflation
(ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics()) |>
civilytics_logo(font_scale = 1) |>
grid.draw()
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 97 KiB

+30 -2
View File
@@ -11,7 +11,7 @@ theme_civilytics(
line_size = 0.5,
rel_small = 12/14,
rel_tiny = 11/14,
rel_large = 16/14,
rel_large = 20/14,
ink = unname(civilytics_colors["ink"]),
paper = unname(civilytics_colors["paper"]),
accent = unname(civilytics_colors["ember_600"]),
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
Default `11/14`.}
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
`font_size`. Default `16/14`.}
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
design system.}
\item{ink}{Character. Hex code for foreground/text color. Defaults to
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
@@ -78,6 +79,28 @@ Brand fonts (Inter for UI text, Libre Franklin for titles) are loaded
automatically via [showtext] when the package is attached. Call
[civilytics_load_fonts()] to reload them if needed.
}
\section{Font size hierarchy}{
All text sizes are derived from `font_size` using relative scale factors.
At the default `font_size = 14`:
| Element | Scale factor | Default size |
|:--------|:-------------|:-------------|
| Plot title | `rel_large` (1.43x) | ~20 pt |
| Subtitle | 1.0x | 14 pt |
| Axis text (tick labels) | `rel_small` (0.86x) | ~12 pt |
| Axis titles | `rel_small` (0.86x) | ~12 pt |
| Legend text | `rel_small` (0.86x) | ~12 pt |
| Caption | `rel_tiny` (0.79x) | ~11 pt |
| Legend title | `rel_tiny` (0.79x) | ~11 pt |
| Strip text (facets) | `rel_small` (0.86x) | ~12 pt |
To uniformly scale all text, change `font_size`. To adjust only the title
prominence, change `rel_large`. When using [civilytics_logo()] to add a
logo below the plot, pass `font_scale` to compensate for viewport
shrinkage.
}
\examples{
\dontrun{
library(ggplot2)
@@ -97,5 +120,10 @@ ggplot(mpg, aes(displ, hwy, colour = class)) +
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics(paper_bg = FALSE)
# Larger text for poster or display
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_civilytics(font_size = 18)
}
}
+3 -2
View File
@@ -11,7 +11,7 @@ theme_civilytics_dark(
line_size = 0.5,
rel_small = 12/14,
rel_tiny = 11/14,
rel_large = 16/14,
rel_large = 20/14,
ink = unname(civilytics_colors["paper"]),
paper = unname(civilytics_colors["navy_700"]),
accent = unname(civilytics_colors["ember_400"]),
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
Default `11/14`.}
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
`font_size`. Default `16/14`.}
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
design system.}
\item{ink}{Character. Hex code for foreground/text color. Defaults to
[civilytics_colors]`["ink"]` (`#0E1A2B`).}
+3 -2
View File
@@ -11,7 +11,7 @@ theme_civilytics_slide(
line_size = 0.5,
rel_small = 12/14,
rel_tiny = 11/14,
rel_large = 16/14,
rel_large = 20/14,
ink = unname(civilytics_colors["ink"]),
paper = unname(civilytics_colors["paper"]),
accent = unname(civilytics_colors["ember_600"]),
@@ -38,7 +38,8 @@ Default `"Libre Franklin"` (loaded via showtext).}
Default `11/14`.}
\item{rel_large}{Numeric. Scale factor for large text (titles) relative to
`font_size`. Default `16/14`.}
`font_size`. Default `20/14` (~1.43x), matching the Civilytics editorial
design system.}
\item{ink}{Character. Hex code for foreground/text color. Defaults to
[civilytics_colors]`["ink"]` (`#0E1A2B`).}