75 changed files with 2238 additions and 18 deletions
@ -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 <bob@rud.is> |
|||
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 |
|||
|
@ -0,0 +1,2 @@ |
|||
YEAR: 2021 |
|||
COPYRIGHT HOLDER: Bob Rudis |
@ -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. |
@ -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) |
|||
|
@ -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" |
@ -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 |
@ -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" |
|||
|
@ -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") |
|||
} |
@ -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 |
|||
|
|||
} |
@ -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 |
|||
# |
|||
# } |
@ -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 |
@ -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) |
|||
} |
@ -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 |
|||
|
|||
} |
@ -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") |
|||
} |
@ -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." |
|||
) |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,173 @@ |
|||
|
|||
[](https://www.repostatus.org/#active) |
|||
[](https://keybase.io/hrbrmstr) |
|||
 |
|||
[](https://travis-ci.org/hrbrmstr/hrbragg) |
|||
 |
|||
 |
|||
|
|||
# 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") |
|||
``` |
|||
|
|||
<img src="man/figures/README-dark-mode-01-1.png" width="672" /> |
|||
|
|||
``` r |
|||
gg1 + theme_inter(grid = "XY", mode = "light") |
|||
``` |
|||
|
|||
<img src="man/figures/README-light-mode-01-1.png" width="672" /> |
|||
|
|||
``` 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") |
|||
``` |
|||
|
|||
<img src="man/figures/README-light-mode-02-1.png" width="1400" /> |
|||
|
|||
``` r |
|||
gg2 + theme_inter(grid = "XY", mode = "dark") |
|||
``` |
|||
|
|||
<img src="man/figures/README-dark-mode-02-1.png" width="1400" /> |
|||
|
|||
## 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. |
@ -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) |
Binary file not shown.
@ -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 |
|||