-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
^examples$ | ||
^\.travis\.yml$ | ||
^codecov\.yml$ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#' Import ET Book font for use in plots | ||
#' | ||
#' There is an option `ggtufte.loadfonts` which -- if set to `TRUE` -- will | ||
#' call `extrafont::loadfonts()` to register non-core fonts with R PDF & PostScript | ||
#' devices. If you are running under Windows, the package calls the same function | ||
#' to register non-core fonts with the Windows graphics device. | ||
#' | ||
#' | ||
|
||
#' @md | ||
#' @note This will take care of ensuring PDF/PostScript usage. The location of the | ||
#' font directory is displayed after the base import is complete. It is highly | ||
#' recommended that you install them on your system the same way you would any | ||
#' other font you wish to use in other programs. | ||
#' @references <https://edwardtufte.github.io/et-book/> | ||
#' @source <https://github.com/edwardtufte/et-book> | ||
#' @export | ||
import_et_book <- function() { | ||
# function adapted from hbrthemes::import_roboto_condensed | ||
font_dir <- system.file("fonts", package = "ggtufte") | ||
|
||
suppressWarnings(suppressMessages(extrafont::font_import(font_dir, | ||
prompt = FALSE))) | ||
message( | ||
sprintf( | ||
paste0("You will likely need to install these fonts on your ", | ||
"system as well.", | ||
"\n\nYou can find them in [%s]"), | ||
font_dir) | ||
) | ||
|
||
} | ||
|
||
#' ET Book fonts | ||
#' | ||
#' ET Book (ETBembo font-family) comprises five fonts: | ||
#' | ||
#' - `"ETBembo RomanLF"`: Roman (lining figures) | ||
#' - `"ETBembo RomanOSF"`: Roman (oldstyle figures) | ||
#' - `"ETBembo SemiBoldOSF"`: Semi-bold (oldstyle figures) | ||
#' - `"ETBembo BoldLF"`: Bold (lining figures) | ||
#' - `"ETBembo DisplayItalic"`: Display Italic (oldstyle figures) | ||
#' | ||
#' @md | ||
#' @title ET Book fonts R variable aliases | ||
#' @format length 5 character vector. Values are the | ||
#' font names, and names are the description of the font. | ||
#' @rdname ETBembo | ||
#' @export | ||
#' @examples | ||
#' font_et | ||
font_et <- c("Roman (line figures)" = "ETBembo RomanLF", | ||
"Roman (old-style figures)" = "ETBembo RomanOSF", | ||
"Bold (line figures)" = "ETBembo BoldLF", | ||
"Semi-bold (old-style figures)" = "ETBembo SemiBoldOSF", | ||
"Display italic" = "ETBembo DisplayItalic") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# adapted from hrbrthemes zzz.R | ||
.onAttach <- function(libname, pkgname) { | ||
# nocov start | ||
if (.Platform$OS.type == "windows") { # nocov start | ||
if (interactive()) { | ||
packageStartupMessage("Registering Windows fonts with R") | ||
} | ||
extrafont::loadfonts("win", quiet = TRUE) | ||
} | ||
|
||
if (getOption("ggtufte.loadfonts", default = FALSE)) { | ||
if (interactive()) { | ||
packageStartupMessage("Registering PDF & PostScript fonts with R") | ||
} | ||
extrafont::loadfonts("pdf", quiet = TRUE) | ||
extrafont::loadfonts("postscript", quiet = TRUE) | ||
} | ||
|
||
fnt <- extrafont::fonttable() | ||
if (!any(grepl("ETBembo", fnt$FamilyName))) { | ||
packageStartupMessage("NOTE: The ET Book fonts are required to use this theme.") | ||
packageStartupMessage(" Please use ggtufte::import_et_book() to install the ET Book fonts.") | ||
} # nocov end | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
library("ggplot2") | ||
library("extrafont") | ||
extrafont::loadfonts() | ||
|
||
ggplot(mtcars, aes(wt, mpg)) + | ||
geom_point() + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
All R source code files are released under the MIT license. | ||
|
||
----------------------------- | ||
|
||
ET Book font has the following license/copyright: | ||
|
||
Copyright (c) 2015 Dmitry Krasny, Bonnie Scranton, Edward Tufte. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.