rstudio / fontawesome

Easily insert FontAwesome icons into R Markdown docs and Shiny apps
https://rstudio.github.io/fontawesome/
Other
295 stars 39 forks source link

warning with package first loading for v4 icon compatible check #76

Closed dracodoc closed 2 years ago

dracodoc commented 2 years ago

With shiny::icon() calling fontawesome::fa_i(), there is a check for v4 icon names. With a fresh R session, this process will generate a warning even when icon name is a valid v5 name.

This is a simple shiny app, icon used is valid in both v4 and v5.

library(shiny)
ui <- fluidPage(
  icon("file")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)

Loading required package: shiny
Warning in name %in% fa_tbl$v4_name :
  strings not representable in native encoding will be translated to UTF-8

It seemed that fa_i checked icon name and didn't find any problem, but still this checking process generated warning when there are some string encoding issues in fa_tbl$v4_name. This might be related to my Chinese locale, but I think it still need to be fixed in some way.

My session info

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936  LC_CTYPE=Chinese (Simplified)_China.936   
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C                              
[5] LC_TIME=Chinese (Simplified)_China.936    
dracodoc commented 2 years ago

Easier way to trigger the warning:

> library(fontawesome)
> fa_i("file")
Warning message:
In mget(objectNames, envir = ns, inherits = TRUE) :
  strings not representable in native encoding will be translated to UTF-8
DavZim commented 2 years ago

I have the same problem (with a a german or english locale).

For example the exclamation-triangle icon throws a warning but renders fine in a shiny app.

This Font Awesome icon ('exclamation-triangle') does not exist:
* if providing a custom `html_dependency` these `name` checks can 
  be deactivated with `verify_fa = FALSE`

When I use fontawesome::fa_i("exclamation-triangle") the warning is shown as well and the icon renders (shiny::icon calls fa_i after all) but when I use fontawesome::fa("exclamation-triangle"), it throws an error and no icon is shown.

rich-iannone commented 2 years ago

This is now fixed in https://github.com/rstudio/fontawesome/pull/96.