diff --git a/.Rbuildignore b/.Rbuildignore index c9a5c92..eae5342 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -19,3 +19,5 @@ ^CRAN-RELEASE$ ^appveyor\.yml$ ^tools$ +^LICENSE\.md$ +^data-raw$ diff --git a/DESCRIPTION b/DESCRIPTION index c234d94..218f9f1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,24 +1,43 @@ Package: hrbragg Type: Package -Title: hrbragg title goes here otherwise CRAN checks fail +Title: Typography-centric Themes, Theme Components, and Utilities + for 'ggplot2' and 'ragg'. Version: 0.1.0 Date: 2021-02-16 Authors@R: c( - person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), - comment = c(ORCID = "0000-0001-5670-2640")) + person( + given = "Bob", + family = "Rudis", + email = "bob@rud.is", + role = c("aut", "cre", "cph"), + comment = c(ORCID = "0000-0001-5670-2640") + ) ) Maintainer: Bob Rudis -Description: A good description goes here otherwise CRAN checks fail. +Description: The 'ragg', 'systemfonts', and 'textshaping' packages make it + possible to create plot components and themes that make full use of + the rich typography features in modern fonts. Fonts, themes, and utilities + are provided to create 'ggplot2' plots intended for rendering on 'ragg' + graphics devices. URL: https://git.rud.is/hrbrmstr/hrbragg BugReports: https://git.rud.is/hrbrmstr/hrbragg/issues Encoding: UTF-8 -License: AGPL +Copyright: file inst/COPYRIGHTS +License: MIT + file LICENSE Suggests: covr, tinytest Depends: - R (>= 3.5.0) + R (>= 3.6.0) Imports: - httr, - jsonlite + ragg (>= 0.4.1), + systemfonts (>= 1.0.1), + textshaping (>= 0.3.0), + ggplot2 (>= 3.3.2), + grid (>= 4.0.4), + grDevices, + scales (>= 1.1.1), + tools, + ggtext (>= 0.1.0), + rstudioapi Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.1 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f51d1b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +YEAR: 2021 +COPYRIGHT HOLDER: Bob Rudis diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c2304a0 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2021 Bob Rudis + +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. diff --git a/NAMESPACE b/NAMESPACE index 5b4b9ae..d87656f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,23 @@ # Generated by roxygen2: do not edit by hand -import(httr) -importFrom(jsonlite,fromJSON) +export(adaptive_color) +export(elb) +export(ell) +export(elr) +export(elt) +export(install_inter) +export(inter_pkg) +export(reconfigure_font) +export(theme_background_color) +export(theme_foreground_color) +export(theme_inter) +import(ggplot2) +import(ggtext) +import(grDevices) +import(grid) +import(ragg) +import(scales) +import(systemfonts) +import(textshaping) +import(tools) +importFrom(rstudioapi,getThemeInfo) diff --git a/R/feature-dict.R b/R/feature-dict.R new file mode 100644 index 0000000..4b3c19f --- /dev/null +++ b/R/feature-dict.R @@ -0,0 +1,12 @@ +#' OpenType feature description lookup table +#' +#' Compact data frame describing OpenType features. +#' +#' @format A data frame with 122 rows and 3 variables: +#' \describe{ +#' \item{tag}{OpenType four-character tag name} +#' \item{long_name}{Human-readable tag name} +#' \item{description}{Compact description of the tag} +#' } +#' @source \url{https://en.wikipedia.org/wiki/List_of_typographic_features} +"feature_dict" \ No newline at end of file diff --git a/R/feature-reference.R b/R/feature-reference.R new file mode 100644 index 0000000..c126fff --- /dev/null +++ b/R/feature-reference.R @@ -0,0 +1,132 @@ +#' OpenType Typographic Features +#' +#' Quick reference table describing the four-character feature codes. A +#' more complete quick reference can be found +#' [on Wikipedia](https://en.wikipedia.org/wiki/List_of_typographic_features) +#' and a complete OpenType feature list specification can be found +#' [at Microsoft](https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist). +#' +#' - `aalt` (_Access All Alternates_): Special feature: used to present user with choice all alternate forms of the character +#' - `abvf` (_Above-base Forms_): Replaces the above-base part of a vowel sign. For Khmer and similar scripts. +#' - `abvm` (_Above-base Mark Positioning_): Positions a mark glyph above a base glyph. +#' - `abvs` (_Above-base Substitutions_): Ligates a consonant with an above-mark. +#' - `afrc` (_Alternative Fractions_): Converts figures separated by slash with alternative stacked fraction form +#' - `akhn` (_Akhand_): Hindi for unbreakable. Ligates consonant+halant+consonant, usually only for k-ss and j-ny combinations. +#' - `blwf` (_Below-base Forms_): Replaces halant+consonant combination with a subscript form. +#' - `blwm` (_Below-base Mark Positioning_): Positions a mark glyph below a base glyph +#' - `blws` (_Below-base Substitutions_): Ligates a consonant with a below-mark. +#' - `c2pc` (_Capitals to Petite Caps_): Substitutes capital letters with petite caps +#' - `c2sc` (_Capitals to Small Caps_): Substitutes capital letters with small caps +#' - `calt` (_Contextual Alternates_): Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns +#' - `case` (_Case Sensitive Forms_): Replace characters, especially punctuation, with forms better suited for all-capital text, cf. titl +#' - `ccmp` (_Glyph Composition/Decomposition_): Either calls a ligature replacement on a sequence of characters or replaces a character with a sequence of glyphs. Provides logic that can for example effectively alter the order of input characters. +#' - `cfar` (_Conjunct Form After Ro_): Khmer +#' - `cjct` (_Conjunct Forms_): Ligates consonant+halant+consonant, indicates part of a conjunct. +#' - `clig` (_Contextual Ligatures_): Applies a second ligature feature based on a match of a character pattern within a context of surrounding patterns +#' - `cpct` (_Centered CJK Punctuation_): Positions punctuation marks vertically and horizontally +#' - `cpsp` (_Capital Spacing_): Adjusts spacing between letters in all-capitals text +#' - `cswh` (_Contextual Swash_): Converts letter to a swashed version based on characters around the letter +#' - `curs` (_Cursive Positioning_): Precise positioning of a letter's connection to an adjacent one +#' - `cv01–cv99` (_Character Variant 1–99_): Multiple variants of a single character, which may not apply to many other characters, see references for voluminous documentation +#' - `dist` (_Distance_): Adjusts horizontal positioning between glyphs. (Always enabled, as opposed to 'kern'.) +#' - `dlig` (_Discretionary Ligatures_): Ligatures to be applied at the user's discretion +#' - `dnom` (_Denominator_): Converts to appropriate fraction denominator form, invoked by frac +#' - `dtls` (_Dotless Forms_): +#' - `expt` (_Expert Forms_): Typographic alternatives for some Japanese tetragrams +#' - `falt` (_Final Glyph on Line Alternates_): Replaces final glyph on the line with an alternate +#' - `fin2` (_Terminal Form #2_): Syriac +#' - `fin3` (_Terminal Form #3_): Syriac +#' - `fina` (_Terminal Forms_): Substitutes a special form of a letter at end of words (required by Arabic and Syriac) +#' - `flac` (_Flattened accent forms_): +#' - `frac` (_Fractions_): Converts figures separated by slash with diagonal fraction +#' - `fwid` (_Full Widths_): Substitutes proportionally spaced character with full-width versions (esp. for Latin letters within Chinese) +#' - `half` (_Half Form_): Replaces consonant+halant with a half form, indicating it is part of a conjunct. +#' - `haln` (_Halant Forms_): Replaces a glyph for final consonant+halant. +#' - `halt` (_Alternate Half Widths_): Re-positions full-width glyphs on half-width spaces +#' - `hist` (_Historical Forms_): Obsolete forms of characters to be applied at the user's discretion, cf. hlig +#' - `hkna` (_Horizontal Kana Alternates_): Alternate forms for horizontal kana text, e.g. ー for chōonpu instead of |, cf. vkna +#' - `hlig` (_Historical Ligatures_): Obsolete ligatures to be applied at the user's discretion +#' - `hngl` (_Hangul_): Transliterates Chinese-style characters with Korean Hangul +#' - `hojo` (_Hojo Kanji Forms_): Hojo alternates for Japanese tetragrams +#' - `hwid` (_Half Widths_): Substitutes uniformly-spaced characters with half-width version +#' - `init` (_Initial Forms_): Substitutes a special form of a letter occurring at the beginning of a word (required by Arabic and Syriac) +#' - `isol` (_Isolated Forms_): Substitutes a special form of a letter occurring outside a word (required by Arabic and Syriac) +#' - `ital` (_Italics_): Replaces letter with corresponding italic glyph +#' - `jalt` (_Justification Alternates_): User selectable wider and narrower alternates, used especially for justifying +#' - `jp04` (_JIS 04 Forms_): JIS 2004 alternates for Japanese tetragrams, not accessible per Unicode +#' - `jp78` (_JIS 78 Forms_): JIS C 6226-1978 alternates for Japanese tetragrams, not accessible per Unicode +#' - `jp83` (_JIS 83 Forms_): JIS X 0208-1983 alternates for Japanese tetragrams, not accessible per Unicode +#' - `jp90` (_JIS 90 Forms_): JIS X 0208-1990 alternates for Japanese tetragrams, not accessible per Unicode +#' - `kern` (_Kerning_): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs +#' - `lfbd` (_Left Bounds_): Re-positions glyphs at end of line. Called by opbd. +#' - `liga` (_Standard Ligatures_): Replaces (by default) sequence of characters with a single ligature glyph +#' - `ljmo` (_Leading Jamo Forms_): Initial group of consonants for a synthesized Korean Hangul tetragram +#' - `lnum` (_Lining Figures_): Replaces numerals with glyphs meant to fit better in all-capitals text, often also tnum +#' - `locl` (_Localized Forms_): Substitutes character with the preferred form based on script language +#' - `ltra` (_Left-to-right glyph alternates_): Replaces characters with forms befitting left-to-right presentation (except mirrored forms) +#' - `ltrm` (_Left-to-right mirrored forms_): Replaces characters with possibly mirrored forms befitting left-to-right presentation +#' - `mark` (_Mark Positioning_): Fine positioning of a mark glyph to a base character +#' - `med2` (_Medial Form #2_): Syriac +#' - `medi` (_Medial Forms_): Substitutes a special form of letters between other letters in words (required by Arabic and Syriac) +#' - `mgrk` (_Mathematical Greek_): Replaces Greek characters with special forms for use in mathematics +#' - `mkmk` (_Mark-to-mark Positioning_): Fine positioning of a mark glyph to another mark character +#' - `mset` (_Mark Positioning via Substitution_): Used in Windows 95 for positioning of Arabic marks +#' - `nalt` (_Alternate Annotation Forms_): Provides user access to circled digits, inverse letters etc. +#' - `nlck` (_NLC Kanji Forms_): NLC alternates for Japanese tetragrams +#' - `nukt` (_Nukta Forms_): Replace consonant+nukta (dot mark) with single glyph. +#' - `numr` (_Numerator_): Converts to appropriate fraction numerator form, invoked by frac +#' - `onum` (_Oldstyle Figures_): Replaces numerals with cased old-style numerals, often also pnum +#' - `opbd` (_Optical Bounds_): Re-positions glyphs at beginning and end of line, for precise justification of text. +#' - `ordn` (_Ordinals_): Replaces characters with ordinal forms for use after numbers +#' - `ornm` (_Ornaments_): Decorative alternates for the bullet character • +#' - `palt` (_Proportional Alternates_): Re-positions otherwise monospace characters according to glyph width +#' - `pcap` (_Petite Caps_): Substitute lower-case letters with their petite caps analogs +#' - `pkna` (_Proportional Kana_): Kana for use alongside alphabets, without grid typography +#' - `pnum` (_Proportional Figures_): Replaces numerals with glyphs of proportional width, often also onum +#' - `pref` (_Pre-base Forms_): Replaces halant+consonant at the end of a consonant cluster with a glyph at the beginning. Khmer, Myanmar, Malayalam, Telugu +#' - `pres` (_Pre-base Substitutions_): Ligates consonant combinations. +#' - `pstf` (_Post-base Forms_): Substitutes final halant+consonant with special form. Khmer and Gurmukhi, Malayalam +#' - `psts` (_Post-base Substitutions_): Ligates a final consonant+consonant. +#' - `pwid` (_Proportional Widths_): Replaces uniformly-spaced glyphs with proportional ones +#' - `qwid` (_Quarter Widths_): Replaces uniformly-spaced glyphs with quarter-width ones (punctuation etc.) +#' - `rand` (_Randomize_): Replaces character with random forms (meant to simulate handwriting) +#' - `rclt` (_Required Contextual Alternates_): Contextual alternates required for correct text display which differs from the default join for other letters, required especially important by Arabic +#' - `rkrf` (_Rakar Forms_): Replaces halant+ra with a rakar glyph, indicating it is part of a conjunct. +#' - `rlig` (_Required Ligatures_): Ligatures required for correct text display (any script, but in cursive) +#' - `rphf` (_Reph Form_): Replaces initial ra+halant with a final reph mark, indicating part of a conjunct. +#' - `rtbd` (_Right Bounds_): Re-positions glyphs at beginning of line. Called by opbd. +#' - `rtla` (_Right-to-left glyph alternates_): Replaces characters with forms befitting right-to-left presentation (except mirrored forms) +#' - `rtlm` (_Right-to-left mirrored forms_): Replaces characters with possibly mirrored forms befitting right-to-left presentation +#' - `ruby` (_Ruby Notation Forms_): Ruby characters, small print +#' - `rvrn` (_Required Variation Alternates_): Special variants of a single character, which need apply to specific font variation, required by variable fonts +#' - `salt` (_Stylistic Alternates_): Either replaces with, or displays list of, stylistic alternatives for a character +#' - `sinf` (_Scientific Inferiors_): as in "H2O", "SOx" or "YCbCr" (but using the same font weight and predefined position in contrast these plain HTML subs and sups) +#' - `size` (_Optical size_): Not a lookup: feature's table provides to applications information about the appearance and intent of the font, to aid in font selection. +#' - `smcp` (_Small Caps_): Substitutes lower-case letters with small caps versions +#' - `smpl` (_Simplified Forms_): Replaces sinograms with their simplified versions, may be language dependent +#' - `ss01-ss20` (_Stylistic Set 1 – 20_): Replaces character with one from a font-specific set of stylistic alternatives +#' - `ssty` (_Math script style alternates_): +#' - `stch` (_Stretching Glyph Decomposition_): Substitutes a special form of a stretchy glyph onto one or more letters (required by Syriac) +#' - `subs` (_Subscript_): Replaces character with subscript version, cf. numr +#' - `sups` (_Superscript_): Replaces character with superscript version, cf. dnom +#' - `swsh` (_Swash_): Either replaces character with or displays multiple swashed versions +#' - `titl` (_Titling Alternates_): Replaces characters with forms suited for large type, as in titles +#' - `tjmo` (_Trailing Jamo Forms_): Final group of consonants for a synthesized Korean Hangul tetragram +#' - `tnam` (_Traditional Name Forms_): Japanese alternates for proper names +#' - `tnum` (_Tabular Figures_): Replaces numerals with glyphs of uniform width, often also lnum +#' - `trad` (_Traditional Forms_): Replaces Chinese characters with their traditional versions +#' - `twid` (_Third Widths_): Substitutes uniformly-spaced character with a version of 1/3 width (punctuation, etc.) +#' - `unic` (_Unicase_): Replaces lowercase and uppercase letters with a set of single case glyphs +#' - `valt` (_Alternative Vertical Metrics_): Positions shorter characters to be centered vertically with full-height characters +#' - `vatu` (_Vattu Variants_): Replaces consonant+rakar combinations with a vattu variant ligature. +#' - `vert` (_Vertical Alternates_): A subset of vrt2: prefer the latter feature +#' - `vhal` (_Alternative Vertical Half Metrics_): Positions characters to be centered vertically with half-height characters +#' - `vjmo` (_Vowel Jamo Forms_): Medial group of vowels for a synthesized Korean Hangul tetragram +#' - `vkna` (_Vertical Kana_): Alternate Japanese kana forms for vertical text, e.g. | for chōonpu instead of ー, cf. hkna +#' - `vkrn` (_Vertical Kerning_): Fine vertical positioning of characters based on shape +#' - `vpal` (_Proportional Alternate Vertical Metrics_): Re-positions glyphs vertically to be centered on proportional full-height characters +#' - `vrt2` (_Vertical Alternates and Rotation_): Replaces characters with forms suitable for vertical writing, possibly by rotating 90° +#' - `vrtr` (_Vertical Alternates for Rotation_): Replaces characters with forms suitable for vertical writing, possibly by shifting or shape +#' - `zero` (_Slashed Zero_): Replaces 0 figure with slashed 0 +#' @name opentype_typographic_features +NULL \ No newline at end of file diff --git a/R/hrbragg-package.R b/R/hrbragg-package.R index 39bffc0..bd79dc9 100644 --- a/R/hrbragg-package.R +++ b/R/hrbragg-package.R @@ -1,9 +1,23 @@ -#' ... -#' +#' Typography-centric Themes, Theme Components, and Utilities for 'ggplot2' and 'ragg'. +#' +#' The 'ragg', 'systemfonts', and 'textshaping' packages make it +#' possible to create plot components and themes that make full use of +#' the rich typography features in modern fonts. Fonts, themes, and utilities +#' are provided to create 'ggplot2' plots intended for rendering on 'ragg' +#' graphics devices. +#' #' @md #' @name hrbragg #' @keywords internal #' @author Bob Rudis (bob@@rud.is) -#' @import httr -#' @importFrom jsonlite fromJSON +#' @import ragg +#' @import systemfonts +#' @import textshaping +#' @import ggplot2 +#' @import grid +#' @import grDevices +#' @import scales +#' @import tools +#' @import ggtext +#' @importFrom rstudioapi getThemeInfo "_PACKAGE" diff --git a/R/install-fonts.R b/R/install-fonts.R new file mode 100644 index 0000000..4a51d68 --- /dev/null +++ b/R/install-fonts.R @@ -0,0 +1,78 @@ +install_font <- function(family_name, sub_dir) { + + loc <- system.file("fonts", sub_dir, package = "hrbragg") + + if (platform() == "mac") { + + font_library <- path.expand("~/Library/Fonts") + + if (!dir.exists(font_library)) { + dir.create(font_library, showWarnings = TRUE, mode = "0700") + } + + message("Copying ", family_name, " to ", font_library) + + file.copy( + from = list.files(path = loc, full.names = TRUE), + to = font_library + ) -> res + + } else { + + message( + "The ", family_name, " font files are in:\n", + system.file("fonts", sub_dir, package = "hrbragg"), + "\nand should be installed on your system. Future versions ", + "of {hrbragg} will not force this requirement but it is very", + "likely you'll be using this font outside of R graphics devices", + "so it does make a bit of sense to have them outside of the R", + "package library directory." + ) + + } + +} + +# #' Install Goldman Sans (Condensed) +# #' +# #' Goldman Sans is a clean, modern typeface designed for dense data-rich +# #' environments. From open letter shapes, enlarged x-height, and optical +# #' balancing of individual letterforms, we designed Goldman Sans with +# #' clarity in mind. Both normal and condensed versions are provided. +# #' +# #' @export +# # install_goldman_sans <- function() { +# install_font("Goldman Sans (Condensed)", "goldman-sans") +# } + +# #' Install Roboto Condensed +# #' +# #' Roboto has a dual nature. It has a mechanical skeleton and the forms are +# #' largely geometric. At the same time, the font features friendly and open +# #' curves. While some grotesks distort their letterforms to force a rigid rhythm, +# #' Roboto doesn’t compromise, allowing letters to be settled into their natural +# #' width. This makes for a more natural reading rhythm more commonly found in +# #' humanist and serif types. +# #' +# #' @note [Apache License, Version 2.0.](http://www.apache.org/licenses/LICENSE-2.0) +# #' @export +# install_roboto_condensed <- function() { +# install_font("Roboto Condensed", "roboto-condensed") +# } + +#' Install Inter +#' +#' Inter is a typeface carefully crafted & designed for computer screens and +#' features a tall x-height to aid in readability of mixed-case and lower-case +#' text. Several OpenType features are provided as well, like contextual +#' alternates that adjusts punctuation depending on the shape of surrounding +#' glyphs, slashed zero for when you need to disambiguate "0" from "o", +#' tabular numbers, etc. +#' +#' +#' @note [SIL Open Font License 1.1](https://choosealicense.com/licenses/ofl-1.1/) +#' @references [Inter](https://rsms.me/inter/) +#' @export +install_inter <- function() { + install_font("Inter", "inter") +} diff --git a/R/reconfigure-font.R b/R/reconfigure-font.R new file mode 100644 index 0000000..fbb2a95 --- /dev/null +++ b/R/reconfigure-font.R @@ -0,0 +1,101 @@ +#' Create an complete, alternate font family with the same customized features +#' +#' @param family font family name +#' @param width font width (defaults to "normal") +#' @param ligatures,letters,numbers See [systemfonts::font_feature()] +#' @param prefix string to use as a prefix to the names of the newly generated font family. +#' If not specified, a guaranteed unique identifier will be used. +#' @param ... Extra four-letter font feature flags passed on to [systemfonts::font_feature()]. See +#' See [Microsoft](https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist) and +#' [Wikipedia](https://en.wikipedia.org/wiki/List_of_typographic_features) for tag descriptions. +#' @return list with names of all the customized font family members. A `family` +#' attribute is included which is the name of the family this variant is +#' based on. +#' @export +#' @examples +#' reconfigure_font( +#' family = "Inter", +#' width = "normal", +#' ligatures = "discretionary", +#' calt = 1, tnum = 1, case = 1, +#' dlig = 1, ss01 = 1, kern = 1, +#' zero = 0, salt = 0 +#' ) -> inter_1 +reconfigure_font <- function(family, width = "normal", + ligatures = NULL, letters = NULL, numbers = NULL, + prefix = uuid::UUIDgenerate(), ...) { + + # make sure the font exists + + fam <- systemfonts::system_fonts() + fam <- fam[tolower(fam$family) == tolower(family) & fam$width == width,] + + if (nrow(fam) == 0) stop("No font family found with the specified name and width.", call. = FALSE) + + # order by weight + + fam <- fam[order(fam$weight),] + + # make sure the font supports all the features specified + + supports <- unlist(textshaping::get_font_features(family)) + supplied <- list(...) + supplied <- setdiff(names(supplied), c("ligatures", "letters", "numbers")) + unsupported <- supplied[!(supplied %in% supports)] + + if (length(unsupported) != 0) { + stop( + sprintf( + "%s does not support (%s) feature%s but does support (%s).", + family, + paste0(unsupported, collapse = ", "), + if (length(unsupported == 1)) "" else "s", + paste0(supports, collapse = ", ") + ), + call. = FALSE + + ) + } + + # set the features we'll use with each variant + + font_feature( + ligatures = ligatures, + letters = letters, + numbers = numbers, + ... + ) -> feat + + # make some room for the return value + + ret <- list() + + # go through each default variant and make a new font with + # the specified feature(s) configuration + + for (idx in 1:nrow(fam)) { + + tmp_nam <- sprintf("%s %s %s", prefix, family, fam$style[idx]) + + idx_nam <- as.character(fam$weight[idx]) + if (fam$italic[idx]) idx_nam <- sprintf("%s_italic", idx_nam) + if (fam$monospace[idx]) idx_nam <- sprintf("%s_mono", idx_nam) + + ret[[idx_nam]] <- tmp_nam + + register_variant( + name = tmp_nam, + weight = as.character(fam$weight[idx]), + features = feat, + family = family, + width = width + ) + + } + + # keep the font name handy + attr(ret, "family") <- family + + ret + +} \ No newline at end of file diff --git a/R/roboto-condensed.R b/R/roboto-condensed.R new file mode 100644 index 0000000..29f22f7 --- /dev/null +++ b/R/roboto-condensed.R @@ -0,0 +1,278 @@ +# #' ggplot2 Theme Based On The Roboto Condensed Font Family +# #' +# #' Uses the built-in [roboto_pkg] custom font. +# #' +# #' - `background_colour` dark mode is "`#121212`" else "`white`" +# #' - `foreground_colour` dark mode is "`#e1e1e1`" else "`#262626`" +# #' - `grid_col` dark mode is "`#606367`" else "`#cccccc`" +# #' - `axis_col` dark mode is "`#606367`" else "`#2b2b2b`" +# #' +# #' @note this function updates `Geom` defaults +# #' @param base_size base font size +# #' @param line_height default line height +# #' @param plot_title_size plot title size +# #' @param plot_title_position plot title position +# #' @param plot_title_margin plot title margin +# #' @param subtitle_size subtitle size +# #' @param subtitle_margin subtitle margin +# #' @param strip_text_size strip text size +# #' @param strip_placement strip placement +# #' @param caption_size caption size +# #' @param caption_margin caption margin +# #' @param axis_text_size axis text size +# #' @param axis_title_size axis title size +# #' @param axis_title_just axis title just +# #' @param text_geom_size text geom size +# #' @param panel_spacing panel spacing +# #' @param plot_margin plot margin +# #' @param grid_col grid col +# #' @param grid grid +# #' @param axis_col axis col +# #' @param axis axis +# #' @param ticks ticks +# #' @return ggplot2 theme +# #' @export +# #' @examples +# #' ggplot() + +# #' geom_point( +# #' data = mtcars, +# #' aes(mpg, wt) +# #' ) + +# #' geom_label( +# #' aes( +# #' x = 30, y = 4.5, +# #' label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." +# #' ), +# #' label.size = 0 +# #' ) + +# #' labs( +# #' x = "Fuel efficiency (mpg)", y = "Weight (tons)", +# #' title = "Seminal ggplot2 scatterplot example", +# #' subtitle = "A plot that is only useful for demonstration purposes", +# #' caption = "Brought to you by the letter 'g'" +# #' ) + +# #' theme_inter(grid = "XY") + +# theme_inter <- function( +# base_size = 10, +# line_height = 0.875, +# plot_title_size = 18, +# plot_title_position = "panel", +# plot_title_margin = 10, +# subtitle_size = 12, +# subtitle_margin = 12, +# strip_text_size = 12, +# strip_placement = "outer", +# caption_size = 9, +# caption_margin = 10, +# axis_text_size = base_size, +# axis_title_size = 9, +# axis_title_just = "rt", +# panel_spacing = grid::unit(2, "lines"), +# plot_margin = margin(30, 30, 30, 30), +# mode = c("light", "dark", "rstudio"), +# background_colour = theme_background_color(mode, light = "white", dark = "#121212"), +# foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), +# grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), +# axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), +# grid = TRUE, +# axis = FALSE, +# ticks = FALSE) { +# +# base_family <- inter_pkg$normal +# plot_title_family <- inter_pkg$ultrabold +# subtitle_family <- inter_pkg$medium +# strip_text_family <- inter_pkg$semibold +# axis_text_family <- inter_pkg$normal +# caption_family <- inter_pkg$normal +# axis_title_family <- inter_pkg$medium +# +# c( +# "GeomRect", "GeomLabel", "GeomTile", "GeomViolin" +# ) -> has_reverse_cols +# +# geoms <- ls(pattern = '^Geom', env = as.environment('package:ggplot2')) +# +# for (geom in geoms) { +# +# update_geom_defaults( +# geom = get(geom), +# new = list( +# arrow.fill = background_colour, +# outlier.colour = foreground_colour, +# outlier.fill = background_colour, +# colour = foreground_colour, +# fill = if (geom %in% c(has_reverse_cols)) background_colour else NA, +# family = base_family, +# lineheight = line_height +# ) +# ) +# +# } +# +# theme_minimal( +# base_family = base_family, +# base_size = base_size, +# ) + +# theme( +# rect = element_rect(colour = foreground_colour, fill = background_colour), +# line = element_line(colour = foreground_colour), +# title = element_text(colour = foreground_colour), +# legend.background = element_blank(), +# legend.key = element_blank(), +# legend.text = element_text(colour = foreground_colour, family = inter_pkg$medium), +# legend.title = element_text(colour = foreground_colour, family = inter_pkg$semibold) +# ) -> ret +# +# +# if (inherits(grid, "character") | grid == TRUE) { +# +# ret + +# theme( +# panel.grid = element_line(colour = grid_col, size = 0.2), +# panel.grid.major = element_line(colour = grid_col, size = 0.2), +# panel.grid.minor = element_line(colour = grid_col, size = 0.15) +# ) -> ret +# +# if (inherits(grid, "character")) { +# if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x = element_blank()) +# if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y = element_blank()) +# if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x = element_blank()) +# if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y = element_blank()) +# } +# +# } else { +# ret <- ret + theme(panel.grid = element_blank()) +# } +# +# if (inherits(axis, "character") | axis == TRUE) { +# ret <- ret + theme(axis.line = element_line(colour = axis_col, size = 0.15)) +# if (inherits(axis, "character")) { +# axis <- tolower(axis) +# if (regexpr("x", axis)[1] < 0) { +# ret <- ret + theme(axis.line.x = element_blank()) +# } else { +# ret <- ret + theme(axis.line.x = element_line(colour = axis_col, size = 0.15)) +# } +# if (regexpr("y", axis)[1] < 0) { +# ret <- ret + theme(axis.line.y = element_blank()) +# } else { +# ret <- ret + theme(axis.line.y = element_line(colour = axis_col, size = 0.15)) +# } +# } else { +# ret + theme( +# axis.line.x = element_line(colour = axis_col, size = 0.15), +# axis.line.y = element_line(colour = axis_col, size = 0.15) +# ) -> ret +# } +# } else { +# ret <- ret + theme(axis.line = element_blank()) +# } +# +# if (!ticks) { +# +# ret + theme( +# axis.ticks = element_blank(), +# axis.ticks.x = element_blank(), +# axis.ticks.y = element_blank() +# ) -> ret +# +# } else { +# +# ret + theme( +# axis.ticks = element_line(size = 0.15), +# axis.ticks.x = element_line(size = 0.15), +# axis.ticks.y = element_line(size = 0.15), +# axis.ticks.length = grid::unit(5, "pt") +# ) -> ret +# +# } +# +# xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) +# yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) +# +# ret + +# theme( +# axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), +# axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), +# axis.text.x.bottom = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), +# +# axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), +# axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), +# axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), +# +# axis.title = element_text( +# size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# +# axis.title.x = element_text( +# hjust = xj, size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# axis.title.x.top = element_text( +# hjust = xj, size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# axis.title.x.bottom = element_text( +# hjust = xj, size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# +# axis.title.y = element_text( +# hjust = yj, size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# axis.title.y.left = element_text( +# hjust = yj, size = axis_title_size, +# family = axis_title_family, lineheight = line_height +# ), +# axis.title.y.right = element_text( +# hjust = yj, size = axis_title_size, angle = 90, +# family = axis_title_family, lineheight = line_height +# ), +# +# strip.placement = strip_placement, +# strip.text = element_text( +# hjust = 0, size = strip_text_size, color = foreground_colour, +# family = strip_text_family, lineheight = line_height +# ), +# strip.text.x = element_text( +# hjust = 0, size = strip_text_size, color = foreground_colour, +# family = strip_text_family, lineheight = line_height +# ), +# strip.background = element_rect( +# fill = background_colour, color = NA +# ), +# strip.background.x = element_rect( +# fill = background_colour, color = NA +# ), +# strip.background.y = element_rect( +# fill = background_colour, color = NA +# ), +# strip.text.y = element_text( +# hjust = 0, size = strip_text_size, color = foreground_colour, +# family = strip_text_family, lineheight = line_height +# ), +# panel.spacing = panel_spacing, +# panel.background = element_rect(color = NA, fill = background_colour), +# plot.background = element_rect(color = NA, fill = background_colour), +# plot.title.position = plot_title_position, +# plot.margin = plot_margin, +# plot.title = element_text( +# hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), +# family = plot_title_family, lineheight = line_height +# ), +# plot.subtitle = element_text( +# hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), +# family = subtitle_family, lineheight = line_height +# ), +# plot.caption = element_text( +# hjust = 1, size = caption_size, margin = margin(t = caption_margin), +# family = caption_family, lineheight = line_height +# ), +# ) -> ret +# +# ret +# +# } diff --git a/R/shortcuts.R b/R/shortcuts.R new file mode 100644 index 0000000..301425d --- /dev/null +++ b/R/shortcuts.R @@ -0,0 +1,25 @@ +#' Shortcut for `element_blank` +#' @return An S3 object of class element, rel, or margin. +#' @export +elb <- ggplot2::element_blank + +#' Shortcut for `element_line` +#' +#' @param colour,size,linetype,lineend,color,arrow,inherit.blank +#' See [ggplot2::element_line()] +#' @return An S3 object of class element, rel, or margin. +#' @export +ell <- ggplot2::element_line + +#' Shortcut for `element_text` +#' @param family,face,colour,size,hjust,vjust,angle,lineheight,color,margin,debug,inherit.blank +#' See [ggplot2::element_text()] +#' @export +elt <- ggplot2::element_text + +#' Shortcut for `element_rect` +#' @param fill,colour,size,linetype,color,inherit.blank +#' See [ggplot2::element_rect()] +#' @return An S3 object of class element, rel, or margin. +#' @export +elr <- ggplot2::element_rect diff --git a/R/theme-colors.R b/R/theme-colors.R new file mode 100644 index 0000000..5cf852c --- /dev/null +++ b/R/theme-colors.R @@ -0,0 +1,36 @@ +#' Adaptive colors colors for {hrbragg} themes +#' +#' Explicit foreground/background theme color functions are provided +#' along with the primary adaptive color switcher function. +#' +#' @param mode `dark`, `light`, or `rstudio` to base it on RStudio's active theme +#' @param light,dark light and dark colors to auto-select from +#' @param dark dark color to use +#' @return length 1 character vector that represents a valid color +#' @export +#' @examples +#' theme_background_color() +adaptive_color <- function(mode = c("light", "dark", "rstudio"), light, dark) { + + mode <- match.arg(mode[1], c("dark", "light", "rstudio")) + + if (mode == "rstudio") mode <- if (rstudioapi::getThemeInfo()[["dark"]]) "dark" else "light" + + c("light" = light, "dark" = dark)[mode] + +} + + +#' @rdname adaptive_color +#' @export +theme_background_color <- function(mode = c("light", "dark", "rstudio"), + light = "white", dark = "#121212") { + adaptive_color(mode, light, dark) +} + +#' @rdname adaptive_color +#' @export +theme_foreground_color <- function(mode = c("light", "dark", "rstudio"), + light = "#262626", dark = "#e1e1e1") { + adaptive_color(mode, light, dark) +} diff --git a/R/theme-inter.R b/R/theme-inter.R new file mode 100644 index 0000000..7ca9bb5 --- /dev/null +++ b/R/theme-inter.R @@ -0,0 +1,277 @@ +#' ggplot2 Theme Based On The Inter Font Family +#' +#' Uses the built-in [inter_pkg] custom font. +#' +#' - `background_colour` dark mode is "`#121212`" else "`white`" +#' - `foreground_colour` dark mode is "`#e1e1e1`" else "`#262626`" +#' - `grid_col` dark mode is "`#606367`" else "`#cccccc`" +#' - `axis_col` dark mode is "`#606367`" else "`#2b2b2b`" +#' +#' @note this function updates `Geom` defaults +#' @param base_size base font size +#' @param line_height default line height +#' @param plot_title_size plot title size +#' @param plot_title_position plot title position +#' @param plot_title_margin plot title margin +#' @param subtitle_size subtitle size +#' @param subtitle_margin subtitle margin +#' @param strip_text_size strip text size +#' @param strip_placement strip placement +#' @param caption_size caption size +#' @param caption_margin caption margin +#' @param axis_text_size axis text size +#' @param axis_title_size axis title size +#' @param axis_title_just axis title just +#' @param text_geom_size text geom size +#' @param panel_spacing panel spacing +#' @param plot_margin plot margin +#' @param grid_col grid col +#' @param grid grid +#' @param axis_col axis col +#' @param axis axis +#' @param ticks ticks +#' @return ggplot2 theme +#' @export +#' @examples +#' ggplot() + +#' geom_point( +#' data = mtcars, +#' aes(mpg, wt) +#' ) + +#' geom_label( +#' aes( +#' x = 30, y = 4.5, +#' label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." +#' ), +#' label.size = 0 +#' ) + +#' labs( +#' x = "Fuel efficiency (mpg)", y = "Weight (tons)", +#' title = "Seminal ggplot2 scatterplot example", +#' subtitle = "A plot that is only useful for demonstration purposes", +#' caption = "Brought to you by the letter 'g'" +#' ) + +#' theme_inter(grid = "XY") +theme_inter <- function( + base_size = 10, + line_height = 0.875, + plot_title_size = 18, + plot_title_position = "panel", + plot_title_margin = 10, + subtitle_size = 12, + subtitle_margin = 12, + strip_text_size = 12, + strip_placement = "outer", + caption_size = 9, + caption_margin = 10, + axis_text_size = base_size, + axis_title_size = 9, + axis_title_just = "rt", + panel_spacing = grid::unit(2, "lines"), + plot_margin = margin(30, 30, 30, 30), + mode = c("light", "dark", "rstudio"), + background_colour = theme_background_color(mode, light = "white", dark = "#121212"), + foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), + grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), + axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), + grid = TRUE, + axis = FALSE, + ticks = FALSE) { + + base_family <- inter_pkg$normal + plot_title_family <- inter_pkg$ultrabold + subtitle_family <- inter_pkg$medium + strip_text_family <- inter_pkg$semibold + axis_text_family <- inter_pkg$normal + caption_family <- inter_pkg$normal + axis_title_family <- inter_pkg$medium + + c( + "GeomRect", "GeomLabel", "GeomTile", "GeomViolin" + ) -> has_reverse_cols + + geoms <- ls(pattern = '^Geom', env = as.environment('package:ggplot2')) + + for (geom in geoms) { + + update_geom_defaults( + geom = get(geom), + new = list( + arrow.fill = background_colour, + outlier.colour = foreground_colour, + outlier.fill = background_colour, + colour = foreground_colour, + fill = if (geom %in% c(has_reverse_cols)) background_colour else NA, + family = base_family, + lineheight = line_height + ) + ) + + } + + theme_minimal( + base_family = base_family, + base_size = base_size, + ) + + theme( + rect = element_rect(colour = foreground_colour, fill = background_colour), + line = element_line(colour = foreground_colour), + title = element_text(colour = foreground_colour), + legend.background = element_blank(), + legend.key = element_blank(), + legend.text = element_text(colour = foreground_colour, family = inter_pkg$medium), + legend.title = element_text(colour = foreground_colour, family = inter_pkg$semibold) + ) -> ret + + + if (inherits(grid, "character") | grid == TRUE) { + + ret + + theme( + panel.grid = element_line(colour = grid_col, size = 0.2), + panel.grid.major = element_line(colour = grid_col, size = 0.2), + panel.grid.minor = element_line(colour = grid_col, size = 0.15) + ) -> ret + + if (inherits(grid, "character")) { + if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x = element_blank()) + if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y = element_blank()) + if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x = element_blank()) + if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y = element_blank()) + } + + } else { + ret <- ret + theme(panel.grid = element_blank()) + } + + if (inherits(axis, "character") | axis == TRUE) { + ret <- ret + theme(axis.line = element_line(colour = axis_col, size = 0.15)) + if (inherits(axis, "character")) { + axis <- tolower(axis) + if (regexpr("x", axis)[1] < 0) { + ret <- ret + theme(axis.line.x = element_blank()) + } else { + ret <- ret + theme(axis.line.x = element_line(colour = axis_col, size = 0.15)) + } + if (regexpr("y", axis)[1] < 0) { + ret <- ret + theme(axis.line.y = element_blank()) + } else { + ret <- ret + theme(axis.line.y = element_line(colour = axis_col, size = 0.15)) + } + } else { + ret + theme( + axis.line.x = element_line(colour = axis_col, size = 0.15), + axis.line.y = element_line(colour = axis_col, size = 0.15) + ) -> ret + } + } else { + ret <- ret + theme(axis.line = element_blank()) + } + + if (!ticks) { + + ret + theme( + axis.ticks = element_blank(), + axis.ticks.x = element_blank(), + axis.ticks.y = element_blank() + ) -> ret + + } else { + + ret + theme( + axis.ticks = element_line(size = 0.15), + axis.ticks.x = element_line(size = 0.15), + axis.ticks.y = element_line(size = 0.15), + axis.ticks.length = grid::unit(5, "pt") + ) -> ret + + } + + xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) + yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) + + ret + + theme( + axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), + axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), + axis.text.x.bottom = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), + + axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), + axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), + axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), + + axis.title = element_text( + size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + + axis.title.x = element_text( + hjust = xj, size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + axis.title.x.top = element_text( + hjust = xj, size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + axis.title.x.bottom = element_text( + hjust = xj, size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + + axis.title.y = element_text( + hjust = yj, size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + axis.title.y.left = element_text( + hjust = yj, size = axis_title_size, + family = axis_title_family, lineheight = line_height + ), + axis.title.y.right = element_text( + hjust = yj, size = axis_title_size, angle = 90, + family = axis_title_family, lineheight = line_height + ), + + strip.placement = strip_placement, + strip.text = element_text( + hjust = 0, size = strip_text_size, color = foreground_colour, + family = strip_text_family, lineheight = line_height + ), + strip.text.x = element_text( + hjust = 0, size = strip_text_size, color = foreground_colour, + family = strip_text_family, lineheight = line_height + ), + strip.background = element_rect( + fill = background_colour, color = NA + ), + strip.background.x = element_rect( + fill = background_colour, color = NA + ), + strip.background.y = element_rect( + fill = background_colour, color = NA + ), + strip.text.y = element_text( + hjust = 0, size = strip_text_size, color = foreground_colour, + family = strip_text_family, lineheight = line_height + ), + panel.spacing = panel_spacing, + panel.background = element_rect(color = NA, fill = background_colour), + plot.background = element_rect(color = NA, fill = background_colour), + plot.title.position = plot_title_position, + plot.margin = plot_margin, + plot.title = element_text( + hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), + family = plot_title_family, lineheight = line_height + ), + plot.subtitle = element_text( + hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), + family = subtitle_family, lineheight = line_height + ), + plot.caption = element_text( + hjust = 1, size = caption_size, margin = margin(t = caption_margin), + family = caption_family, lineheight = line_height + ), + ) -> ret + + ret + +} diff --git a/R/utils.R b/R/utils.R new file mode 100644 index 0000000..b55e31b --- /dev/null +++ b/R/utils.R @@ -0,0 +1,10 @@ +is_windows <- function() .Platform$OS.type == "windows" +is_mac <- function() Sys.info()[["sysname"]] == "Darwin" +is_linux <- function() Sys.info()[["sysname"]] == "Linux" + +platform <- function() { + if (is_windows()) return("win") + if (is_mac()) return("mac") + if (is_linux()) return("linux") + stop("unknown platform") +} \ No newline at end of file diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..6b0c8dd --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,69 @@ +#' Inter Font Variant +#' +#' On load {hrbragg} creates a custom Inter font family variant +#' and makes it available in the global environment. +#' +#' The reconfigured family variant has the following features: +#' +#' - `calt`: (_Contextual Alternates_): Applies a second substitution feature +#' based on a match of a character pattern within a context of surrounding patterns +#' - `case` (_Case Sensitive Forms_): Replace characters, especially punctuation, with forms better suited for all-capital text, cf. titl +#' - `dlig`/`ligatures` (_Discretionary Ligatures_): Ligatures to be applied at the user's discretion +#' - `kern` (_Kerning_): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs +#' - `salt` (_Stylistic Alternates_): **DISABLED** — Either replaces with, or displays list of, stylistic alternatives for a character +#' - `ss01` (_Stylistic set 1: Alternate digits_): An alternate style of digits. +#' - `tnum` (_Tabular Figures_): Replaces numerals with glyphs of uniform width, often also lnum +#' - `zero` (_Slashed Zero_): **DISABLED** — Replaces 0 figure with slashed 0 +#' +#' Inter online documentation has [specific descriptions and exaples of these features](https://rsms.me/inter/#features). +#' +#' This object has the following names corresponding to individual, +#' customized font variants (ordered by font weight): +#' +#' - `ultralight` +#' - `ultralight_italic` +#' - `light` +#' - `light_italic` +#' - `normal_italic` +#' - `normal` +#' - `medium_italic` +#' - `medium` +#' - `semibold_italic` +#' - `semibold` +#' - `bold` +#' - `bold_italic` +#' - `ultrabold` +#' - `ultrabold_italic` +#' - `heavy` +#' - `heavy_italic` +#' +#' @docType data +#' @format A list +#' @export +inter_pkg <- NULL + +.onLoad <- function(...) { + + if (systemfonts::font_info("Inter")[["family"]][1] == "Inter") { + + if (interactive()) packageStartupMessage("Registering 'Inter' font variant.") + + reconfigure_font( + prefix = "hrbragg-pkg", + family = "Inter", + width = "normal", + ligatures = "discretionary", + calt = 1, tnum = 1, case = 1, + dlig = 1, ss01 = 1, kern = 1, + zero = 0, salt = 0 + ) ->> inter_pkg + + } else { + + packageStartupMessage( + "Please run `install_inter()`. This is only an interim requirement." + ) + + } + +} diff --git a/README.Rmd b/README.Rmd index 68443e2..65f2422 100644 --- a/README.Rmd +++ b/README.Rmd @@ -7,6 +7,12 @@ editor_options: hrbrpkghelpr::global_opts() ``` +```{r ragg, echo = FALSE} +knitr::opts_chunk$set( + dev = "ragg_png" +) +``` + ```{r badges, results='asis', echo=FALSE, cache=FALSE} hrbrpkghelpr::stinking_badges() ``` @@ -33,12 +39,78 @@ hrbrpkghelpr::install_block() ```{r lib-ex} library(hrbragg) +library(ggplot2) # current version packageVersion("hrbragg") ``` +For the moment, you'll need to install Inter: + +```{r install-font, eval = FALSE} +install_inter() +``` + +```{r ex-00} +str(inter_pkg, 1) +``` + +```{r ex-01} +ggplot() + + geom_point( + data = mtcars, + aes(mpg, wt, color = factor(cyl)) + ) + + geom_label( + aes( + x = 15, y = 5.48, + label = "<- A fairly useless annotation\n that uses the custom Inter\n variant by default." + ), + label.size = 0, hjust = 0, vjust = 1 + ) + + labs( + x = "Fuel efficiency (mpg)", y = "Weight (tons)", + title = "Seminal ggplot2 scatterplot example", + subtitle = "A plot that is only useful for demonstration purposes", + caption = "Brought to you by the letter 'g'" + ) -> gg1 +``` + + +```{r dark-mode-01} +gg1 + theme_inter(grid = "XY", mode = "dark") +``` + +```{r light-mode-01} +gg1 + theme_inter(grid = "XY", mode = "light") +``` + +```{r ex-02} +ggplot() + + geom_point( + data = mpg, + aes(displ, hwy, color = trans) + ) + + facet_wrap( + vars(cyl, drv), scales = "free", drop = TRUE + ) + + labs( + x = "Displacement", y = "Highway", + title = "Another seminal ggplot2 scatterplot example", + subtitle = "A plot that is only useful for demonstration purposes", + caption = "Brought to you by the letter 'g'" + ) -> gg2 +``` + +```{r light-mode-02, fig.width=1400/96, fig.height=700/96} +gg2 + theme_inter(grid = "XY", mode = "light") +``` + +```{r dark-mode-02, fig.width=1400/96, fig.height=700/96} +gg2 + theme_inter(grid = "XY", mode = "dark") +``` + ## hrbragg Metrics ```{r cloc, echo=FALSE} @@ -47,5 +119,4 @@ cloc::cloc_pkg_md() ## Code of Conduct -Please note that this project is released with a Contributor Code of Conduct. -By participating in this project you agree to abide by its terms. +Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. diff --git a/README.md b/README.md new file mode 100644 index 0000000..21ec0e3 --- /dev/null +++ b/README.md @@ -0,0 +1,173 @@ + +[![Project Status: Active – The project has reached a stable, usable +state and is being actively +developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![Signed +by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr) +![Signed commit +%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg) +[![Linux build +Status](https://travis-ci.org/hrbrmstr/hrbragg.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbragg) +![Minimal R +Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg) +![License](https://img.shields.io/badge/License-MIT-blue.svg) + +# hrbragg + +Typography-centric Themes, Theme Components, and Utilities for ‘ggplot2’ +and ‘ragg’. + +## Description + +The ‘ragg’, ‘systemfonts’, and ‘textshaping’ packages make it possible +to create plot components and themes that make full use of the rich +typography features in modern fonts. Fonts, themes, and utilities are +provided to create ‘ggplot2’ plots intended for rendering on ‘ragg’ +graphics devices. + +## What’s Inside The Tin + +The following functions are implemented: + +- `adaptive_color`: Adaptive colors colors for hrbragg themes +- `elb`: Shortcut for element\_blank +- `ell`: Shortcut for element\_line +- `elr`: Shortcut for element\_rect +- `elt`: Shortcut for element\_text +- `feature_dict`: OpenType feature description lookup table +- `install_inter`: Install Inter +- `inter_pkg`: Inter Font Variant +- `opentype_typographic_features`: OpenType Typographic Features +- `reconfigure_font`: Create an complete, alternate font family with + the same customized features +- `theme_inter`: ggplot2 Theme Based On The Inter Font Family + +## Installation + +``` r +remotes::install_git("https://git.rud.is/hrbrmstr/hrbragg.git") +# or +remotes::install_gitlab("hrbrmstr/hrbragg") +# or +remotes::install_bitbucket("hrbrmstr/hrbragg") +``` + +NOTE: To use the ‘remotes’ install options you will need to have the +[{remotes} package](https://github.com/r-lib/remotes) installed. + +## Usage + +``` r +library(hrbragg) +library(ggplot2) + +# current version +packageVersion("hrbragg") +## [1] '0.1.0' +``` + +For the moment, you’ll need to install Inter: + +``` r +install_inter() +``` + +``` r +str(inter_pkg, 1) +## List of 16 +## $ ultralight : chr "hrbragg-pkg Inter Thin" +## $ ultralight_italic: chr "hrbragg-pkg Inter Thin Italic" +## $ light : chr "hrbragg-pkg Inter Extra Light" +## $ light_italic : chr "hrbragg-pkg Inter Extra Light Italic" +## $ normal_italic : chr "hrbragg-pkg Inter Light Italic" +## $ normal : chr "hrbragg-pkg Inter Light" +## $ medium_italic : chr "hrbragg-pkg Inter Medium Italic" +## $ medium : chr "hrbragg-pkg Inter Medium" +## $ semibold_italic : chr "hrbragg-pkg Inter Semi Bold Italic" +## $ semibold : chr "hrbragg-pkg Inter Semi Bold" +## $ bold : chr "hrbragg-pkg Inter Bold" +## $ bold_italic : chr "hrbragg-pkg Inter Bold Italic" +## $ ultrabold : chr "hrbragg-pkg Inter Extra Bold" +## $ ultrabold_italic : chr "hrbragg-pkg Inter Extra Bold Italic" +## $ heavy : chr "hrbragg-pkg Inter Black" +## $ heavy_italic : chr "hrbragg-pkg Inter Black Italic" +## - attr(*, "family")= chr "Inter" +``` + +``` r +ggplot() + + geom_point( + data = mtcars, + aes(mpg, wt, color = factor(cyl)) + ) + + geom_label( + aes( + x = 15, y = 5.48, + label = "<- A fairly useless annotation\n that uses the custom Inter\n variant by default." + ), + label.size = 0, hjust = 0, vjust = 1 + ) + + labs( + x = "Fuel efficiency (mpg)", y = "Weight (tons)", + title = "Seminal ggplot2 scatterplot example", + subtitle = "A plot that is only useful for demonstration purposes", + caption = "Brought to you by the letter 'g'" + ) -> gg1 +``` + +``` r +gg1 + theme_inter(grid = "XY", mode = "dark") +``` + + + +``` r +gg1 + theme_inter(grid = "XY", mode = "light") +``` + + + +``` r +ggplot() + + geom_point( + data = mpg, + aes(displ, hwy, color = trans) + ) + + facet_wrap( + vars(cyl, drv), scales = "free", drop = TRUE + ) + + labs( + x = "Displacement", y = "Highway", + title = "Another seminal ggplot2 scatterplot example", + subtitle = "A plot that is only useful for demonstration purposes", + caption = "Brought to you by the letter 'g'" + ) -> gg2 +``` + +``` r +gg2 + theme_inter(grid = "XY", mode = "light") +``` + + + +``` r +gg2 + theme_inter(grid = "XY", mode = "dark") +``` + + + +## hrbragg Metrics + +| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | +|:-----|---------:|-----:|----:|-----:|------------:|-----:|---------:|-----:| +| R | 13 | 0.46 | 332 | 0.43 | 89 | 0.39 | 646 | 0.47 | +| Rmd | 1 | 0.04 | 50 | 0.07 | 26 | 0.11 | 46 | 0.03 | +| SUM | 14 | 0.50 | 382 | 0.50 | 115 | 0.50 | 692 | 0.50 | + +clock Package Metrics for hrbragg + +## Code of Conduct + +Please note that this project is released with a Contributor Code of +Conduct. By participating in this project you agree to abide by its +terms. diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R new file mode 100644 index 0000000..8343e80 --- /dev/null +++ b/data-raw/DATASET.R @@ -0,0 +1,21 @@ +## code to prepare `feature_dict` dataset goes here + +library(rvest) +library(tidyverse) + +pg <- read_html("https://en.wikipedia.org/wiki/List_of_typographic_features") + +pg %>% + html_nodes(xpath = ".//table[contains(., 'Long name')]") %>% + map_df(html_table) %>% + as_tibble() %>% + janitor::clean_names() %>% + # mutate( + # doc = sprintf( + # "- `%s` (_%s_): %s", tag, long_name, description + # ) + # ) %>% + arrange(tag) %>% + select(tag, long_name, description) -> feature_dict + +usethis::use_data(feature_dict, overwrite = TRUE) diff --git a/data/feature_dict.rda b/data/feature_dict.rda new file mode 100644 index 0000000..c6025e5 Binary files /dev/null and b/data/feature_dict.rda differ diff --git a/inst/COPYRIGHTS b/inst/COPYRIGHTS new file mode 100644 index 0000000..014c818 --- /dev/null +++ b/inst/COPYRIGHTS @@ -0,0 +1,325 @@ +The fonts included with this package have the following licenses/copyrights: + + +Goldman + +--- Roboto Condensed ---------------------------------------------------------- + +Roboto Condensed is in `fonts/roboto-condensed` and is Apache 2.0 licensed. +A copy of the generic Apache License (which is what the font distribution used) +is included at the end of this document. + +--- Goldman Sans -------------------------------------------------------------- + +Goldman Sans is in `fonts/goldman-sans` and is Goldman Sans Restricted Font licensed. A copy of the Goldman Sachs Restricted Font License +is included at the end of this document. + +--- Goldman Sachs Restricted Font License ------------------------------------ + +Goldman Sachs Restricted Font License + +A. Background Goldman Sachs & Co. LLC (“Goldman Sachs”) owns the +copyright interests in and to a font style entitled “Goldman Sans” +(“Licensed Font”). Goldman Sachs is providing this license of the +Licensed Font software (the “License”) free of charge as long as it is +used in compliance with this License. + +B. Definitions A “Font” is a typeface that can be used for text, +character display, HTML, style sheets, and the like; it includes the +normal character set, as well as additional font styles such as +underlined, bold, and italicized. + +“Licensed Font Software” refers to the set of files released by Goldman +“Sachs under this License to the Goldman Sans Font, and may include +“source files, build scripts and documentation. + +C. Grant and Scope of License By reproducing, distributing, publicly +displaying or otherwise using the Licensed Font Software, you agree to +abide by this License. Anyone who uses the Licensed Font Software is a +“User,” regardless of how, where, or from whom the Licensed Font +Software is obtained. + +The User is hereby granted a limited, royalty-free, nonexclusive, and +revocable license to use, reproduce, and distribute unmodified copies of +the Licensed Font Software, subject to the following conditions: + +a. The User may not modify or make derivative works of or sell (by +itself or with any other item or software), sub-license, bundle, or +embed copies of the Licensed Font Software. + +b. The User may not use the Licensed Font Software in any “open source” +or other code that would create any obligation for Goldman Sachs to: (i) +grant to any third party any intellectual property or other proprietary +rights; (ii) disclose or make any source code or any part or derivative +work thereof available to third parties under any circumstances; or +(iii) otherwise subject Goldman Sachs to any obligations not expressly +set forth in this License. + +c. The User may not use the Licensed Font Software to suggest any +affiliation with or endorsement by Goldman Sachs. + +d. If a User distributes a copy of the Licensed Font Software, each copy +shall bear an appropriate copyright notice in substantially the form of +“© 2020 Goldman Sachs & Co. LLC. All rights reserved.” and a copy of +this License. The Licensed Font Software must be distributed entirely +under this License and must not be distributed under any other license. +The requirement for the Licensed Font Software to remain under this +License does not apply to any document created using the Licensed Font +Software. + +User expressly agrees that all proprietary right, title, and interest in +and to and control of the Licensed Font Software are and shall at all +times be solely owned by Goldman Sachs and hereby acknowledges that +nothing contained in this License shall give User any right, title. or +interest in or to the ownership or use of the Licensed Font Software, +except the restricted use provided herein. + +D. Trademarks “GOLDMAN,” “GOLDMAN SACHS,” and “GOLDMAN SANS” +(collectively the “Trademarks”) are trademarks of Goldman Sachs or its +affiliates. “GOLDMAN SANS” may be used by licensed Users only to +identify the Licensed Font or Licensed Font Software. The name(s) of +Goldman Sachs or the Trademarks shall not be used to promote, endorse or +advertise any User, or to suggest any affiliation with or endorsement by +Goldman Sachs. Users shall not otherwise use or attempt to register the +Trademarks or any confusingly similar marks. + +E. Term and Termination of the License The term of the License is for +the unexpired term of, and for so long as Goldman Sachs owns, the +copyright on the Licensed Font Software, or any renewal thereof. This +License shall terminate and become null and void for any use that does +not comply with any of the conditions in this License. Goldman Sachs +may, at its sole discretion, terminate this License at any time. Goldman +Sachs’s exercise of any right of termination does not constitute a +waiver of other rights and remedies available to Goldman Sachs. F. +Disclaimer of Warranties; Limitation of Liability THE LICENSED FONT +SOFTWARE IS PROVIDED “AS IS” AND “WITH ALL FAULTS,” WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY +WARRANTIES OF QUALITY, ACCURACY, MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NON-INFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, +OR OTHER RIGHT. IN NO EVENT SHALL GOLDMAN SACHS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, INCLUDING ANY DIRECT, LOST PROFIT, LOST +REVENUE, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, EXEMPLARY OR +CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT, UNDER ANY +WARRANTY OR ANY OTHER THEORY OF LIABILITY, ARISING OUT OF OR IN +CONNECTION WITH THIS LICENSE, THE USE OR INABILITY TO USE THE LICENSED +FONT SOFTWARE OR FROM OTHER DEALINGS IN THE LICENSED FONT SOFTWARE, EVEN +IF IT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE RISK OF +THE PERFORMANCE AND QUALITY OF LICENSED FONT SOFTWARE IS STRICTLY ON THE +USER AND THE USER MUST REPAIR THE LICENSED FONT SOFTWARE AT THEIR OWN +EXPENSE. + +G. Governing Law This License shall be governed by and construed under +the laws of the State of New York. The User and Goldman Sachs hereby +waive any right to a trial by jury and consent to exclusive jurisdiction +of the U.S. District Court for the Southern District of New York or, if +federal jurisdiction is lacking, New York Supreme Court, New York +County, for the resolution of any dispute regarding this License or the +parties’ relationship arising therefrom. + +H. Entire Agreement; Amendment Without Notice This is the entire +agreement with respect to its subject matter. This License may be +amended at any time by Goldman Sachs without notice. + +--- Apache v2 (generic) ------------------------------------------------------ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Bd.ttf b/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Bd.ttf new file mode 100755 index 0000000..e3c07e7 Binary files /dev/null and b/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Bd.ttf differ diff --git a/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Rg.ttf b/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Rg.ttf new file mode 100755 index 0000000..6449876 Binary files /dev/null and b/inst/fonts/goldman-sans-condensed/GoldmanSansCd_Rg.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSansCd_Bd.ttf b/inst/fonts/goldman-sans/GoldmanSansCd_Bd.ttf new file mode 100755 index 0000000..e3c07e7 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSansCd_Bd.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSansCd_Rg.ttf b/inst/fonts/goldman-sans/GoldmanSansCd_Rg.ttf new file mode 100755 index 0000000..6449876 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSansCd_Rg.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Bd.ttf b/inst/fonts/goldman-sans/GoldmanSans_Bd.ttf new file mode 100755 index 0000000..f7fedca Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Bd.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_BdIt.ttf b/inst/fonts/goldman-sans/GoldmanSans_BdIt.ttf new file mode 100755 index 0000000..b2ce00e Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_BdIt.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Blk.ttf b/inst/fonts/goldman-sans/GoldmanSans_Blk.ttf new file mode 100755 index 0000000..44bbbc7 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Blk.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_It.ttf b/inst/fonts/goldman-sans/GoldmanSans_It.ttf new file mode 100755 index 0000000..015d374 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_It.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Lt.ttf b/inst/fonts/goldman-sans/GoldmanSans_Lt.ttf new file mode 100755 index 0000000..a4f2779 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Lt.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Md.ttf b/inst/fonts/goldman-sans/GoldmanSans_Md.ttf new file mode 100755 index 0000000..4d0bb07 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Md.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_MdIt.ttf b/inst/fonts/goldman-sans/GoldmanSans_MdIt.ttf new file mode 100755 index 0000000..79a5d3d Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_MdIt.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Rg.ttf b/inst/fonts/goldman-sans/GoldmanSans_Rg.ttf new file mode 100755 index 0000000..3d6b10a Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Rg.ttf differ diff --git a/inst/fonts/goldman-sans/GoldmanSans_Th.ttf b/inst/fonts/goldman-sans/GoldmanSans_Th.ttf new file mode 100755 index 0000000..6e95e60 Binary files /dev/null and b/inst/fonts/goldman-sans/GoldmanSans_Th.ttf differ diff --git a/inst/fonts/inter/Inter-Black.otf b/inst/fonts/inter/Inter-Black.otf new file mode 100644 index 0000000..8394a9f Binary files /dev/null and b/inst/fonts/inter/Inter-Black.otf differ diff --git a/inst/fonts/inter/Inter-BlackItalic.otf b/inst/fonts/inter/Inter-BlackItalic.otf new file mode 100644 index 0000000..b24c8ca Binary files /dev/null and b/inst/fonts/inter/Inter-BlackItalic.otf differ diff --git a/inst/fonts/inter/Inter-Bold.otf b/inst/fonts/inter/Inter-Bold.otf new file mode 100644 index 0000000..ed9019a Binary files /dev/null and b/inst/fonts/inter/Inter-Bold.otf differ diff --git a/inst/fonts/inter/Inter-BoldItalic.otf b/inst/fonts/inter/Inter-BoldItalic.otf new file mode 100644 index 0000000..be8a3d3 Binary files /dev/null and b/inst/fonts/inter/Inter-BoldItalic.otf differ diff --git a/inst/fonts/inter/Inter-ExtraBold.otf b/inst/fonts/inter/Inter-ExtraBold.otf new file mode 100644 index 0000000..e96535f Binary files /dev/null and b/inst/fonts/inter/Inter-ExtraBold.otf differ diff --git a/inst/fonts/inter/Inter-ExtraBoldItalic.otf b/inst/fonts/inter/Inter-ExtraBoldItalic.otf new file mode 100644 index 0000000..3b196c8 Binary files /dev/null and b/inst/fonts/inter/Inter-ExtraBoldItalic.otf differ diff --git a/inst/fonts/inter/Inter-ExtraLight.otf b/inst/fonts/inter/Inter-ExtraLight.otf new file mode 100644 index 0000000..677bce0 Binary files /dev/null and b/inst/fonts/inter/Inter-ExtraLight.otf differ diff --git a/inst/fonts/inter/Inter-ExtraLightItalic.otf b/inst/fonts/inter/Inter-ExtraLightItalic.otf new file mode 100644 index 0000000..00512ba Binary files /dev/null and b/inst/fonts/inter/Inter-ExtraLightItalic.otf differ diff --git a/inst/fonts/inter/Inter-Italic.otf b/inst/fonts/inter/Inter-Italic.otf new file mode 100644 index 0000000..12319b0 Binary files /dev/null and b/inst/fonts/inter/Inter-Italic.otf differ diff --git a/inst/fonts/inter/Inter-Light.otf b/inst/fonts/inter/Inter-Light.otf new file mode 100644 index 0000000..95c69f8 Binary files /dev/null and b/inst/fonts/inter/Inter-Light.otf differ diff --git a/inst/fonts/inter/Inter-LightItalic.otf b/inst/fonts/inter/Inter-LightItalic.otf new file mode 100644 index 0000000..8dee08c Binary files /dev/null and b/inst/fonts/inter/Inter-LightItalic.otf differ diff --git a/inst/fonts/inter/Inter-Medium.otf b/inst/fonts/inter/Inter-Medium.otf new file mode 100644 index 0000000..01b0b4a Binary files /dev/null and b/inst/fonts/inter/Inter-Medium.otf differ diff --git a/inst/fonts/inter/Inter-MediumItalic.otf b/inst/fonts/inter/Inter-MediumItalic.otf new file mode 100644 index 0000000..abd9877 Binary files /dev/null and b/inst/fonts/inter/Inter-MediumItalic.otf differ diff --git a/inst/fonts/inter/Inter-Regular.otf b/inst/fonts/inter/Inter-Regular.otf new file mode 100644 index 0000000..e94fa45 Binary files /dev/null and b/inst/fonts/inter/Inter-Regular.otf differ diff --git a/inst/fonts/inter/Inter-SemiBold.otf b/inst/fonts/inter/Inter-SemiBold.otf new file mode 100644 index 0000000..2329402 Binary files /dev/null and b/inst/fonts/inter/Inter-SemiBold.otf differ diff --git a/inst/fonts/inter/Inter-SemiBoldItalic.otf b/inst/fonts/inter/Inter-SemiBoldItalic.otf new file mode 100644 index 0000000..2137d65 Binary files /dev/null and b/inst/fonts/inter/Inter-SemiBoldItalic.otf differ diff --git a/inst/fonts/inter/Inter-Thin.otf b/inst/fonts/inter/Inter-Thin.otf new file mode 100644 index 0000000..0aac1a9 Binary files /dev/null and b/inst/fonts/inter/Inter-Thin.otf differ diff --git a/inst/fonts/inter/Inter-ThinItalic.otf b/inst/fonts/inter/Inter-ThinItalic.otf new file mode 100644 index 0000000..f6e240a Binary files /dev/null and b/inst/fonts/inter/Inter-ThinItalic.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-Bold.otf b/inst/fonts/roboto-condensed/RobotoCondensed-Bold.otf new file mode 100644 index 0000000..1afbb38 Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-Bold.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-BoldItalic.otf b/inst/fonts/roboto-condensed/RobotoCondensed-BoldItalic.otf new file mode 100644 index 0000000..f2a73ac Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-BoldItalic.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-Italic.otf b/inst/fonts/roboto-condensed/RobotoCondensed-Italic.otf new file mode 100644 index 0000000..12cc234 Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-Italic.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-Light.otf b/inst/fonts/roboto-condensed/RobotoCondensed-Light.otf new file mode 100644 index 0000000..89f69a6 Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-Light.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-LightItalic.otf b/inst/fonts/roboto-condensed/RobotoCondensed-LightItalic.otf new file mode 100644 index 0000000..43d7caa Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-LightItalic.otf differ diff --git a/inst/fonts/roboto-condensed/RobotoCondensed-Regular.otf b/inst/fonts/roboto-condensed/RobotoCondensed-Regular.otf new file mode 100644 index 0000000..e922232 Binary files /dev/null and b/inst/fonts/roboto-condensed/RobotoCondensed-Regular.otf differ diff --git a/man/adaptive_color.Rd b/man/adaptive_color.Rd new file mode 100644 index 0000000..3d02821 --- /dev/null +++ b/man/adaptive_color.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/theme-colors.R +\name{adaptive_color} +\alias{adaptive_color} +\alias{theme_background_color} +\alias{theme_foreground_color} +\title{Adaptive colors colors for {hrbragg} themes} +\usage{ +adaptive_color(mode = c("light", "dark", "rstudio"), light, dark) + +theme_background_color( + mode = c("light", "dark", "rstudio"), + light = "white", + dark = "#121212" +) + +theme_foreground_color( + mode = c("light", "dark", "rstudio"), + light = "#262626", + dark = "#e1e1e1" +) +} +\arguments{ +\item{mode}{\code{dark}, \code{light}, or \code{rstudio} to base it on RStudio's active theme} + +\item{light, dark}{light and dark colors to auto-select from} + +\item{dark}{dark color to use} +} +\value{ +length 1 character vector that represents a valid color +} +\description{ +Explicit foreground/background theme color functions are provided +along with the primary adaptive color switcher function. +} +\examples{ +theme_background_color() +} diff --git a/man/elb.Rd b/man/elb.Rd new file mode 100644 index 0000000..558ff00 --- /dev/null +++ b/man/elb.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/shortcuts.R +\name{elb} +\alias{elb} +\title{Shortcut for \code{element_blank}} +\usage{ +elb() +} +\value{ +An S3 object of class element, rel, or margin. +} +\description{ +Shortcut for \code{element_blank} +} diff --git a/man/ell.Rd b/man/ell.Rd new file mode 100644 index 0000000..36d4cfa --- /dev/null +++ b/man/ell.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/shortcuts.R +\name{ell} +\alias{ell} +\title{Shortcut for \code{element_line}} +\usage{ +ell( + colour = NULL, + size = NULL, + linetype = NULL, + lineend = NULL, + color = NULL, + arrow = NULL, + inherit.blank = FALSE +) +} +\arguments{ +\item{colour, size, linetype, lineend, color, arrow, inherit.blank}{See \code{\link[ggplot2:element]{ggplot2::element_line()}}} +} +\value{ +An S3 object of class element, rel, or margin. +} +\description{ +Shortcut for \code{element_line} +} diff --git a/man/elr.Rd b/man/elr.Rd new file mode 100644 index 0000000..4a8d2a1 --- /dev/null +++ b/man/elr.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/shortcuts.R +\name{elr} +\alias{elr} +\title{Shortcut for \code{element_rect}} +\usage{ +elr( + fill = NULL, + colour = NULL, + size = NULL, + linetype = NULL, + color = NULL, + inherit.blank = FALSE +) +} +\arguments{ +\item{fill, colour, size, linetype, color, inherit.blank}{See \code{\link[ggplot2:element]{ggplot2::element_rect()}}} +} +\value{ +An S3 object of class element, rel, or margin. +} +\description{ +Shortcut for \code{element_rect} +} diff --git a/man/elt.Rd b/man/elt.Rd new file mode 100644 index 0000000..935687c --- /dev/null +++ b/man/elt.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/shortcuts.R +\name{elt} +\alias{elt} +\title{Shortcut for \code{element_text}} +\usage{ +elt( + family = NULL, + face = NULL, + colour = NULL, + size = NULL, + hjust = NULL, + vjust = NULL, + angle = NULL, + lineheight = NULL, + color = NULL, + margin = NULL, + debug = NULL, + inherit.blank = FALSE +) +} +\arguments{ +\item{family, face, colour, size, hjust, vjust, angle, lineheight, color, margin, debug, inherit.blank}{See \code{\link[ggplot2:element]{ggplot2::element_text()}}} +} +\description{ +Shortcut for \code{element_text} +} diff --git a/man/feature_dict.Rd b/man/feature_dict.Rd new file mode 100644 index 0000000..d7dd339 --- /dev/null +++ b/man/feature_dict.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/feature-dict.R +\docType{data} +\name{feature_dict} +\alias{feature_dict} +\title{OpenType feature description lookup table} +\format{ +A data frame with 122 rows and 3 variables: +\describe{ +\item{tag}{OpenType four-character tag name} +\item{long_name}{Human-readable tag name} +\item{description}{Compact description of the tag} +} +} +\source{ +\url{https://en.wikipedia.org/wiki/List_of_typographic_features} +} +\usage{ +feature_dict +} +\description{ +Compact data frame describing OpenType features. +} +\keyword{datasets} diff --git a/man/figures/README-dark-mode-01-1.png b/man/figures/README-dark-mode-01-1.png new file mode 100644 index 0000000..dfcf522 Binary files /dev/null and b/man/figures/README-dark-mode-01-1.png differ diff --git a/man/figures/README-dark-mode-02-1.png b/man/figures/README-dark-mode-02-1.png new file mode 100644 index 0000000..bcbef7b Binary files /dev/null and b/man/figures/README-dark-mode-02-1.png differ diff --git a/man/figures/README-ex-01-1.png b/man/figures/README-ex-01-1.png new file mode 100644 index 0000000..fe17aff Binary files /dev/null and b/man/figures/README-ex-01-1.png differ diff --git a/man/figures/README-light-mode-01-1.png b/man/figures/README-light-mode-01-1.png new file mode 100644 index 0000000..2778d41 Binary files /dev/null and b/man/figures/README-light-mode-01-1.png differ diff --git a/man/figures/README-light-mode-02-1.png b/man/figures/README-light-mode-02-1.png new file mode 100644 index 0000000..0e6706f Binary files /dev/null and b/man/figures/README-light-mode-02-1.png differ diff --git a/man/hrbragg.Rd b/man/hrbragg.Rd index 1124086..5fb5431 100644 --- a/man/hrbragg.Rd +++ b/man/hrbragg.Rd @@ -4,9 +4,13 @@ \name{hrbragg} \alias{hrbragg} \alias{hrbragg-package} -\title{...} +\title{Typography-centric Themes, Theme Components, and Utilities for 'ggplot2' and 'ragg'.} \description{ -A good description goes here otherwise CRAN checks fail. +The 'ragg', 'systemfonts', and 'textshaping' packages make it +possible to create plot components and themes that make full use of +the rich typography features in modern fonts. Fonts, themes, and utilities +are provided to create 'ggplot2' plots intended for rendering on 'ragg' +graphics devices. } \seealso{ Useful links: diff --git a/man/install_inter.Rd b/man/install_inter.Rd new file mode 100644 index 0000000..ed18f1f --- /dev/null +++ b/man/install_inter.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/install-fonts.R +\name{install_inter} +\alias{install_inter} +\title{Install Inter} +\usage{ +install_inter() +} +\description{ +Inter is a typeface carefully crafted & designed for computer screens and +features a tall x-height to aid in readability of mixed-case and lower-case +text. Several OpenType features are provided as well, like contextual +alternates that adjusts punctuation depending on the shape of surrounding +glyphs, slashed zero for when you need to disambiguate "0" from "o", +tabular numbers, etc. +} +\note{ +\href{https://choosealicense.com/licenses/ofl-1.1/}{SIL Open Font License 1.1} +} +\references{ +\href{https://rsms.me/inter/}{Inter} +} diff --git a/man/inter_pkg.Rd b/man/inter_pkg.Rd new file mode 100644 index 0000000..44f61cf --- /dev/null +++ b/man/inter_pkg.Rd @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/zzz.R +\docType{data} +\name{inter_pkg} +\alias{inter_pkg} +\title{Inter Font Variant} +\format{ +A list +} +\usage{ +inter_pkg +} +\description{ +On load {hrbragg} creates a custom Inter font family variant +and makes it available in the global environment. +} +\details{ +The reconfigured family variant has the following features: +\itemize{ +\item \code{calt}: (\emph{Contextual Alternates}): Applies a second substitution feature +based on a match of a character pattern within a context of surrounding patterns +\item \code{case} (\emph{Case Sensitive Forms}): Replace characters, especially punctuation, with forms better suited for all-capital text, cf. titl +\item \code{dlig}/\code{ligatures} (\emph{Discretionary Ligatures}): Ligatures to be applied at the user's discretion +\item \code{kern} (\emph{Kerning}): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs +\item \code{salt} (\emph{Stylistic Alternates}): \strong{DISABLED} — Either replaces with, or displays list of, stylistic alternatives for a character +\item \code{ss01} (\emph{Stylistic set 1: Alternate digits}): An alternate style of digits. +\item \code{tnum} (\emph{Tabular Figures}): Replaces numerals with glyphs of uniform width, often also lnum +\item \code{zero} (\emph{Slashed Zero}): \strong{DISABLED} — Replaces 0 figure with slashed 0 +} + +Inter online documentation has \href{https://rsms.me/inter/#features}{specific descriptions and exaples of these features}. + +This object has the following names corresponding to individual, +customized font variants (ordered by font weight): +\itemize{ +\item \code{ultralight} +\item \code{ultralight_italic} +\item \code{light} +\item \code{light_italic} +\item \code{normal_italic} +\item \code{normal} +\item \code{medium_italic} +\item \code{medium} +\item \code{semibold_italic} +\item \code{semibold} +\item \code{bold} +\item \code{bold_italic} +\item \code{ultrabold} +\item \code{ultrabold_italic} +\item \code{heavy} +\item \code{heavy_italic} +} +} +\keyword{datasets} diff --git a/man/opentype_typographic_features.Rd b/man/opentype_typographic_features.Rd new file mode 100644 index 0000000..e39580d --- /dev/null +++ b/man/opentype_typographic_features.Rd @@ -0,0 +1,138 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/feature-reference.R +\name{opentype_typographic_features} +\alias{opentype_typographic_features} +\title{OpenType Typographic Features} +\description{ +Quick reference table describing the four-character feature codes. A +more complete quick reference can be found +\href{https://en.wikipedia.org/wiki/List_of_typographic_features}{on Wikipedia} +and a complete OpenType feature list specification can be found +\href{https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist}{at Microsoft}. +} +\details{ +\itemize{ +\item \code{aalt} (\emph{Access All Alternates}): Special feature: used to present user with choice all alternate forms of the character +\item \code{abvf} (\emph{Above-base Forms}): Replaces the above-base part of a vowel sign. For Khmer and similar scripts. +\item \code{abvm} (\emph{Above-base Mark Positioning}): Positions a mark glyph above a base glyph. +\item \code{abvs} (\emph{Above-base Substitutions}): Ligates a consonant with an above-mark. +\item \code{afrc} (\emph{Alternative Fractions}): Converts figures separated by slash with alternative stacked fraction form +\item \code{akhn} (\emph{Akhand}): Hindi for unbreakable. Ligates consonant+halant+consonant, usually only for k-ss and j-ny combinations. +\item \code{blwf} (\emph{Below-base Forms}): Replaces halant+consonant combination with a subscript form. +\item \code{blwm} (\emph{Below-base Mark Positioning}): Positions a mark glyph below a base glyph +\item \code{blws} (\emph{Below-base Substitutions}): Ligates a consonant with a below-mark. +\item \code{c2pc} (\emph{Capitals to Petite Caps}): Substitutes capital letters with petite caps +\item \code{c2sc} (\emph{Capitals to Small Caps}): Substitutes capital letters with small caps +\item \code{calt} (\emph{Contextual Alternates}): Applies a second substitution feature based on a match of a character pattern within a context of surrounding patterns +\item \code{case} (\emph{Case Sensitive Forms}): Replace characters, especially punctuation, with forms better suited for all-capital text, cf. titl +\item \code{ccmp} (\emph{Glyph Composition/Decomposition}): Either calls a ligature replacement on a sequence of characters or replaces a character with a sequence of glyphs. Provides logic that can for example effectively alter the order of input characters. +\item \code{cfar} (\emph{Conjunct Form After Ro}): Khmer +\item \code{cjct} (\emph{Conjunct Forms}): Ligates consonant+halant+consonant, indicates part of a conjunct. +\item \code{clig} (\emph{Contextual Ligatures}): Applies a second ligature feature based on a match of a character pattern within a context of surrounding patterns +\item \code{cpct} (\emph{Centered CJK Punctuation}): Positions punctuation marks vertically and horizontally +\item \code{cpsp} (\emph{Capital Spacing}): Adjusts spacing between letters in all-capitals text +\item \code{cswh} (\emph{Contextual Swash}): Converts letter to a swashed version based on characters around the letter +\item \code{curs} (\emph{Cursive Positioning}): Precise positioning of a letter's connection to an adjacent one +\item \verb{cv01–cv99} (\emph{Character Variant 1–99}): Multiple variants of a single character, which may not apply to many other characters, see references for voluminous documentation +\item \code{dist} (\emph{Distance}): Adjusts horizontal positioning between glyphs. (Always enabled, as opposed to 'kern'.) +\item \code{dlig} (\emph{Discretionary Ligatures}): Ligatures to be applied at the user's discretion +\item \code{dnom} (\emph{Denominator}): Converts to appropriate fraction denominator form, invoked by frac +\item \code{dtls} (\emph{Dotless Forms}): +\item \code{expt} (\emph{Expert Forms}): Typographic alternatives for some Japanese tetragrams +\item \code{falt} (\emph{Final Glyph on Line Alternates}): Replaces final glyph on the line with an alternate +\item \code{fin2} (\emph{Terminal Form #2}): Syriac +\item \code{fin3} (\emph{Terminal Form #3}): Syriac +\item \code{fina} (\emph{Terminal Forms}): Substitutes a special form of a letter at end of words (required by Arabic and Syriac) +\item \code{flac} (\emph{Flattened accent forms}): +\item \code{frac} (\emph{Fractions}): Converts figures separated by slash with diagonal fraction +\item \code{fwid} (\emph{Full Widths}): Substitutes proportionally spaced character with full-width versions (esp. for Latin letters within Chinese) +\item \code{half} (\emph{Half Form}): Replaces consonant+halant with a half form, indicating it is part of a conjunct. +\item \code{haln} (\emph{Halant Forms}): Replaces a glyph for final consonant+halant. +\item \code{halt} (\emph{Alternate Half Widths}): Re-positions full-width glyphs on half-width spaces +\item \code{hist} (\emph{Historical Forms}): Obsolete forms of characters to be applied at the user's discretion, cf. hlig +\item \code{hkna} (\emph{Horizontal Kana Alternates}): Alternate forms for horizontal kana text, e.g. ー for chōonpu instead of |, cf. vkna +\item \code{hlig} (\emph{Historical Ligatures}): Obsolete ligatures to be applied at the user's discretion +\item \code{hngl} (\emph{Hangul}): Transliterates Chinese-style characters with Korean Hangul +\item \code{hojo} (\emph{Hojo Kanji Forms}): Hojo alternates for Japanese tetragrams +\item \code{hwid} (\emph{Half Widths}): Substitutes uniformly-spaced characters with half-width version +\item \code{init} (\emph{Initial Forms}): Substitutes a special form of a letter occurring at the beginning of a word (required by Arabic and Syriac) +\item \code{isol} (\emph{Isolated Forms}): Substitutes a special form of a letter occurring outside a word (required by Arabic and Syriac) +\item \code{ital} (\emph{Italics}): Replaces letter with corresponding italic glyph +\item \code{jalt} (\emph{Justification Alternates}): User selectable wider and narrower alternates, used especially for justifying +\item \code{jp04} (\emph{JIS 04 Forms}): JIS 2004 alternates for Japanese tetragrams, not accessible per Unicode +\item \code{jp78} (\emph{JIS 78 Forms}): JIS C 6226-1978 alternates for Japanese tetragrams, not accessible per Unicode +\item \code{jp83} (\emph{JIS 83 Forms}): JIS X 0208-1983 alternates for Japanese tetragrams, not accessible per Unicode +\item \code{jp90} (\emph{JIS 90 Forms}): JIS X 0208-1990 alternates for Japanese tetragrams, not accessible per Unicode +\item \code{kern} (\emph{Kerning}): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs +\item \code{lfbd} (\emph{Left Bounds}): Re-positions glyphs at end of line. Called by opbd. +\item \code{liga} (\emph{Standard Ligatures}): Replaces (by default) sequence of characters with a single ligature glyph +\item \code{ljmo} (\emph{Leading Jamo Forms}): Initial group of consonants for a synthesized Korean Hangul tetragram +\item \code{lnum} (\emph{Lining Figures}): Replaces numerals with glyphs meant to fit better in all-capitals text, often also tnum +\item \code{locl} (\emph{Localized Forms}): Substitutes character with the preferred form based on script language +\item \code{ltra} (\emph{Left-to-right glyph alternates}): Replaces characters with forms befitting left-to-right presentation (except mirrored forms) +\item \code{ltrm} (\emph{Left-to-right mirrored forms}): Replaces characters with possibly mirrored forms befitting left-to-right presentation +\item \code{mark} (\emph{Mark Positioning}): Fine positioning of a mark glyph to a base character +\item \code{med2} (\emph{Medial Form #2}): Syriac +\item \code{medi} (\emph{Medial Forms}): Substitutes a special form of letters between other letters in words (required by Arabic and Syriac) +\item \code{mgrk} (\emph{Mathematical Greek}): Replaces Greek characters with special forms for use in mathematics +\item \code{mkmk} (\emph{Mark-to-mark Positioning}): Fine positioning of a mark glyph to another mark character +\item \code{mset} (\emph{Mark Positioning via Substitution}): Used in Windows 95 for positioning of Arabic marks +\item \code{nalt} (\emph{Alternate Annotation Forms}): Provides user access to circled digits, inverse letters etc. +\item \code{nlck} (\emph{NLC Kanji Forms}): NLC alternates for Japanese tetragrams +\item \code{nukt} (\emph{Nukta Forms}): Replace consonant+nukta (dot mark) with single glyph. +\item \code{numr} (\emph{Numerator}): Converts to appropriate fraction numerator form, invoked by frac +\item \code{onum} (\emph{Oldstyle Figures}): Replaces numerals with cased old-style numerals, often also pnum +\item \code{opbd} (\emph{Optical Bounds}): Re-positions glyphs at beginning and end of line, for precise justification of text. +\item \code{ordn} (\emph{Ordinals}): Replaces characters with ordinal forms for use after numbers +\item \code{ornm} (\emph{Ornaments}): Decorative alternates for the bullet character • +\item \code{palt} (\emph{Proportional Alternates}): Re-positions otherwise monospace characters according to glyph width +\item \code{pcap} (\emph{Petite Caps}): Substitute lower-case letters with their petite caps analogs +\item \code{pkna} (\emph{Proportional Kana}): Kana for use alongside alphabets, without grid typography +\item \code{pnum} (\emph{Proportional Figures}): Replaces numerals with glyphs of proportional width, often also onum +\item \code{pref} (\emph{Pre-base Forms}): Replaces halant+consonant at the end of a consonant cluster with a glyph at the beginning. Khmer, Myanmar, Malayalam, Telugu +\item \code{pres} (\emph{Pre-base Substitutions}): Ligates consonant combinations. +\item \code{pstf} (\emph{Post-base Forms}): Substitutes final halant+consonant with special form. Khmer and Gurmukhi, Malayalam +\item \code{psts} (\emph{Post-base Substitutions}): Ligates a final consonant+consonant. +\item \code{pwid} (\emph{Proportional Widths}): Replaces uniformly-spaced glyphs with proportional ones +\item \code{qwid} (\emph{Quarter Widths}): Replaces uniformly-spaced glyphs with quarter-width ones (punctuation etc.) +\item \code{rand} (\emph{Randomize}): Replaces character with random forms (meant to simulate handwriting) +\item \code{rclt} (\emph{Required Contextual Alternates}): Contextual alternates required for correct text display which differs from the default join for other letters, required especially important by Arabic +\item \code{rkrf} (\emph{Rakar Forms}): Replaces halant+ra with a rakar glyph, indicating it is part of a conjunct. +\item \code{rlig} (\emph{Required Ligatures}): Ligatures required for correct text display (any script, but in cursive) +\item \code{rphf} (\emph{Reph Form}): Replaces initial ra+halant with a final reph mark, indicating part of a conjunct. +\item \code{rtbd} (\emph{Right Bounds}): Re-positions glyphs at beginning of line. Called by opbd. +\item \code{rtla} (\emph{Right-to-left glyph alternates}): Replaces characters with forms befitting right-to-left presentation (except mirrored forms) +\item \code{rtlm} (\emph{Right-to-left mirrored forms}): Replaces characters with possibly mirrored forms befitting right-to-left presentation +\item \code{ruby} (\emph{Ruby Notation Forms}): Ruby characters, small print +\item \code{rvrn} (\emph{Required Variation Alternates}): Special variants of a single character, which need apply to specific font variation, required by variable fonts +\item \code{salt} (\emph{Stylistic Alternates}): Either replaces with, or displays list of, stylistic alternatives for a character +\item \code{sinf} (\emph{Scientific Inferiors}): as in "H2O", "SOx" or "YCbCr" (but using the same font weight and predefined position in contrast these plain HTML subs and sups) +\item \code{size} (\emph{Optical size}): Not a lookup: feature's table provides to applications information about the appearance and intent of the font, to aid in font selection. +\item \code{smcp} (\emph{Small Caps}): Substitutes lower-case letters with small caps versions +\item \code{smpl} (\emph{Simplified Forms}): Replaces sinograms with their simplified versions, may be language dependent +\item \code{ss01-ss20} (\emph{Stylistic Set 1 – 20}): Replaces character with one from a font-specific set of stylistic alternatives +\item \code{ssty} (\emph{Math script style alternates}): +\item \code{stch} (\emph{Stretching Glyph Decomposition}): Substitutes a special form of a stretchy glyph onto one or more letters (required by Syriac) +\item \code{subs} (\emph{Subscript}): Replaces character with subscript version, cf. numr +\item \code{sups} (\emph{Superscript}): Replaces character with superscript version, cf. dnom +\item \code{swsh} (\emph{Swash}): Either replaces character with or displays multiple swashed versions +\item \code{titl} (\emph{Titling Alternates}): Replaces characters with forms suited for large type, as in titles +\item \code{tjmo} (\emph{Trailing Jamo Forms}): Final group of consonants for a synthesized Korean Hangul tetragram +\item \code{tnam} (\emph{Traditional Name Forms}): Japanese alternates for proper names +\item \code{tnum} (\emph{Tabular Figures}): Replaces numerals with glyphs of uniform width, often also lnum +\item \code{trad} (\emph{Traditional Forms}): Replaces Chinese characters with their traditional versions +\item \code{twid} (\emph{Third Widths}): Substitutes uniformly-spaced character with a version of 1/3 width (punctuation, etc.) +\item \code{unic} (\emph{Unicase}): Replaces lowercase and uppercase letters with a set of single case glyphs +\item \code{valt} (\emph{Alternative Vertical Metrics}): Positions shorter characters to be centered vertically with full-height characters +\item \code{vatu} (\emph{Vattu Variants}): Replaces consonant+rakar combinations with a vattu variant ligature. +\item \code{vert} (\emph{Vertical Alternates}): A subset of vrt2: prefer the latter feature +\item \code{vhal} (\emph{Alternative Vertical Half Metrics}): Positions characters to be centered vertically with half-height characters +\item \code{vjmo} (\emph{Vowel Jamo Forms}): Medial group of vowels for a synthesized Korean Hangul tetragram +\item \code{vkna} (\emph{Vertical Kana}): Alternate Japanese kana forms for vertical text, e.g. | for chōonpu instead of ー, cf. hkna +\item \code{vkrn} (\emph{Vertical Kerning}): Fine vertical positioning of characters based on shape +\item \code{vpal} (\emph{Proportional Alternate Vertical Metrics}): Re-positions glyphs vertically to be centered on proportional full-height characters +\item \code{vrt2} (\emph{Vertical Alternates and Rotation}): Replaces characters with forms suitable for vertical writing, possibly by rotating 90° +\item \code{vrtr} (\emph{Vertical Alternates for Rotation}): Replaces characters with forms suitable for vertical writing, possibly by shifting or shape +\item \code{zero} (\emph{Slashed Zero}): Replaces 0 figure with slashed 0 +} +} diff --git a/man/reconfigure_font.Rd b/man/reconfigure_font.Rd new file mode 100644 index 0000000..d899b7f --- /dev/null +++ b/man/reconfigure_font.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reconfigure-font.R +\name{reconfigure_font} +\alias{reconfigure_font} +\title{Create an complete, alternate font family with the same customized features} +\usage{ +reconfigure_font( + family, + width = "normal", + ligatures = NULL, + letters = NULL, + numbers = NULL, + prefix = uuid::UUIDgenerate(), + ... +) +} +\arguments{ +\item{family}{font family name} + +\item{width}{font width (defaults to "normal")} + +\item{ligatures, letters, numbers}{See \code{\link[systemfonts:font_feature]{systemfonts::font_feature()}}} + +\item{prefix}{string to use as a prefix to the names of the newly generated font family. +If not specified, a guaranteed unique identifier will be used.} + +\item{...}{Extra four-letter font feature flags passed on to \code{\link[systemfonts:font_feature]{systemfonts::font_feature()}}. See +See \href{https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist}{Microsoft} and +\href{https://en.wikipedia.org/wiki/List_of_typographic_features}{Wikipedia} for tag descriptions.} +} +\value{ +list with names of all the customized font family members. A \code{family} +attribute is included which is the name of the family this variant is +based on. +} +\description{ +Create an complete, alternate font family with the same customized features +} +\examples{ +reconfigure_font( + family = "Inter", + width = "normal", + ligatures = "discretionary", + calt = 1, tnum = 1, case = 1, + dlig = 1, ss01 = 1, kern = 1, + zero = 0, salt = 0 +) -> inter_1 +} diff --git a/man/theme_inter.Rd b/man/theme_inter.Rd new file mode 100644 index 0000000..cf35a6e --- /dev/null +++ b/man/theme_inter.Rd @@ -0,0 +1,116 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/theme-inter.R +\name{theme_inter} +\alias{theme_inter} +\title{ggplot2 Theme Based On The Inter Font Family} +\usage{ +theme_inter( + base_size = 10, + line_height = 0.875, + plot_title_size = 18, + plot_title_position = "panel", + plot_title_margin = 10, + subtitle_size = 12, + subtitle_margin = 12, + strip_text_size = 12, + strip_placement = "outer", + caption_size = 9, + caption_margin = 10, + axis_text_size = base_size, + axis_title_size = 9, + axis_title_just = "rt", + panel_spacing = grid::unit(2, "lines"), + plot_margin = margin(30, 30, 30, 30), + mode = c("light", "dark", "rstudio"), + background_colour = theme_background_color(mode, light = "white", dark = "#121212"), + foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), + grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), + axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), + grid = TRUE, + axis = FALSE, + ticks = FALSE +) +} +\arguments{ +\item{base_size}{base font size} + +\item{line_height}{default line height} + +\item{plot_title_size}{plot title size} + +\item{plot_title_position}{plot title position} + +\item{plot_title_margin}{plot title margin} + +\item{subtitle_size}{subtitle size} + +\item{subtitle_margin}{subtitle margin} + +\item{strip_text_size}{strip text size} + +\item{strip_placement}{strip placement} + +\item{caption_size}{caption size} + +\item{caption_margin}{caption margin} + +\item{axis_text_size}{axis text size} + +\item{axis_title_size}{axis title size} + +\item{axis_title_just}{axis title just} + +\item{panel_spacing}{panel spacing} + +\item{plot_margin}{plot margin} + +\item{grid_col}{grid col} + +\item{axis_col}{axis col} + +\item{grid}{grid} + +\item{axis}{axis} + +\item{ticks}{ticks} + +\item{text_geom_size}{text geom size} +} +\value{ +ggplot2 theme +} +\description{ +Uses the built-in \link{inter_pkg} custom font. +} +\details{ +\itemize{ +\item \code{background_colour} dark mode is "\verb{#121212}" else "\code{white}" +\item \code{foreground_colour} dark mode is "\verb{#e1e1e1}" else "\verb{#262626}" +\item \code{grid_col} dark mode is "\verb{#606367}" else "\verb{#cccccc}" +\item \code{axis_col} dark mode is "\verb{#606367}" else "\verb{#2b2b2b}" +} +} +\note{ +this function updates \code{Geom} defaults +} +\examples{ +ggplot() + + geom_point( + data = mtcars, + aes(mpg, wt) + ) + + geom_label( + aes( + x = 30, y = 4.5, + label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." + ), + label.size = 0 + ) + + labs( + x = "Fuel efficiency (mpg)", y = "Weight (tons)", + title = "Seminal ggplot2 scatterplot example", + subtitle = "A plot that is only useful for demonstration purposes", + caption = "Brought to you by the letter 'g'" + ) + + theme_inter(grid = "XY") +}