davidgohel / ggiraph

make 'ggplot' graphics interactive
https://davidgohel.github.io/ggiraph
761 stars 74 forks source link

Fontconfig error on mac OS #47

Closed ThoDuyNguyen closed 7 years ago

ThoDuyNguyen commented 7 years ago

My attempt

app_dir <- file.path( system.file(package = "ggiraph"), "shiny/cars" )
shinyAppDir(appDir = app_dir )

My session info:

Session info ---------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, darwin13.4.0        
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       Asia/Ho_Chi_Minh            
 date     2017-01-19                  

Packages -------------------------------------------------------------------------------------------------------
 package           * version    date       source                                       
 assertthat          0.1        2013-12-06 CRAN (R 3.3.0)                               
 base64enc           0.1-3      2015-07-28 CRAN (R 3.3.0)                               
 BTYD              * 2.4        2014-11-07 CRAN (R 3.3.0)                               
 BTYDplus          * 1.0.1      2016-12-14 CRAN (R 3.3.2)                               
 chron               2.3-47     2015-06-24 CRAN (R 3.3.0)                               
 coda                0.19-1     2016-12-08 CRAN (R 3.3.2)                               
 colorspace          1.2-6      2015-03-11 CRAN (R 3.3.0)                               
 contfrac            1.1-10     2016-05-26 CRAN (R 3.3.0)                               
 crosstalk           0.3.1      2016-12-12 Github (rstudio/crosstalk@da9ed3f)           
 d3heatmap         * 0.6.1.1    2016-02-23 CRAN (R 3.3.0)                               
 D3TableFilter     * 0.6        2016-12-12 Github (ThomasSiegmund/D3TableFilter@b5399e1)
 data.table          1.9.6      2015-09-19 CRAN (R 3.3.0)                               
 DBI               * 0.5-1      2016-09-10 cran (@0.5-1)                                
 deSolve             1.14       2016-09-05 CRAN (R 3.3.0)                               
 devtools            1.12.0     2016-06-24 CRAN (R 3.3.0)                               
 digest              0.6.10     2016-08-02 CRAN (R 3.3.0)                               
 dplyr             * 0.5.0      2016-06-24 CRAN (R 3.3.0)                               
 elliptic            1.3-7      2016-05-26 CRAN (R 3.3.0)                               
 gdtools             0.1.3      2016-11-11 CRAN (R 3.3.2)                               
 ggiraph           * 0.3.2.9000 2017-01-12 Github (davidgohel/ggiraph@973828b)          
 ggiraphExtra      * 0.1.2      2017-01-19 Github (cardiomoon/ggiraphExtra@19c9916)     
 ggplot2           * 2.2.1      2016-12-30 CRAN (R 3.3.2)                               
 gtable              0.2.0      2016-02-26 CRAN (R 3.3.0)                               
 gtools              3.5.0      2015-05-29 cran (@3.5.0)                                
 htmltools           0.3.5      2016-03-21 CRAN (R 3.3.0)                               
 htmlwidgets         0.8        2016-11-09 cran (@0.8)                                  
 httpuv              1.3.3      2015-08-04 CRAN (R 3.3.0)                               
 httr                1.2.1      2016-07-03 CRAN (R 3.3.0)                               
 hypergeo          * 1.2-13     2016-04-07 CRAN (R 3.3.0)                               
 jsonlite            1.1        2016-09-14 cran (@1.1)                                  
 labeling            0.3        2014-08-23 CRAN (R 3.3.0)                               
 lattice             0.20-34    2016-09-06 CRAN (R 3.3.2)                               
 lazyeval            0.2.0      2016-06-12 CRAN (R 3.3.0)                               
 lubridate         * 1.6.0      2016-09-13 CRAN (R 3.3.0)                               
 magrittr            1.5        2014-11-22 CRAN (R 3.3.0)                               
 maps              * 3.1.1      2016-07-27 cran (@3.1.1)                                
 MASS                7.3-45     2016-04-21 CRAN (R 3.3.2)                               
 Matrix              1.2-7.1    2016-09-01 CRAN (R 3.3.2)                               
 memoise             1.0.0      2016-01-29 CRAN (R 3.3.0)                               
 mgcv                1.8-15     2016-09-14 CRAN (R 3.3.2)                               
 mime                0.5        2016-07-07 CRAN (R 3.3.0)                               
 moonBook          * 0.1.3      2015-02-14 CRAN (R 3.3.0)                               
 munsell             0.4.3      2016-02-13 CRAN (R 3.3.0)                               
 mycor               0.1        2014-10-02 CRAN (R 3.3.0)                               
 mygamer           * 0.0.2      2016-12-27 local                                        
 mysquar.utilities   0.1.1      2017-01-16 local                                        
 nlme                3.1-128    2016-05-10 CRAN (R 3.3.2)                               
 plotly            * 4.5.6      2016-11-12 CRAN (R 3.3.2)                               
 plyr                1.8.4      2016-06-08 CRAN (R 3.3.0)                               
 png                 0.1-7      2013-12-03 CRAN (R 3.3.0)                               
 pool              * 0.1.0      2016-10-17 Github (rstudio/pool@13d3e59)                
 purrr               0.2.2      2016-06-18 CRAN (R 3.3.0)                               
 R.methodsS3         1.7.1      2016-02-16 CRAN (R 3.3.0)                               
 R.oo                1.21.0     2016-11-01 CRAN (R 3.3.0)                               
 R.utils             2.5.0      2016-11-07 CRAN (R 3.3.0)                               
 R6                  2.2.0      2016-10-05 cran (@2.2.0)                                
 RColorBrewer        1.1-2      2014-12-07 CRAN (R 3.3.0)                               
 Rcpp                0.12.9     2017-01-14 cran (@0.12.9)                               
 reshape2          * 1.4.2      2016-10-22 CRAN (R 3.3.0)                               
 RMySQL            * 0.10.9     2016-05-08 CRAN (R 3.3.0)                               
 rpivotTable       * 0.1.5.20   2016-06-05 CRAN (R 3.3.0)                               
 rvg                 0.1.2      2017-01-03 CRAN (R 3.3.2)                               
 scales              0.4.1      2016-11-09 CRAN (R 3.3.2)                               
 shiny             * 0.14.2     2016-11-01 cran (@0.14.2)                               
 squr              * 0.0.2      2016-12-14 Github (smbache/squr@e82075d)                
 stringi             1.1.2      2016-10-01 cran (@1.1.2)                                
 stringr           * 1.1.0      2016-08-19 cran (@1.1.0)                                
 tibble              1.2        2016-08-26 cran (@1.2)                                  
 tidyr               0.6.0      2016-08-12 CRAN (R 3.3.0)                               
 viridisLite         0.1.3      2016-03-12 CRAN (R 3.3.0)                               
 withr               1.0.2      2016-06-20 CRAN (R 3.3.0)                               
 XML                 3.98-1.5   2016-11-10 cran (@3.98-1.)                              
 xml2                1.1.0      2017-01-07 cran (@1.1.0)                                
 xtable              1.8-2      2016-02-05 CRAN (R 3.3.0)                               
 yaml                2.1.14     2016-11-12 cran (@2.1.14)  

