| font | R Documentation |
Change the font of selected rows and columns of a flextable.
Fonts impact the readability and aesthetics of the table. Font families refer to a set of typefaces that share common design features, such as 'Arial' and 'Open Sans'.
'Google Fonts' is a popular library of free web fonts that can be
easily integrated into flextable with the gdtools::register_gfont() function.
When the output is HTML, the font will be automatically added to the HTML
document.
font(
x,
i = NULL,
j = NULL,
fontname,
part = "body",
cs.family = fontname,
hansi.family = fontname,
eastasia.family = fontname
)
x |
a 'flextable' object, see flextable-package to learn how to create 'flextable' object. |
i |
row selector, see section Row selection with the |
j |
column selector, see section Column selection with the |
fontname |
single character value, the font family name. With Word and PowerPoint output, this value specifies the font to be used for formatting characters in the Unicode range (U+0000-U+007F). |
part |
part selector, see section Part selection with the |
cs.family |
Optional font to be used for formatting
characters in a complex script Unicode range. For example, Arabic
text might be displayed using the "Arial Unicode MS" font.
Used only with Word and PowerPoint outputs. The default value is the value
of |
hansi.family |
Optional font to be used for formatting
characters in a Unicode range that does not fall into one of the
other categories.
Used only with Word and PowerPoint outputs. The default value is the value
of |
eastasia.family |
Optional font to be used for
formatting characters in an East Asian Unicode range. For example,
Japanese text might be displayed using the "MS Mincho" font.
Used only with Word and PowerPoint outputs. The default value is the value
of |
Other formatting shortcuts:
align(),
bg(),
bold(),
color(),
empty_blanks(),
fontsize(),
highlight(),
indentation(),
italic(),
keep_with_next(),
line_spacing(),
padding(),
rotate(),
style(),
tab_settings(),
valign()
library(gdtools)
fontname <- "Brush Script MT"
if (font_family_exists(fontname)) {
ft_1 <- flextable(head(iris))
ft_2 <- font(ft_1, fontname = fontname, part = "header")
ft_2 <- font(ft_2, fontname = fontname, j = 5)
ft_2
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.