MyNixOS website logo
Description

Utilities for Graphical Rendering and Fonts Management.

Tools are provided to compute metrics of formatted strings and to check the availability of a font. Another set of functions is provided to support the collection of fonts from 'Google Fonts' in a cache. Their use is simple within 'R Markdown' documents and 'shiny' applications but also with graphic productions generated with the 'ggiraph', 'ragg' and 'svglite' packages or with tabular productions from the 'flextable' package.

gdtools

CRANstatus R buildstatus codecov testcoverage

The package gdtools provides functionalities to get font metrics and to generate base64 encoded string from raster matrix. It is used by package ‘flextable’ and ‘rvg’ to allow font metric calculation but can also be used to compute the exact size a text would have with specific font options (size, bold, italic).

library(gdtools)
str_extents(c("a string", "a longer string"), 
  fontsize = 24, bold = TRUE, italic = TRUE)
#>           [,1]     [,2]
#> [1,]  86.68359 22.60547
#> [2,] 166.68750 22.60547

Another set of functions is provided to support the collection of fonts from ‘Google Fonts’ in a cache. Their use is simple within ‘R Markdown’ documents and ‘shiny’ applications but also with graphic productions generated with the ‘ggiraph’, ‘ragg’ and ‘svglite’ packages or with tabular productions from the ‘flextable’ package.

# Download to a user cache and register the font with systemfonts
register_gfont(family = "Open Sans")

If you need a ‘Google Font’ to be installed on your machine, you can use install_gfont_script().

install_gfont_script("Fira Sans", file = "firafont.sh")

You then have to run ./firafont.sh.

Installation

You can install the released version of gdtools from CRAN with:

install.packages("gdtools")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("davidgohel/gdtools")
Metadata

Version

0.3.7

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows