with_font_sizes: Wrap a table formatter so it applies fixed font sizes

View source: R/ft_formats.R

with_font_sizesR Documentation

Wrap a table formatter so it applies fixed font sizes

Description

Returns a new table-format function that behaves like 'table_format' but with the supplied font sizes injected. This is the generic mechanism used by [generate_slides()] to honor per-slide 'font_size' settings declared in the spec: a single 'table_format' symbol can carry body/header/footer sizes.

Sizes are only forwarded to arguments the underlying formatter actually declares. A formatter with an explicit 'body_font_size'/'header_font_size'/ 'footer_font_size' argument (or a '...') receives the corresponding size; sizes a formatter cannot accept are dropped rather than raising an "unused argument" error. Additional arguments supplied when the returned function is called are forwarded to the underlying formatter. When no sizes are supplied the original formatter is returned unchanged.

Usage

with_font_sizes(
  table_format,
  body_font_size = NULL,
  header_font_size = NULL,
  footer_font_size = NULL
)

Arguments

table_format

A function taking a flextable as its first argument and returning a flextable (e.g. [autoslider_format()], [black_format_tb()]).

body_font_size, header_font_size, footer_font_size

Point sizes. 'NULL' (the default) leaves that part to the underlying formatter default.

Value

A function 'function(ft, ...)' returning a styled flextable.

Examples

small <- with_font_sizes(black_format_tb, body_font_size = 6, header_font_size = 6)
ft <- flextable::flextable(head(mtcars))
small(ft)

autoslider.core documentation built on Sept. 29, 2026, 5:08 p.m.