diff --git a/DESCRIPTION b/DESCRIPTION index e0ce907..a591b36 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,23 @@ Package: gridtext Type: Package Title: Improved Text Rendering Support for 'Grid' Graphics -Version: 0.1.4.9000 +Version: 0.1.5 Authors@R: - person( - given = "Claus O.", - family = "Wilke", - role = c("aut", "cre"), - email = "wilke@austin.utexas.edu", - comment = c(ORCID = "0000-0002-7470-9261") + c( + person( + given = "Claus O.", + family = "Wilke", + role = c("aut"), + email = "wilke@austin.utexas.edu", + comment = c(ORCID = "0000-0002-7470-9261") + ), + person( + given = "Brenton M.", + family = "Wiernik", + role = c("aut", "cre"), + email = "brenton@wiernik.org", + comment = c(ORCID = "0000-0001-9560-6336", Twitter = "@bmwiernik") + ) ) Description: Provides support for rendering of formatted text using 'grid' graphics. Text can be formatted via a minimal subset of 'Markdown', 'HTML', and inline 'CSS' directives, and it can be diff --git a/NEWS.md b/NEWS.md index b199af4..29a244b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,8 @@ -# gridtext 0.1.4.9000 +# gridtext 0.1.5 - Transition to curl package and drop RCurl dependency - Fix fontface not being processed and words spaced properly in R 4.2.0 +- Maintainer changes to Brenton Wiernik # gridtext 0.1.4 diff --git a/README.Rmd b/README.Rmd index 0287e04..182b1d1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,7 +19,7 @@ knitr::opts_chunk$set( status](https://github.com/wilkelab/gridtext/workflows/R-CMD-check/badge.svg)](https://github.com/wilkelab/gridtext/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/wilkelab/gridtext/master.svg)](https://codecov.io/github/wilkelab/gridtext?branch=master) [![CRAN status](https://www.r-pkg.org/badges/version/gridtext)](https://cran.r-project.org/package=gridtext) -[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) +[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing) Improved text rendering support for grid graphics in R. @@ -164,7 +164,7 @@ grid.draw(g) ## Acknowledgments -This project is receiving [financial support](https://www.r-consortium.org/projects/awarded-projects) from the [R consortium.](https://www.r-consortium.org) +This project received [financial support](https://www.r-consortium.org/all-projects/awarded-projects) from the [R consortium.](https://www.r-consortium.org) diff --git a/README.md b/README.md index 3b93375..5e9ea27 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -gridtext -======== +# gridtext @@ -13,25 +12,27 @@ Status](https://img.shields.io/codecov/c/github/wilkelab/gridtext/master.svg)](h [![CRAN status](https://www.r-pkg.org/badges/version/gridtext)](https://cran.r-project.org/package=gridtext) [![Lifecycle: -maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) +maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html#maturing) Improved text rendering support for grid graphics in R. -Installation ------------- +## Installation You can install the current release from CRAN with `install.packages()`: - install.packages("gridtext") +``` r +install.packages("gridtext") +``` To install the latest development version of this package, please run the following line in your R console: - remotes::install_github("wilkelab/gridtext") +``` r +remotes::install_github("wilkelab/gridtext") +``` -Examples --------- +## Examples The gridtext package provides two new grobs, `richtext_grob()` and `textbox_grob()`, which support drawing of formatted text labels and @@ -58,39 +59,41 @@ It is vectorized and can draw multiple text labels with one call. Labels can be drawn with padding, margins, and at arbitrary angles. Markdown and HTML parsing is turned on by default. - library(grid) - library(gridtext) - - text <- c( - "Some text **in bold.**", - "Linebreaks
Linebreaks
Linebreaks", - "*x*2 + 5*x* + *C**i*", - "Some blue text **in bold.**
And *italics text.*
And some large text." - ) - - x <- c(.2, .1, .7, .9) - y <- c(.8, .4, .1, .5) - rot <- c(0, 0, 45, -45) - gp = gpar( - col = c("black", "red"), - fontfamily = c("Palatino", "Courier", "Times", "Helvetica") - ) - box_gp = gpar( - col = "black", fill = c(NA, "cornsilk", "lightblue1", NA), - lty = c(0, 1, 1, 1) - ) - hjust <- c(0.5, 0, 0, 1) - vjust <- c(0.5, 1, 0, 0.5) - - grid.newpage() - g <- richtext_grob( - text, x, y, hjust = hjust, vjust = vjust, rot = rot, - padding = unit(c(6, 6, 4, 6), "pt"), - r = unit(c(0, 2, 4, 8), "pt"), - gp = gp, box_gp = box_gp - ) - grid.draw(g) - grid.points(x, y, default.units = "npc", pch = 19, size = unit(5, "pt")) +``` r +library(grid) +library(gridtext) + +text <- c( + "Some text **in bold.**", + "Linebreaks
Linebreaks
Linebreaks", + "*x*2 + 5*x* + *C**i*", + "Some blue text **in bold.**
And *italics text.*
And some large text." +) + +x <- c(.2, .1, .7, .9) +y <- c(.8, .4, .1, .5) +rot <- c(0, 0, 45, -45) +gp = gpar( + col = c("black", "red"), + fontfamily = c("Palatino", "Courier", "Times", "Helvetica") +) +box_gp = gpar( + col = "black", fill = c(NA, "cornsilk", "lightblue1", NA), + lty = c(0, 1, 1, 1) +) +hjust <- c(0.5, 0, 0, 1) +vjust <- c(0.5, 1, 0, 0.5) + +grid.newpage() +g <- richtext_grob( + text, x, y, hjust = hjust, vjust = vjust, rot = rot, + padding = unit(c(6, 6, 4, 6), "pt"), + r = unit(c(0, 2, 4, 8), "pt"), + gp = gp, box_gp = box_gp +) +grid.draw(g) +grid.points(x, y, default.units = "npc", pch = 19, size = unit(5, "pt")) +``` ![](man/figures/README-unnamed-chunk-4-1.png) @@ -99,34 +102,38 @@ heights, and alignment of text inside the box (specified via `hjust` and `vjust`) is separate from alignment of the box relative to a reference point (specified via `box_hjust` and `box_vjust`). - text <- c("January", "February", "March", "April", "May") - x <- (1:5)/6 + 1/24 - y <- rep(0.8, 5) - g <- richtext_grob( - text, x, y, halign = 0, hjust = 1, - rot = 45, - padding = unit(c(3, 6, 1, 3), "pt"), - r = unit(4, "pt"), - align_widths = TRUE, - box_gp = gpar(col = "black", fill = "cornsilk") - ) - grid.newpage() - grid.draw(g) - grid.points(x, y, default.units = "npc", pch = 19, size = unit(5, "pt")) +``` r +text <- c("January", "February", "March", "April", "May") +x <- (1:5)/6 + 1/24 +y <- rep(0.8, 5) +g <- richtext_grob( + text, x, y, halign = 0, hjust = 1, + rot = 45, + padding = unit(c(3, 6, 1, 3), "pt"), + r = unit(4, "pt"), + align_widths = TRUE, + box_gp = gpar(col = "black", fill = "cornsilk") +) +grid.newpage() +grid.draw(g) +grid.points(x, y, default.units = "npc", pch = 19, size = unit(5, "pt")) +``` ![](man/figures/README-unnamed-chunk-5-1.png) Basic support for images is available as well. As of now, images will always be vertically aligned with the baseline of the text. - grid.newpage() +``` r +grid.newpage() - img_src <- system.file("extdata", "Rlogo.png", package = "gridtext") - text <- glue::glue("Image with native aspect ratio: And some more text.") - grid.draw(richtext_grob(text, x = 0.9, y = 0.7, hjust = 1)) +img_src <- system.file("extdata", "Rlogo.png", package = "gridtext") +text <- glue::glue("Image with native aspect ratio: And some more text.") +grid.draw(richtext_grob(text, x = 0.9, y = 0.7, hjust = 1)) - text <- glue::glue("Image with forced size: And some more text.") - grid.draw(richtext_grob(text, x = 0.9, y = 0.3, hjust = 1)) +text <- glue::glue("Image with forced size: And some more text.") +grid.draw(richtext_grob(text, x = 0.9, y = 0.3, hjust = 1)) +``` ![](man/figures/README-unnamed-chunk-6-1.png) @@ -141,50 +148,53 @@ support rendering the text box at arbitrary angles. Only four different orientations are supported, corresponding to a rotation by 0, 90, 180, and 270 degrees. - g <- textbox_grob( - "**The quick brown fox jumps over the lazy dog.**

- The quick brown fox jumps over the lazy dog. - The **quick brown fox** jumps over the lazy dog. - The quick brown fox jumps over the lazy dog.", - x = unit(0.5, "npc"), y = unit(0.7, "npc"), - gp = gpar(fontsize = 15), - box_gp = gpar(col = "black", fill = "lightcyan1"), - r = unit(5, "pt"), - padding = unit(c(10, 10, 10, 10), "pt"), - margin = unit(c(0, 10, 0, 10), "pt") - ) - grid.newpage() - grid.draw(g) +``` r +g <- textbox_grob( + "**The quick brown fox jumps over the lazy dog.**

+ The quick brown fox jumps over the lazy dog. + The **quick brown fox** jumps over the lazy dog. + The quick brown fox jumps over the lazy dog.", + x = unit(0.5, "npc"), y = unit(0.7, "npc"), + gp = gpar(fontsize = 15), + box_gp = gpar(col = "black", fill = "lightcyan1"), + r = unit(5, "pt"), + padding = unit(c(10, 10, 10, 10), "pt"), + margin = unit(c(0, 10, 0, 10), "pt") +) +grid.newpage() +grid.draw(g) +``` ![](man/figures/README-unnamed-chunk-7-1.png) The alignment parameters `hjust`, `vjust`, `halign`, and `valign` function just like they do in `richtext_grob()`. - g <- textbox_grob( - "**The quick brown fox jumps over the lazy dog.**

- The quick brown fox jumps over the lazy dog. - The **quick brown fox** jumps over the lazy dog. - The quick brown fox jumps over the lazy dog.", - x = unit(0.2, "npc"), y = unit(0.5, "npc"), - hjust = 0.5, vjust = 1, halign = 1, - gp = gpar(fontsize = 15), - box_gp = gpar(col = "black", fill = "lightcyan1"), - r = unit(5, "pt"), - padding = unit(c(10, 10, 10, 10), "pt"), - margin = unit(c(0, 10, 0, 10), "pt"), - orientation = "left-rotated" - ) - grid.newpage() - grid.draw(g) +``` r +g <- textbox_grob( + "**The quick brown fox jumps over the lazy dog.**

+ The quick brown fox jumps over the lazy dog. + The **quick brown fox** jumps over the lazy dog. + The quick brown fox jumps over the lazy dog.", + x = unit(0.2, "npc"), y = unit(0.5, "npc"), + hjust = 0.5, vjust = 1, halign = 1, + gp = gpar(fontsize = 15), + box_gp = gpar(col = "black", fill = "lightcyan1"), + r = unit(5, "pt"), + padding = unit(c(10, 10, 10, 10), "pt"), + margin = unit(c(0, 10, 0, 10), "pt"), + orientation = "left-rotated" +) +grid.newpage() +grid.draw(g) +``` ![](man/figures/README-unnamed-chunk-8-1.png) -Acknowledgments ---------------- +## Acknowledgments -This project is receiving [financial -support](https://www.r-consortium.org/projects/awarded-projects) from -the [R consortium.](https://www.r-consortium.org) +This project received [financial +support](https://www.r-consortium.org/all-projects/awarded-projects) +from the [R consortium.](https://www.r-consortium.org) diff --git a/cran-comments.md b/cran-comments.md index 442de1a..695e031 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,4 +1,4 @@ -Make sure tests don't fail just because vdiffr couldn't be installed, per request by Brian Ripley. +* Maintainer changes from Claus Wilke to Brenton Wiernik. ## Test environments * ubuntu 20.04, devel and release diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png index c08c045..c34d5ff 100644 Binary files a/man/figures/README-unnamed-chunk-4-1.png and b/man/figures/README-unnamed-chunk-4-1.png differ diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index a1ba480..fba0bc4 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index a992809..aa73189 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ diff --git a/man/figures/README-unnamed-chunk-7-1.png b/man/figures/README-unnamed-chunk-7-1.png index 260ce0f..a52b64a 100644 Binary files a/man/figures/README-unnamed-chunk-7-1.png and b/man/figures/README-unnamed-chunk-7-1.png differ diff --git a/man/figures/README-unnamed-chunk-8-1.png b/man/figures/README-unnamed-chunk-8-1.png index 0e85aff..16ffee4 100644 Binary files a/man/figures/README-unnamed-chunk-8-1.png and b/man/figures/README-unnamed-chunk-8-1.png differ