sprinkle_font: Sprinkle the Characteristics of Text in a Cell

Description Usage Arguments Details Functional Requirements Author(s) See Also

View source: R/sprinkle_font.R

Description

Text can be made to stand out (or fade away) by using font features such as bold and italic text, color, size, or different fonts.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
sprinkle_font(
  x,
  rows = NULL,
  cols = NULL,
  bold = NULL,
  italic = NULL,
  font_size = NULL,
  font_size_units = NULL,
  font_color = NULL,
  font_family = NULL,
  ...,
  part = c("body", "head", "foot", "interfoot", "table"),
  fixed = FALSE,
  recycle = "none"
)

## Default S3 method:
sprinkle_font(
  x,
  rows = NULL,
  cols = NULL,
  bold = NULL,
  italic = NULL,
  font_size = NULL,
  font_size_units = NULL,
  font_color = NULL,
  font_family = NULL,
  ...,
  part = c("body", "head", "foot", "interfoot", "table"),
  fixed = FALSE,
  recycle = "none"
)

## S3 method for class 'dust_list'
sprinkle_font(
  x,
  rows = NULL,
  cols = NULL,
  bold = NULL,
  italic = NULL,
  font_size = NULL,
  font_size_units = NULL,
  font_color = NULL,
  font_family = NULL,
  ...,
  part = c("body", "head", "foot", "interfoot", "table"),
  fixed = FALSE,
  recycle = "none"
)

Arguments

x

An object of class dust

rows

Either a numeric vector of rows in the tabular object to be modified or an object of class call. When a call, generated by quote(expression), the expression resolves to a logical vector the same length as the number of rows in the table. Sprinkles are applied to where the expression resolves to TRUE.

cols

Either a numeric vector of columns in the tabular object to be modified, or a character vector of column names. A mixture of character and numeric indices is permissible.

bold

logical(1) indicating if the text in the selected cells should be made bold.

italic

logical(1) indicating if the text in the selected cells should be made italic.

font_size

numeric(1) giving the font size.

font_size_units

character(1) giving the units of the font size. May be any of c("px", "pt", "%", "em"). LaTeX output only recognizes "pt" and "em". For LaTeX output, "px" is quietly changed to "pt" when printing.

font_color

character(1) giving a valid color name for the text.

font_family

character(1) giving the font name for the text. This is only recognized in HTML output.

...

Additional arguments to pass to other methods. Currently ignored.

part

A character string denoting which part of the table to modify.

fixed

logical(1) indicating if the values in rows and cols should be read as fixed coordinate pairs. By default, sprinkles are applied at the intersection of rows and cols, meaning that the arguments do not have to share the same length. When fixed = TRUE, they must share the same length.

recycle

A character one that determines how sprinkles are managed when the sprinkle input doesn't match the length of the region to be sprinkled. By default, recycling is turned off. Recycling may be performed across rows first (left to right, top to bottom), or down columns first (top to bottom, left to right).

Details

The bold and italic features are recognized by all formats.

Font size features are recognized by HTML and LaTeX. LaTeX only recognizes the font size unit options of "pt" and "em", but will quietly change "px" to "pt" when printing.

Font color features are recognized by HTML and LaTeX.

Font family is only recognized by HTML.

Functional Requirements

  1. Correctly change the bold column of the table part for the selected cells.

  2. Correctly change the italic column of the table part for the selected cells.

  3. Correctly change the font_size column of the table part for the selected cells.

  4. Correctly change the font_size_units column of the table part for the selected cells.

  5. Correctly chagne the font_color column of the table part for the selected cells.

  6. Correctly change the font_family column of the table part for the selected cells.

  7. Cast an error if x is not a dust object.

  8. Cast an error if bold is not logical(1)

  9. Cast an error if italic is not logical(1)

  10. Cast an error if font_size is not numeric(1)

  11. Cast an error if font_size_units is not character(1)

  12. Cast an error if font_size_units is not one of px, pt, em, or

  13. Cast an error if font_color is not character(1)

  14. Cast an error if font_family is not character(1)

  15. Cast an error if part is not a subset of c("body", "head", "foot", "interfoot")

  16. Cast an error if recycle = "none" and bold does not have length 1.

  17. Cast an error if recycle = "none" and italic does not have length 1.

  18. Cast an error if recycle = "none" and font_size does not have length 1.

  19. Cast an error if recycle = "none" and font_size_units does not have length 1.

  20. Cast an error if recycle = "none" and font_color does not have length 1.

  21. Cast an error if recycle = "none" and font_family does not have length 1.

The functional behavior of the fixed and recycle arguments is not tested for this function. It is tested and validated in the tests for index_to_sprinkle.

Author(s)

Benjamin Nutter

See Also

sprinkle


pixiedust documentation built on Jan. 16, 2021, 5:25 p.m.