jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
195 stars 27 forks source link

Fontawesome icons in tab_source_notes() #81

Closed heerymichael closed 1 year ago

heerymichael commented 1 year ago

Hi

I have been trying to include fontawesome social media icons within the tab_source_note of a table but every time I try when the table is exported the icon does not appear.

The relevant code for the tab_cource_code is:

tab_source_note(html("Table by Michael Heery &#xf099 @HEERYMICHAEL | DATA: UNDERDOG"))

I just wanted to check that firstly it is even possible to include fontawesome icons in this part of the table, and if so is there something I am missing that is preventing it working?

Thank you for any help you can offer

Michael

jthomasmock commented 1 year ago

Howdy! I don't think the raw html string method you are attempting will work as fontawesome is not available by default, but you can use the fontawesome R package:

library(gt)

fa_icon <- as.character(fontawesome::fa("twitter"))

head(mtcars) |> 
  gt() |> 
  tab_source_note(html(glue::glue("Table by Michael Heery {fa_icon} @heerymichael | DATA: UNDERDOG"))) |> 
  gtsave("test.png")

knitr::include_graphics("test.png")

Created on 2023-02-19 by the reprex package (v2.0.1)

jthomasmock commented 1 year ago

Closed this for now, but let me know if that doesn't address your Question