The error message I get in RStudio Viewer:

Fontconfig error: unable to match font pattern

Error in console log

Listening on http://127.0.0.1:5743
Warning: Error in eval: Fontconfig error: unable to match font pattern
Stack trace (innermost first):
    89: <Anonymous>
    88: stop
    87: match_family_
    86: FUN
    85: lapply
    84: validate_fonts
    83: dsvg
    82: ggiraph
    81: func [/Library/Frameworks/R.framework/Versions/3.3/Resources/library/ggiraph/shiny/cars/server.R#16]
    80: origRenderFunc
    79: output$plot
     4: <Anonymous>
     3: do.call
     2: print.shiny.appobj
     1: <Promise>

What should I do in this case? It seems I need to install a missing font but I don't know which font.

davidgohel commented 7 years ago

You can see what are available fonts by running the following command:

gdtools::sys_fonts()

The column family contains family names.

Then in the ggiraph call, add the parameter fonts as below (see rvg::dsvg for more details):

ggiraph(..., fonts = list(sans = "a_sansserif_font", serif = "a_serif_font", mono = "mono_font", symbol = "symbol_font"))

The following vignette is explaining things better than I do: https://CRAN.R-project.org/package=svglite/vignettes/fonts.html (dsvg do not handle user font aliases for now).

David

ThoDuyNguyen commented 7 years ago
> gdtools::sys_fonts()
Fontconfig error: Cannot load default config file
[1] foundry family  file    slant   weight 
<0 rows> (or 0-length row.names)

After googling for a while, this could be caused by the OS not on R side. I haven't found the solution yet but closed the case.

Thank for your help.

davidgohel commented 7 years ago

OK

That thread may help: https://groups.google.com/forum/#!topic/reporters-package/9WP5uqP2hr8

In short: "I had to update HomeBrew and install the cairo package manually"

++ David