feat(theme): add a showtext switch to civilytics_load_fonts() for ragg users (#29)
R-CMD-check / R CMD check (push) Successful in 5m7s
R-CMD-check / R CMD check (push) Successful in 5m7s
civilytics_load_fonts(showtext = getOption("civilytics.showtext", TRUE))
registers the brand fonts and only then turns on showtext, so ragg users can
opt out of its 96 dpi text sizing. The default is unchanged, so existing
reports render as before. The help page documents the ragg path.
Closes #29
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f3ec052144
commit
119aa7aa0f
5 files changed
+105
-16
No files matched your search
@@ -4,28 +4,46 @@
|
||||
\alias{civilytics_load_fonts}
|
||||
\title{Load Civilytics brand fonts}
|
||||
\usage{
|
||||
civilytics_load_fonts(force = FALSE)
|
||||
civilytics_load_fonts(
|
||||
force = FALSE,
|
||||
showtext = getOption("civilytics.showtext", TRUE)
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{force}{Logical. If \code{TRUE}, reload fonts even if they were already
|
||||
loaded in this session. Default \code{FALSE}.}
|
||||
|
||||
\item{showtext}{Logical. Turn on \code{showtext::showtext_auto()} after
|
||||
registering the fonts. Default is \code{getOption("civilytics.showtext", TRUE)}.}
|
||||
}
|
||||
\value{
|
||||
Invisibly returns \code{TRUE} if fonts were loaded, \code{FALSE} if skipped
|
||||
(already loaded and \code{force = FALSE}).
|
||||
(already loaded and \code{force = FALSE}).
|
||||
}
|
||||
\description{
|
||||
Downloads Inter, Libre Franklin, Source Serif 4 and JetBrains Mono from
|
||||
Google Fonts via \code{sysfonts::font_add_google()}, then calls
|
||||
\code{showtext::showtext_auto()} so that all graphics devices render text with
|
||||
those fonts. This is called automatically when the package loads; use this
|
||||
function to retry if the initial load failed (e.g., the machine was offline
|
||||
at load time).
|
||||
|
||||
Google Fonts via \code{sysfonts::font_add_google()}, then, unless
|
||||
\code{showtext = FALSE}, calls \code{showtext::showtext_auto()} so that all graphics
|
||||
devices render text with those fonts. This is called automatically when the
|
||||
package loads; use this function to retry if the initial load failed (e.g.,
|
||||
the machine was offline at load time).
|
||||
}
|
||||
\details{
|
||||
Subsequent calls within the same session are no-ops unless \code{force = TRUE}.
|
||||
|
||||
\strong{Using ragg.} \code{showtext::showtext_auto()} draws text at 96 dpi whatever the
|
||||
device resolution, so on a \code{ragg::agg_png(res = 300)} device text comes out
|
||||
at about a third of its requested size. For ragg, set
|
||||
\code{options(civilytics.showtext = FALSE)} before loading the package, or call
|
||||
\code{showtext::showtext_auto(FALSE)} afterwards. The brand fonts must then be
|
||||
installed on the system, because ragg reads system fonts rather than the
|
||||
ones registered through sysfonts.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
civilytics_load_fonts()
|
||||
|
||||
# For ragg devices: register the fonts but leave showtext off
|
||||
civilytics_load_fonts(force = TRUE, showtext = FALSE)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user