This is a follow up question based on this other thread asking the same question: R Shiny: how to use fontawesome pro version with the icon function?.
I tried the accepted answer, but it works only for the free icons. Other icons are not rendered, that is, nothing appears.
Here is my unsuccessful attempt at rewriting the custom my_icon()
, "forked" from the linked thread above. My goal is to correctly account pro icons classes fas
, far
, fal
, fad
, under the assumption that iconClass
supposed to be, for example, fas fa-alien
(as in https://fontawesome.com/icons/alien?style=solid).
Still my change has no effect. Pro icons keep not appearing. So I must be missing something fundamental.
Note that I changed ./www/shared
into ./shared/
to avoid the warning:
Warning: Found subdirectories of your app's www/ directory that conflict with other resource URL prefixes. Consider renaming these directories: 'www/shared'
my_icon = function (name, class = NULL, lib = "font-awesome") {
prefixes <- list(`font-awesome` = "fa", glyphicon = "glyphicon")
prefix <- prefixes[[lib]]
if (is.null(prefix)) {
stop("Unknown font library '", lib, "' specified. Must be one of ",
paste0("\"", names(prefixes), "\"", collapse = ", "))
}
iconClass <- ""
if (!is.null(name) & is.null(class)) {
prefix_class <- prefix
iconClass <- paste0(prefix_class, " ", prefix, "-", name)
} else if (!is.null(name) & !is.null(class)) {
iconClass <- paste0(prefix, '-', name)
iconClass <- paste(class, iconClass)
}
# print(iconClass)
iconTag <- tags$i(class = iconClass)
if (lib == "font-awesome") {
htmlDependencies(iconTag) <- htmlDependency("font-awesome",
"5.13.0", "./shared/fontawesome",
stylesheet = c("css/all.min.css"))
}
htmltools::browsable(iconTag)
}