You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use as_raw_html() to attach my {gt} tables to {blastula} emails, but I noticed the custom fonts from google_font() gets dropped in the process.
Reproducible example
weekly_email= compose_email(
header= add_image("resources/combined_logo.png")
body= blocks(
block_title("weekly Report"),
block_text(html(str_c(
"<center> Sent on ", add_readable_time(),
"<br>This email report is also attached as PDF & HTML files!</center>"
))),
block_articles(
article(content= as_raw_html(gt_marketplace))
),
block_articles(
article(content= as_raw_html(price_summary)),
article(content= add_ggplot(plt_price_history, width=10, height=4))
),
)
)
The {gt} tables will default to the client default font. I did come up with a work-around for 1 custom font, but it would need to be tweaked for multiple fonts. Here is the custom function:
as_raw_html_with_google_font.R=function(gt, font_name="Roboto", font_family_css="Roboto") {
# Transfrom {gt} to HTMLhtml_gt= as_raw_html(gt)
# Embed Google Font link in the HTML headergoogle_font_link= paste0(
"https://fonts.googleapis.com/css2?family=",
font_family_css,
"&display=swap")
# Define CSS to apply the Google Font to the {gt} tablecss_content= sprintf(" <style> .gt_table { font-family: '%s', sans-serif; } </style>", font_name)
# Combine the font link and CSS with the HTMLhtmltools::tagList(
tags$head(
tags$link(href=google_font_link, rel="stylesheet"),
HTML(css_content)
),
HTML(html_gt)
)
}
The text was updated successfully, but these errors were encountered:
Description
I use as_raw_html() to attach my {gt} tables to {blastula} emails, but I noticed the custom fonts from google_font() gets dropped in the process.
Reproducible example
The {gt} tables will default to the client default font. I did come up with a work-around for 1 custom font, but it would need to be tweaked for multiple fonts. Here is the custom function:
The text was updated successfully, but these errors were encountered: