Skip to content

Commit

Permalink
version 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bwiernik authored and cran-robot committed Sep 16, 2022
1 parent 6b5a7de commit 7c53188
Show file tree
Hide file tree
Showing 17 changed files with 185 additions and 142 deletions.
36 changes: 23 additions & 13 deletions DESCRIPTION
@@ -1,14 +1,23 @@
Package: gridtext
Type: Package
Title: Improved Text Rendering Support for 'Grid' Graphics
Version: 0.1.4
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
Expand All @@ -17,17 +26,18 @@ URL: https://wilkelab.org/gridtext/
BugReports: https://github.com/wilkelab/gridtext/issues
License: MIT + file LICENSE
Depends: R (>= 3.5)
Imports: grid, grDevices, markdown, rlang, Rcpp, RCurl, png, jpeg,
Imports: curl, grid, grDevices, markdown, rlang, Rcpp, png, jpeg,
stringr, xml2
Suggests: covr, knitr, rmarkdown, testthat, vdiffr
LinkingTo: Rcpp
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
SystemRequirements: C++11
NeedsCompilation: yes
Packaged: 2020-12-10 20:29:04 UTC; clauswilke
Author: Claus O. Wilke [aut, cre] (<https://orcid.org/0000-0002-7470-9261>)
Maintainer: Claus O. Wilke <wilke@austin.utexas.edu>
Packaged: 2022-09-15 13:49:42 UTC; brentonw
Author: Claus O. Wilke [aut] (<https://orcid.org/0000-0002-7470-9261>),
Brenton M. Wiernik [aut, cre] (<https://orcid.org/0000-0001-9560-6336>,
@bmwiernik)
Maintainer: Brenton M. Wiernik <brenton@wiernik.org>
Repository: CRAN
Date/Publication: 2020-12-10 20:50:02 UTC
Date/Publication: 2022-09-16 11:16:15 UTC
29 changes: 15 additions & 14 deletions MD5
@@ -1,30 +1,30 @@
a81cd9ab95ddcbff8baecc2c2e97b4b2 *DESCRIPTION
f3d0555788d67826ba869802fdd0f970 *DESCRIPTION
39276fab68fb6f733821e2f243383213 *LICENSE
0857ec650ec6eaebb76f061ff2d67a68 *NAMESPACE
1bf4e40b7bdc98e7bb9478baba344c96 *NEWS.md
86d99a4c02df8f471228fb6b33c930f4 *NEWS.md
b35088f9df099335362baa60c94fabb9 *R/RcppExports.R
4527d6b21d7c1bb4691dde35ee928398 *R/drawing-context.R
1505f684fb64bc1430b1639f3b973720 *R/drawing-context.R
33ddf7bf682842d3d1e18a29302f3c38 *R/grid-utils.R
c75f2b410d48d061281f07fa280c3120 *R/gridtext.R
d441b7c0ec23dc1e813e4efc421e4c62 *R/grob-zero.R
0c7639a9d088da143da79eccc7d103e7 *R/parse-css.R
6f2fdb69ac961039af6d814b61dae5d0 *R/process-tags.R
ce37c3f6ac753f22d2a04ec8c9d4a965 *R/read-image.R
11fe35d92b60aeb21a5e1a039e048833 *R/read-image.R
14f402b6578dc90c2ccc237fd5985d9a *R/recycle-gpar.R
78d868e02a776fa994f8ef9c1b0c35f2 *R/richtext-grob.R
993e909e3ca88ea9454c1b6c307fd560 *R/text-details.R
b1effa033bea2bafdbc7696a60e7d458 *R/text-details.R
a5bd8b3d723da070417833237a931d6a *R/textbox-grob.R
6b0f56d8948306eea2700dcd4f951c56 *README.md
bbe289c4fff2d847fd93d09f61b8731a *README.md
a424816ce3f3342cdd6254853ef2ff55 *inst/extdata/Rlogo.png
4b91fa975d9b9a1c36e4f0796fb94d9b *man/figures/README-unnamed-chunk-4-1.png
b38817d8e9a2491e5dcfbb45a6f3b8c7 *man/figures/README-unnamed-chunk-5-1.png
444041d0d8b1efa2e4b96a01923728ff *man/figures/README-unnamed-chunk-6-1.png
5042b5bf2843319ddb68bb50144b4a12 *man/figures/README-unnamed-chunk-7-1.png
f05ca7e8590471689cf00f242952751f *man/figures/README-unnamed-chunk-8-1.png
af9ea4783f9da353be659b69350558f1 *man/figures/README-unnamed-chunk-4-1.png
b4e9131dcbdf1c21cafa4ebbe137c258 *man/figures/README-unnamed-chunk-5-1.png
7e57d63476e09ecde6b2b730c9f08819 *man/figures/README-unnamed-chunk-6-1.png
ed4b2603a3a06bdd360e54455c711aa6 *man/figures/README-unnamed-chunk-7-1.png
b5a7c31a715ce207b896f25fc573b1da *man/figures/README-unnamed-chunk-8-1.png
5c51af6b80be93402d056d83ef476473 *man/gridtext.Rd
670d7725c7c9e0122bac4bbbf9c49c6e *man/richtext_grob.Rd
725c355183ac984c7c998f776f344a7e *man/textbox_grob.Rd
cb6e7b0f75173d5b42376d6ccaaae425 *src/RcppExports.cpp
7eb4d6f0f775937d765e69a38edbd6bb *src/RcppExports.cpp
b768a47be0be837939ac29e35472f98e *src/bl-r-bindings.cpp
d269719f4d854f1631ef0855544996c2 *src/glue.h
37903129a8e47d97fe238f007c62fd75 *src/grid-renderer.cpp
Expand All @@ -38,7 +38,7 @@ fe9e6d3d255267f5c38d99d167b434e9 *src/layout.h
2fca8c188ccdc7e31da70a673d793992 *src/null-box.h
52a50bc433ecc83670967956e45f6f09 *src/par-box.h
cb46811dca7dc0d664c1c215184dcefd *src/penalty.h
63c950ab0c0fbba33290ff8c42d25a1a *src/raster-box.h
667b6ab8e3d2f747074b121f21f6bd1c *src/raster-box.h
2693123ffb9befabf5ca09312c049e93 *src/rect-box.h
089683ed503534bc7875101e82df704c *src/text-box.h
1231c98d2f4345736a6460869b5341b6 *src/vbox.h
Expand All @@ -50,15 +50,16 @@ c54d3410efb2abfb584a3df1898a1149 *tests/figs/grid-renderer/text-in-different-sty
b693385997bec7757f486fc9587d34aa *tests/figs/richtext-grob/aligned-widths.svg
2b84957ca9a04074e23f6fdb76bc888a *tests/figs/richtext-grob/various-text-boxes-w-debug.svg
b6dc6571ddad9bd0893269af602d0d47 *tests/figs/richtext-grob/various-text-boxes.svg
4338fd4ea5ae39e415ec2e29860d85b4 *tests/figs/test_image.png
29c1ec20c4fa45fd1701764204804eb2 *tests/figs/textbox-grob/box-spanning-entire-viewport-with-margins.svg
ac3d25a8bb15c8576e1e1be197e5b0ad *tests/figs/textbox-grob/multiple-boxes-internal-alignment.svg
f140c71bab32e5854d2eb9800abd1e49 *tests/figs/textbox-grob/multiple-boxes-inverted-internal-alignment.svg
f2d116c67913c1bbb2c946c4fd631ffd *tests/figs/textbox-grob/multiple-boxes-left-rotated-internal-alignment.svg
8d90a80333398e45985b4afd082bd7dc *tests/figs/textbox-grob/multiple-boxes-right-rotated-internal-alignment.svg
ac47bab71f229d8f1348f10a00972b0e *tests/figs/textbox-grob/rotation-around-fixed-point.svg
7cd33292d3bce2d48077d0ecc3b2a73e *tests/testthat.R
da111b5d5ed9b70155ae02a92bae48f8 *tests/testthat/Rplots.pdf
d9a7d5e06f4322eac9e14fddf2d6c974 *tests/testthat/helper-vdiffr.R
03978976647e2bcc1e69e02bc8b591b3 *tests/testthat/test-get_file.R
6bf9388356cea9d14c3cb4be5ff1fb95 *tests/testthat/test-grid-constructors.R
cf5970a12ce52be28cc42be15e732631 *tests/testthat/test-grid-renderer.R
6206e103f5f343de2c97d386dc016672 *tests/testthat/test-null-box.R
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
@@ -1,3 +1,10 @@
# 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
- Removed LazyData from package DESCRIPTION to fix CRAN NOTE

# gridtext 0.1.4

- Make sure tests don't fail if vdiffr is missing.
Expand Down
10 changes: 5 additions & 5 deletions R/drawing-context.R
Expand Up @@ -46,8 +46,8 @@ set_style <- function(drawing_context, style = NULL) {
update_gpar <- function(gp, gp_new) {
names_new <- names(gp_new)
names_old <- names(gp)
gp[c(intersect(names_old, names_new), "font")] <- NULL
gp_new["font"] <- NULL
gp[c(intersect(names_old, names_new), "fontface")] <- NULL
gp_new["fontface"] <- NULL
do.call(gpar, c(gp, gp_new))
}

Expand All @@ -70,13 +70,13 @@ set_context_gp <- function(drawing_context, gp = NULL) {

# update the fontface of a drawing context
set_context_fontface <- function(drawing_context, fontface = "plain", overwrite = FALSE) {
fontface_old <- drawing_context$gp$fontface
font_old <- drawing_context$gp$font

# combine bold and italic if needed
if (!isTRUE(overwrite)) {
if (isTRUE(fontface == "italic") && isTRUE(fontface_old == "bold")) {
if (isTRUE(fontface == "italic") && isTRUE(font_old == 2)) { # see ?grid::gpar for fontface codes
fontface <- "bold.italic"
} else if (isTRUE(fontface == "bold") && isTRUE(fontface_old == "italic")) {
} else if (isTRUE(fontface == "bold") && isTRUE(font_old == 3)) {
fontface <- "bold.italic"
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/read-image.R
Expand Up @@ -11,7 +11,7 @@ read_image <- function(path) {

get_file <- function(path) {
if (is_url(path)) {
RCurl::getBinaryURL(path)
curl::curl_fetch_memory(path)$content
} else {
path
}
Expand Down
22 changes: 11 additions & 11 deletions R/text-details.R
Expand Up @@ -3,7 +3,7 @@
#' Calculate text details for a given text label
#' @param label Character vector containing the label. Can handle only one label at a time.
#' @param gp Grid graphical parameters defining the font (`fontfamily`, `fontface`, and
#' `fontface` should be defined).
#' `fontsize` should be defined).
#' @examples
#' text_details("Hello world!", grid::gpar(fontfamily = "", fontface = "plain", fontsize = 12))
#' text_details("Hello world!", grid::gpar(fontfamily = "", fontface = "plain", fontsize = 24))
Expand All @@ -14,11 +14,11 @@
#' @noRd
text_details <- function(label, gp = gpar()) {
fontfamily <- gp$fontfamily %||% grid::get.gpar("fontfamily")$fontfamily
fontface <- gp$fontface %||% grid::get.gpar("fontface")$fontface
font <- gp$font %||% grid::get.gpar("font")$font
fontsize <- gp$fontsize %||% grid::get.gpar("fontsize")$fontsize

devname <- names(grDevices::dev.cur())
fontkey <- paste0(devname, fontfamily, fontface, fontsize)
fontkey <- paste0(devname, fontfamily, font, fontsize)
if (devname == "null device") {
cache <- FALSE # don't cache if no device open
} else {
Expand All @@ -30,16 +30,16 @@ text_details <- function(label, gp = gpar()) {
}

# ascent and width depend on label and font
l1 <- text_info(label, fontkey, fontfamily, fontface, fontsize, cache)
l1 <- text_info(label, fontkey, fontfamily, font, fontsize, cache)
# descent and space width depend only on font
l2 <- font_info(fontkey, fontfamily, fontface, fontsize, cache)
l2 <- font_info(fontkey, fontfamily, font, fontsize, cache)

# concatenate, result is a list with four members, width_pt, ascent_pt, descent_pt, space_pt
c(l1, l2)
}

font_info_cache <- new.env(parent = emptyenv())
font_info <- function(fontkey, fontfamily, fontface, fontsize, cache) {
font_info <- function(fontkey, fontfamily, font, fontsize, cache) {
info <- font_info_cache[[fontkey]]

if (is.null(info)) {
Expand All @@ -48,7 +48,7 @@ font_info <- function(fontkey, fontfamily, fontface, fontsize, cache) {
gp = gpar(
fontsize = fontsize,
fontfamily = fontfamily,
fontface = fontface,
font = font,
cex = 1
)
)), "pt", valueOnly = TRUE)
Expand All @@ -58,7 +58,7 @@ font_info <- function(fontkey, fontfamily, fontface, fontsize, cache) {
gp = gpar(
fontsize = fontsize,
fontfamily = fontfamily,
fontface = fontface,
font = font,
cex = 1
)
)), "pt", valueOnly = TRUE)
Expand All @@ -73,7 +73,7 @@ font_info <- function(fontkey, fontfamily, fontface, fontsize, cache) {
}

text_info_cache <- new.env(parent = emptyenv())
text_info <- function(label, fontkey, fontfamily, fontface, fontsize, cache) {
text_info <- function(label, fontkey, fontfamily, font, fontsize, cache) {
key <- paste0(label, fontkey)
info <- text_info_cache[[key]]

Expand All @@ -83,7 +83,7 @@ text_info <- function(label, fontkey, fontfamily, fontface, fontsize, cache) {
gp = gpar(
fontsize = fontsize,
fontfamily = fontfamily,
fontface = fontface,
font = font,
cex = 1
)
)), "pt", valueOnly = TRUE)
Expand All @@ -93,7 +93,7 @@ text_info <- function(label, fontkey, fontfamily, fontface, fontsize, cache) {
gp = gpar(
fontsize = fontsize,
fontfamily = fontfamily,
fontface = fontface,
font = font,
cex = 1
)
)), "pt", valueOnly = TRUE)
Expand Down

0 comments on commit 7c53188

Please sign in to comment.