Skip to content

Commit

Permalink
Merge pull request #6 from TxWRI/documentation
Browse files Browse the repository at this point in the history
Documentation
  • Loading branch information
mps9506 authored Sep 9, 2021
2 parents 2e0554f + aee9009 commit 9d20c79
Show file tree
Hide file tree
Showing 21 changed files with 284 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: twriTemplates
Type: Package
Title: Templates for TWRI reports
Version: 0.1.001
Version: 0.2.0
Authors@R:
person(given = "Michael",
family = "Schramm",
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export(scale_fill_continuous_twri)
export(scale_fill_discrete_twri)
export(scale_fill_diverging_twri)
export(scale_fill_opinionated_twri)
export(theme_TWRI_fig)
export(theme_TWRI_pres)
export(theme_TWRI_print)
export(twri_docx)
export(twri_pal)
export(twri_pal_cont)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# twriTemplates 0.2.0

* Initial package release.
* Includes two rmarkdown templates for word and pdf document creation.
* Includes two ggplot2 themes for print and presentation graphics.
* Unit testing handled by testthat
* Github actions used for r-cmd-check

2 changes: 2 additions & 0 deletions R/add_TWRI_logo.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ add_TWRI_logo <- function(plot,

logo_path <- fs::path_package("twriTemplates", "rmarkdown", "templates", "twri-docx", "skeleton", "twri_logo.png")

#logo <- magick::image_read_svg(logo_path, width = 2000)

cowplot::ggdraw() +
cowplot::draw_plot(plot) +
cowplot::draw_image(logo_path,
Expand Down
2 changes: 1 addition & 1 deletion R/onload.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

## Register desired system fonts
fonts <- systemfonts::system_fonts()
try(init_fonts(fonts), outFile = "Could not register required [Moriston] fonts, please download and install from: https://agrilife.tamu.edu/wp-content/uploads/2021/03/AgriFonts.zip")
try(init_fonts(fonts))

}
10 changes: 5 additions & 5 deletions R/theme_TWRI_fig.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' a [ggplot2] theme formatted in the TWRI style
#'
#' Provides a [ggplot2] theme formatted consistent with TWRI style guidance.
#' Provides a [ggplot2] theme formatted consistent with TWRI style guidance. Use this theme for figures intended for printed reports. The default font is "Open Sans Condensed". The suggest export width is 6.5 inches at 300 dpi.
#'
#' @param base_family defaults to \code{"Arial"}. Generally, use a sensible sans serif font that is available on your system.
#' @param base_family defaults to \code{"OpenSansCondensed_TWRI"}. Which is provided in the package. Generally, use a sensible sans serif font that is available on your system.
#' @param base_size default text size in px
#' @param base_line_size default line size
#' @param base_rect_size default rect size
#' @import ggplot2
#' @export
theme_TWRI_fig <- function(base_size = 8.5,
base_family = "Arial",
theme_TWRI_print <- function(base_size = 8.5,
base_family = "OpenSansCondensed_TWRI",
base_line_size = 0.5,
base_rect_size = 0.5) {
half_line <- base_size / 2L
Expand Down Expand Up @@ -150,7 +150,7 @@ theme_TWRI_fig <- function(base_size = 8.5,
panel.grid = NULL,
panel.grid.major = ggplot2::element_line(),
panel.grid.major.x = ggplot2::element_blank(),
panel.grid.major.y = ggplot2::element_blank(),
panel.grid.major.y = ggplot2::element_line(linetype = "dotted", color = "#d9d9d9"),
panel.grid.minor = ggplot2::element_line(),
panel.grid.minor.x = ggplot2::element_blank(),
panel.grid.minor.y = ggplot2::element_blank(),
Expand Down
2 changes: 1 addition & 1 deletion R/theme_TWRI_pres.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' @import ggplot2
#' @export
theme_TWRI_pres <- function(base_size = 16,
base_family = "Moriston_personal",
base_family = "Oswald_TWRI",
base_line_size = 1,
base_rect_size = 1) {

Expand Down
52 changes: 45 additions & 7 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
init_fonts <- function(fonts) {
MoristonRegular <- fonts[fonts$name == "MoristonPersonal-Medium",]$path
MoristonSemibold <- fonts[fonts$name == "MoristonPersonal-Semibold",]$path
systemfonts::register_font("Moriston_personal",
plain = MoristonRegular,
bold = MoristonSemibold,
features = systemfonts::font_feature(letters = ,
numbers = c("lining","tabular")))

## make sure fonts are installed
if(length(fonts[fonts$family == "Moriston Personal",]$path) == 0){
packageStartupMessage("Moriston Personal font was not found,
please install from https://agrilife.tamu.edu/wp-content/uploads/2021/03/AgriFonts.zip")
} else {
## register moriston fonts with systemfonts because styles are not defined by default
MoristonRegular <- fonts[fonts$name == "MoristonPersonal-Medium",]$path
MoristonSemibold <- fonts[fonts$name == "MoristonPersonal-Semibold",]$path
systemfonts::register_font("Moriston_TWRI",
plain = MoristonRegular,
bold = MoristonSemibold,
features = systemfonts::font_feature(letters = ,
numbers = c("lining")))
}

if(length(fonts[fonts$family == "Oswald",]$path) == 0){
packageStartupMessage("Oswald font was not found,
please install from https://agrilife.tamu.edu/wp-content/uploads/2021/03/AgriFonts.zip")
} else {
Oswald_Bold <- fonts[fonts$name == "Oswald-SemiBold",]$path
Oswald_Normal <- fonts[fonts$name == "Oswald-Light",]$path
systemfonts::register_font("Oswald_TWRI",
plain = Oswald_Normal,
bold = Oswald_Bold,
)
}


if(length(fonts[fonts$family == "Minion Pro",]$path) == 0){
packageStartupMessage("Minion Pro font was not found,
please install from https://agrilife.tamu.edu/wp-content/uploads/2021/03/AgriFonts.zip")
}
## don't need to register minion pro

## register cabin
OpenSansCondensed <- fs::path_package("twriTemplates", "fonts", "OpenSansCondensed", "OpenSansCondensed-Light.ttf")
OpenSansCondensed_Bold <- fs::path_package("twriTemplates", "fonts", "OpenSansCondensed", "OpenSansCondensed-Bold.ttf")
OpenSansCondensed_Italic <- fs::path_package("twriTemplates", "fonts", "OpenSansCondensed", "OpenSansCondensed-LightItalic.ttf")
systemfonts::register_font("OpenSansCondensed_TWRI",
plain = OpenSansCondensed,
bold = OpenSansCondensed_Bold,
italic = OpenSansCondensed_Italic)


}
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ knitr::opts_chunk$set(
fig.path = "man/figures/README-",
out.width = "100%",
dev = "ragg_png",
dpi = 200
dpi = 300
)
```

Expand Down Expand Up @@ -41,7 +41,7 @@ remotes::install_github("TxWRI/twriTemplates")

### Prerequisites

The Rmarkdown templates assume the required fonts are installed on your system. The `Minion Pro` and `Open Sans` fonts among others are used by the various templates and themes. We aren't licensed to distribute some of the fonts. Install all the fonts AgriLife provides at the [Marketing and Communications branding website](https://agrilife.tamu.edu/marketing-and-communications/resources/branding-agrilife/).
The Rmarkdown templates assume the required fonts are installed on your system. The `Minion Pro` font among others are used by the various templates and themes. We aren't licensed to distribute some of the fonts. Install all the fonts AgriLife provides at the [Marketing and Communications branding website](https://agrilife.tamu.edu/marketing-and-communications/resources/branding-agrilife/).

In order to use the pdf template, please install the tinytex package:

Expand Down Expand Up @@ -79,7 +79,7 @@ p1 <- Dissolved_Oxygen %>%
color = Station_ID)) +
geom_boxplot(alpha = 0.5) +
geom_jitter(alpha = 0.9, width = 0.1, height = 0) +
theme_TWRI_fig() +
theme_TWRI_print() +
scale_color_discrete_twri(name = "Station ID") +
scale_fill_discrete_twri(name = "Station ID") +
labs(x = "Station ID",
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ remotes::install_github("TxWRI/twriTemplates")
### Prerequisites

The Rmarkdown templates assume the required fonts are installed on your
system. The `Minion Pro` and `Open Sans` fonts among others are used by
the various templates and themes. We aren’t licensed to distribute some
of the fonts. Install all the fonts AgriLife provides at the [Marketing
and Communications branding
system. The `Minion Pro` font among others are used by the various
templates and themes. We aren’t licensed to distribute some of the
fonts. Install all the fonts AgriLife provides at the [Marketing and
Communications branding
website](https://agrilife.tamu.edu/marketing-and-communications/resources/branding-agrilife/).

In order to use the pdf template, please install the tinytex package:
Expand Down Expand Up @@ -86,7 +86,7 @@ p1 <- Dissolved_Oxygen %>%
color = Station_ID)) +
geom_boxplot(alpha = 0.5) +
geom_jitter(alpha = 0.9, width = 0.1, height = 0) +
theme_TWRI_fig() +
theme_TWRI_print() +
scale_color_discrete_twri(name = "Station ID") +
scale_fill_discrete_twri(name = "Station ID") +
labs(x = "Station ID",
Expand Down
Loading

0 comments on commit 9d20c79

Please sign in to comment.