flextable icon indicating copy to clipboard operation
flextable copied to clipboard

Allow font-family to be inherited if font.family is set to empty

Open zeripath opened this issue 7 months ago • 0 comments

I'm unsure whether this would work in all output formats, but it would be good to not have to set the font-family explicitly for flextable and instead just inherit directly from the css/styling outside of the flextable.

I propose, that either, one sets the font.family to "" (or NA) and then in runs_as_functions.R change:

https://github.com/davidgohel/flextable/blob/39d821417360da091363676e89cee273759fe919/R/runs_as_functions.R#L10

to simply detect if it's "", e.g.:

family <- ""
if (x$font.family != "") {
  family <- sprintf("font-family:'%s';", x$font.family) 
}

or for NA:

family <- ""
if (!is.na(x$font.family) {
  family <- sprintf("font-family:'%s';", x$font.family) 
}

AFAIC The font-family should then simply be inherited from the rest of the document.

zeripath avatar Mar 13 '25 15:03 zeripath