Set the font for cell text

font(ht)
font(ht) <- value
set_font(ht, row, col, value )
map_font(ht, row, col, fn)

Arguments

ht

A huxtable.

row

A row specifier. See rowspecs for details.

col

An optional column specifier.

fn

A mapping function. See mapping-functions for details.

value

A character vector or matrix.

Set to NA to reset to the default, which is "NA".

Value

font() returns the font property. set_font() returns the modified huxtable.

Details

To find out what fonts are on your system, systemfonts::match_font() is useful.

For HTML, you can use comma-separated lists of font names like "Times New Roman, Times, Serif". This is not portable, though.

LaTeX and HTML use different font names. To use the same font names across document formats, see options("huxtable.latex_use_fontspec") in huxtable-options.

See also

Other formatting functions: background_color(), bold(), font_size(), na_string(), number_format(), text_color()

Examples


font(jams) <-  "times"
font(jams)
#>     Type    Price  
#> 1   "times" "times"
#> 1.1 "times" "times"
#> 2   "times" "times"
#> 3   "times" "times"

jams2 <- set_font(jams,
      "arial")
font(jams2)
#>     Type    Price  
#> 1   "arial" "arial"
#> 1.1 "arial" "arial"
#> 2   "arial" "arial"
#> 3   "arial" "arial"

jams3 <- set_font(jams,
      2:3, 1, "arial")
font(jams3)
#>     Type    Price  
#> 1   "times" "times"
#> 1.1 "arial" "times"
#> 2   "arial" "times"
#> 3   "times" "times"

jams4 <- map_font(jams,
      by_rows(
        "arial",
        "times")
      )
font(jams4)
#>     Type    Price  
#> 1   "arial" "arial"
#> 1.1 "times" "times"
#> 2   "arial" "arial"
#> 3   "times" "times"