Skip to content

Commit

Permalink
doc: improve gen_grob manual
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgohel committed Mar 5, 2024
1 parent 8afca7b commit a24947d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ License: GPL-3
Imports:
stats, utils, grDevices, graphics, grid,
rmarkdown, knitr, htmltools, rlang, ragg,
officer (>= 0.6.5), gdtools (>= 0.3.3),
officer (>= 0.6.5), gdtools (>= 0.3.6),
xml2, data.table (>= 1.13.0), uuid (>= 0.1-4)
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Expand Down
38 changes: 23 additions & 15 deletions R/grid_grobs.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,33 @@
#'
#' @return a grob (gTree) object made with package `grid`
#' @examples
#' library(ragg)
#' library(gdtools)
#' register_liberationsans()
#'
#' set_flextable_defaults(font.family = "Liberation Sans")
#'
#' ft <- flextable(head(mtcars))
#' ft <- autofit(ft)
#'
#' gr <- gen_grob(ft)
#'
#' used_family <- get_flextable_defaults()$font.family
#' if (gdtools::font_family_exists(used_family) &&
#' require("ragg")) {
#' png_f <- tempfile(fileext = ".png")
#' # get the size
#' dims <- dim(gr)
#' dims
#' ragg::agg_png(
#' filename = png_f, width = dims$width + .1,
#' height = dims$height + .1, units = "in", res = 150
#' )
#' plot(gr)
#' dev.off()
#' }
#' png_f_1 <- tempfile(fileext = ".png")
#' ragg::agg_png(
#' filename = png_f_1, width = 4, height = 2,
#' units = "in", res = 150)
#' plot(gr)
#' dev.off()
#'
#' png_f_2 <- tempfile(fileext = ".png")
#' # get the size
#' dims <- dim(gr)
#' dims
#' ragg::agg_png(
#' filename = png_f_2, width = dims$width + .1,
#' height = dims$height + .1, units = "in", res = 150
#' )
#' plot(gr)
#' dev.off()
#' @family flextable print function
#' @importFrom grid gTree
gen_grob <- function(x,
Expand Down
40 changes: 24 additions & 16 deletions man/gen_grob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a24947d

Please sign in to comment.