GithubHelp home page GithubHelp logo

r-lib / systemfonts Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 16.0 5.13 MB

System Native Font Handling in R

Home Page: https://systemfonts.r-lib.org

License: Other

R 23.09% C++ 66.16% Objective-C++ 4.87% Shell 0.02% C 5.86%
fonts rstats

systemfonts's People

Contributors

batpigandme avatar georgestagg avatar hadley avatar jan-glx avatar jeroen avatar jimhester avatar kevinushey avatar mine-cetinkaya-rundel avatar pekkarr avatar thomasp85 avatar yutannihilation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemfonts's Issues

Trouble with .otf fonts

Hello.

I'm not sure if this is the right place for this issue. Apologies if not. Perhaps it's a ggplot2 issue (but in any case, I guess this will bring it to the attention of @thomasp85!)

I am trying to follow the example here with a variety of fonts on my computer. It's working fine for the .ttf fonts (both system and user), but I get the error below with .otf fonts. (Museo is available for free here).

I'm new to trying to do interesting things with fonts, so perhaps I'm missing something obvious? Or is this a bug?

Thanks!

library(tidyverse)
library(systemfonts)
match_font("Museo")
#> $path
#> [1] "/Users/ellakaye/Library/Fonts/exljbris - Museo-500.otf"
#> 
#> $index
#> [1] 0

system_fonts() %>%
  filter(str_detect(path, "Museo"))
#> # A tibble: 2 x 9
#>   path                   index name   family style weight width italic monospace
#>   <chr>                  <int> <chr>  <chr>  <chr> <ord>  <ord> <lgl>  <lgl>    
#> 1 /Users/ellakaye/Libra…     0 Museo… Museo  500   normal norm… FALSE  FALSE    
#> 2 /Users/ellakaye/Libra…     0 Museo… Museo  300   light  norm… FALSE  FALSE

ggplot(diamonds) + 
  geom_bar(aes(color, fill = color)) + 
  ggtitle("A fancy font") + 
  theme(text = element_text(family = "Museo", size = 12))
#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"

#> Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): no font could
#> be found for family "Museo"
#> Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : no
#> font could be found for family "Museo"
#> Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found

Created on 2020-07-29 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       macOS Catalina 10.15.6      
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_GB.UTF-8                 
#>  ctype    en_GB.UTF-8                 
#>  tz       Europe/London               
#>  date     2020-07-29                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date       lib source           
#>  assertthat    0.2.1   2019-03-21 [2] CRAN (R 4.0.0)   
#>  backports     1.1.8   2020-06-17 [2] CRAN (R 4.0.0)   
#>  blob          1.2.1   2020-01-20 [2] CRAN (R 4.0.0)   
#>  broom         0.7.0   2020-07-09 [2] CRAN (R 4.0.2)   
#>  callr         3.4.3   2020-03-28 [2] CRAN (R 4.0.0)   
#>  cellranger    1.1.0   2016-07-27 [2] CRAN (R 4.0.0)   
#>  cli           2.0.2   2020-02-28 [2] CRAN (R 4.0.0)   
#>  colorspace    1.4-2   2020-02-27 [2] R-Forge (R 4.0.0)
#>  crayon        1.3.4   2017-09-16 [2] CRAN (R 4.0.0)   
#>  curl          4.3     2019-12-02 [2] CRAN (R 4.0.0)   
#>  DBI           1.1.0   2019-12-15 [2] CRAN (R 4.0.0)   
#>  dbplyr        1.4.4   2020-05-27 [2] CRAN (R 4.0.0)   
#>  desc          1.2.0   2018-05-01 [2] CRAN (R 4.0.0)   
#>  devtools      2.3.0   2020-04-10 [2] CRAN (R 4.0.0)   
#>  digest        0.6.25  2020-02-23 [2] CRAN (R 4.0.0)   
#>  dplyr       * 1.0.0   2020-05-29 [1] CRAN (R 4.0.0)   
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 4.0.0)   
#>  evaluate      0.14    2019-05-28 [2] CRAN (R 4.0.0)   
#>  fansi         0.4.1   2020-01-08 [2] CRAN (R 4.0.0)   
#>  farver        2.0.3   2020-01-16 [2] CRAN (R 4.0.0)   
#>  forcats     * 0.5.0   2020-03-01 [2] CRAN (R 4.0.0)   
#>  fs            1.4.2   2020-06-30 [2] CRAN (R 4.0.0)   
#>  generics      0.0.2   2018-11-29 [2] CRAN (R 4.0.0)   
#>  ggplot2     * 3.3.2   2020-06-19 [2] CRAN (R 4.0.0)   
#>  glue          1.4.1   2020-05-13 [1] CRAN (R 4.0.0)   
#>  gtable        0.3.0   2019-03-25 [2] CRAN (R 4.0.0)   
#>  haven         2.3.1   2020-06-01 [2] CRAN (R 4.0.0)   
#>  highr         0.8     2019-03-20 [2] CRAN (R 4.0.0)   
#>  hms           0.5.3   2020-01-08 [2] CRAN (R 4.0.0)   
#>  htmltools     0.5.0   2020-06-16 [2] CRAN (R 4.0.0)   
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.0.2)   
#>  jsonlite      1.7.0   2020-06-25 [2] CRAN (R 4.0.0)   
#>  knitr         1.29    2020-06-23 [2] CRAN (R 4.0.0)   
#>  labeling      0.3     2014-08-23 [2] CRAN (R 4.0.0)   
#>  lifecycle     0.2.0   2020-03-06 [2] CRAN (R 4.0.0)   
#>  lubridate     1.7.9   2020-06-08 [2] CRAN (R 4.0.0)   
#>  magrittr      1.5     2014-11-22 [2] CRAN (R 4.0.0)   
#>  memoise       1.1.0   2017-04-21 [2] CRAN (R 4.0.0)   
#>  mime          0.9     2020-02-04 [2] CRAN (R 4.0.0)   
#>  modelr        0.1.8   2020-05-19 [2] CRAN (R 4.0.0)   
#>  munsell       0.5.0   2018-06-12 [2] CRAN (R 4.0.0)   
#>  pillar        1.4.6   2020-07-10 [1] CRAN (R 4.0.2)   
#>  pkgbuild      1.1.0   2020-07-13 [1] CRAN (R 4.0.2)   
#>  pkgconfig     2.0.3   2019-09-22 [2] CRAN (R 4.0.0)   
#>  pkgload       1.1.0   2020-05-29 [2] CRAN (R 4.0.0)   
#>  prettyunits   1.1.1   2020-01-24 [2] CRAN (R 4.0.0)   
#>  processx      3.4.3   2020-07-05 [2] CRAN (R 4.0.0)   
#>  ps            1.3.3   2020-05-08 [2] CRAN (R 4.0.0)   
#>  purrr       * 0.3.4   2020-04-17 [2] CRAN (R 4.0.0)   
#>  R6            2.4.1   2019-11-12 [2] CRAN (R 4.0.0)   
#>  Rcpp          1.0.5   2020-07-06 [2] CRAN (R 4.0.0)   
#>  readr       * 1.3.1   2018-12-21 [2] CRAN (R 4.0.0)   
#>  readxl        1.3.1   2019-03-13 [2] CRAN (R 4.0.0)   
#>  remotes       2.1.1   2020-02-15 [2] CRAN (R 4.0.0)   
#>  reprex        0.3.0   2019-05-16 [2] CRAN (R 4.0.0)   
#>  rlang         0.4.7   2020-07-09 [1] CRAN (R 4.0.2)   
#>  rmarkdown     2.3     2020-06-18 [2] CRAN (R 4.0.0)   
#>  rprojroot     1.3-2   2018-01-03 [2] CRAN (R 4.0.0)   
#>  rvest         0.3.5   2019-11-08 [2] CRAN (R 4.0.0)   
#>  scales        1.1.1   2020-05-11 [2] CRAN (R 4.0.0)   
#>  sessioninfo   1.1.1   2018-11-05 [2] CRAN (R 4.0.0)   
#>  stringi       1.4.6   2020-02-17 [2] CRAN (R 4.0.0)   
#>  stringr     * 1.4.0   2019-02-10 [2] CRAN (R 4.0.0)   
#>  systemfonts * 0.2.3   2020-06-09 [1] CRAN (R 4.0.2)   
#>  testthat      2.3.2   2020-03-02 [2] CRAN (R 4.0.0)   
#>  tibble      * 3.0.3   2020-07-10 [1] CRAN (R 4.0.2)   
#>  tidyr       * 1.1.0   2020-05-20 [2] CRAN (R 4.0.0)   
#>  tidyselect    1.1.0   2020-05-11 [1] CRAN (R 4.0.0)   
#>  tidyverse   * 1.3.0   2019-11-21 [2] CRAN (R 4.0.0)   
#>  usethis       1.6.1   2020-04-29 [2] CRAN (R 4.0.0)   
#>  utf8          1.1.4   2018-05-24 [2] CRAN (R 4.0.0)   
#>  vctrs         0.3.2   2020-07-15 [1] CRAN (R 4.0.2)   
#>  viridisLite   0.3.0   2018-02-01 [2] CRAN (R 4.0.0)   
#>  withr         2.2.0   2020-04-20 [2] CRAN (R 4.0.0)   
#>  xfun          0.16    2020-07-24 [1] CRAN (R 4.0.2)   
#>  xml2          1.3.2   2020-04-23 [2] CRAN (R 4.0.0)   
#>  yaml          2.2.1   2020-02-01 [2] CRAN (R 4.0.0)   
#> 
#> [1] /Users/ellakaye/Library/R/4.0/library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

fails to install with old version of cpp11

needs version >= 0.2.1 of cpp11 I believe

cpp11.cpp:106:356: error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘SEXP’ {aka ‘SEXPREC*’} to binary ‘operator>’
     return cpp11::as_sexp(get_line_width_c(cpp11::as_cpp<cpp11::decay_t<cpp11::strings>>(string), cpp11::as_cpp<cpp11::decay_t<cpp11::strings>>(path), cpp11::as_cpp<cpp11::decay_t<cpp11::integers>>(index), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(size), cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(res), cpp11::as_cpp<cpp11::decay_t<cpp11::logicals>>(include_bearing)));
                                                                                                                                                                                                                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
make: *** [/usr/lib64/R/etc/Makeconf:177: cpp11.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package ‘systemfonts’
> install.packages("cpp11")
Installing package into ‘***/R/x86_64-suse-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.ma.imperial.ac.uk/src/contrib/cpp11_0.2.1.tar.gz'

then

* DONE (systemfonts)

The downloaded source packages are in
	‘/tmp/RtmpPEopPn/downloaded_packages’

Release systemfonts 0.1.1

Prepare for release:

  • devtools::check()
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Polish NEWS
  • Polish pkgdown reference index

Submit to CRAN:

  • usethis::use_version('patch')
  • Update cran-comments.md
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Tweet

APPCRASH in systemfonts.dll

Hello,

This code make Rgui/Rsript i386 or x64 crash (but not RStudio).
Do-you have any idea?

Windows R 3.6.2 with latest updates.
Here's code to reproduce:

library(flextable)

df <- data.frame(Date=c('2010-01-01','2011-01-01','2012-01-01'), V=c(9,9,10))

ft <- flextable(df)

z <- data.frame(col_keys = colnames(df) ,labels = gsub("[.]1","",gsub("X","",colnames(df))),stringsAsFactors = FALSE)

ft <- set_header_df(ft, mapping = z )

Here the error:

Log Name:      Application
Source:        Application Error
Date:          12-Feb-20 11:51:36 AM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      ECO-RDS-1.main.oecd.org
Description:
Faulting application name: Rscript.exe, version: 3.62.12024.0, time stamp: 0x5df1fdf7
Faulting module name: systemfonts.dll, version: 0.0.0.0, time stamp: 0x5dd52fa8
Exception code: 0xc0000005
Fault offset: 0x0000000000001597
Faulting process id: 0xedc
Faulting application start time: 0x01d5e192606fac0d
Faulting application path: \\main.oecd.org\em_apps\r-eco\bin\x64\Rscript.exe
Faulting module path: **\\main.oecd.org\em_apps\R-ECO\library\systemfonts\libs\x64\systemfonts.dll**
Report Id: a31a2021-4d85-11ea-80e0-001dd8b71c10
Faulting package full name: 
Faulting package-relative application ID: 
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2020-02-12T10:51:36.000000000Z" />
    <EventRecordID>200843</EventRecordID>
    <Channel>Application</Channel>
    <Computer>ECO-RDS-1.main.oecd.org</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Rscript.exe</Data>
    <Data>3.62.12024.0</Data>
    <Data>5df1fdf7</Data>
    <Data>systemfonts.dll</Data>
    <Data>0.0.0.0</Data>
    <Data>5dd52fa8</Data>
    <Data>c0000005</Data>
    <Data>0000000000001597</Data>
    <Data>edc</Data>
    <Data>01d5e192606fac0d</Data>
    <Data>\\main.oecd.org\em_apps\r-eco\bin\x64\Rscript.exe</Data>
    <Data>\\main.oecd.org\em_apps\R-ECO\library\systemfonts\libs\x64\systemfonts.dll</Data>
    <Data>a31a2021-4d85-11ea-80e0-001dd8b71c10</Data>
    <Data>
    </Data>
    <Data>
    </Data>
  </EventData>
</Event>

Package or namespace load fail for "systemfonts"

install.packages("systemfonts") seems to work fine, but then when I try library(systemfonts):

Error: package or namespace load failed for ‘systemfonts’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so
Reason: image not found

Fonts in user library not detected in MacOS build on Github Actions

The problem: on a MacOS build on Github Actions, {systemfonts} does not see fonts installed in user library, reports matching IBM Plex Sans to Helvetica but some other font shows up in the ggplot2 PNG ragg output.

This may well be a limitation of Github Actions (or me doing something wrong in the workflow spec), but logging here in case (a) it can be remedied in {systemfonts} or (b) you have any intuitions as to whether/how it can be handled on the GHA side.

HTML output at https://petrbouchal.xyz/pagetest/ (ignore text...)
Worflow file at https://github.com/petrbouchal/pagetest/blob/master/.github/workflows/website.yml
Workflow output at https://github.com/petrbouchal/pagetest/runs/1400625372?check_suite_focus=true
Rmd code at https://github.com/petrbouchal/pagetest/blob/master/index.Rmd

What I try to do:

  • install a font (IBM Plex Sans via homebrew) on a MacOS run of GHA
  • build a site using rmarkdown::render_site(), containing {ggplot2} graphics using the font
  • rendering via dev = "ragg_png".

What I expect:

  • fonts to be available in user Library
  • {systemfonts}/{ragg} to pick them up
  • correct font or correct fallback font to show up in plot

What I see:

  • homebrew reports installing the fonts into /Users/runner/Library/Fonts;
  • systemfonts::system_fonts() contains only entries with paths starting in /System/Library/Fonts
  • systemfonts::match_font("IBM Plex Sans") returns Helvetica.
  • plot contains odd font, not Helvetica

Feeding the font in manually via systemfonts::register_font() works but that is a bit of a convoluted and long-winded solution - but it confirms that the user font library exists and is accessible to R.

Font caching

currently font caching has to be implemented by the client but it would be nice to have that in systemfonts instead, as it would give a central place to clear cache etc

Dev version fails to install from source on mac (no such file or directory: '@objcflags@')

I believe this was introduced by a recent commit ad6a3a8

> remotes::install_github("r-lib/systemfonts")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo r-lib/systemfonts@master
   checking for file/private/var/folders/t8/jxw4bftj35g15fcb6m4mfbc80000gn/T/RtmpZUPl4c/remotes1620a8352checking for file/private/var/folders/t8/jxw4bftj35g15fcb6m4mfbc80000gn/T/RtmpZUPl4c/remotes1620a8352c3c/r-lib-systemfonts-9f19d7e/DESCRIPTION’
─  preparingsystemfonts:checking DESCRIPTION meta-information ...cleaning srcrunningcleanup’
─  checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directorieslooking to see if adata/datalistfile should be addedbuildingsystemfonts_0.1.1.9000.tar.gz* installing *source* packagesystemfonts...
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/local/opt/freetype/include/freetype2
Using PKG_LIBS=-L/usr/local/opt/freetype/lib -lfreetype
sed: s|@objcflags@|-fobjc-arc|: No such file or directory
** libs
rm -f systemfonts.so systemfonts.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o init.o mac/FontManagerMac.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c systemfonts.cpp -o systemfonts.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c ft_cache.cpp -o ft_cache.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c string_shape.cpp -o string_shape.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c font_metrics.cpp -o font_metrics.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c string_metrics.cpp -o string_metrics.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c emoji.cpp -o emoji.o
/usr/local/clang4/bin/clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c init.cpp -o init.o
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -DSTRICT_R_HEADERS  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include @objcflags@ -fPIC   -c mac/FontManagerMac.mm -o mac/FontManagerMac.o
clang: error: no such file or directory: '@objcflags@'
make: *** [mac/FontManagerMac.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for packagesystemfonts* removing/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts* restoring previous/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfontsError: Failed to install 'systemfonts' from GitHub:
  (converted from warning) installation of package/var/folders/t8/jxw4bftj35g15fcb6m4mfbc80000gn/T//RtmpZUPl4c/file1620a197aca17/systemfonts_0.1.1.9000.tar.gzhad non-zero exit status
> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.3 (2020-02-29)
 os       macOS Mojave 10.14.6        
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       America/Chicago             
 date     2020-04-03Packages ───────────────────────────────────────────────────────────────────
 package     * version     date       lib source                            
 assertthat    0.2.1       2019-03-21 [1] CRAN (R 3.6.0)                    
 backports     1.1.5       2019-10-02 [1] CRAN (R 3.6.0)                    
 bit           1.1-15.2    2020-02-10 [1] CRAN (R 3.6.2)                    
 bit64         0.9-7       2017-05-08 [1] CRAN (R 3.6.0)                    
 blob          1.2.1       2020-01-20 [1] CRAN (R 3.6.2)                    
 callr         3.4.3       2020-03-28 [1] CRAN (R 3.6.2)                    
 cli           2.0.2       2020-02-28 [1] CRAN (R 3.6.0)                    
 colorout      1.2-2       2019-09-16 [1] Github (jalvesaq/colorout@641ed38)
 crancache     0.0.0.9001  2019-09-16 [1] Github (r-lib/crancache@936fa23)  
 cranlike      1.0.2       2018-11-26 [1] CRAN (R 3.6.0)                    
 crayon        1.3.4       2017-09-16 [1] CRAN (R 3.6.0)                    
 curl          4.3         2019-12-02 [1] CRAN (R 3.6.1)                    
 DBI           1.1.0       2019-12-15 [1] CRAN (R 3.6.1)                    
 debugme       1.1.0       2017-10-22 [1] CRAN (R 3.6.0)                    
 desc          1.2.0       2018-05-01 [1] CRAN (R 3.6.0)                    
 devtools    * 2.2.2.9000  2020-04-01 [1] Github (r-lib/devtools@f77c14e)   
 digest        0.6.25      2020-02-23 [1] CRAN (R 3.6.2)                    
 ellipsis      0.3.0       2019-09-20 [1] CRAN (R 3.6.1)                    
 fansi         0.4.1       2020-01-08 [1] CRAN (R 3.6.2)                    
 fortunes      1.5-4       2016-12-29 [1] CRAN (R 3.6.0)                    
 fs            1.4.0       2020-03-31 [1] CRAN (R 3.6.2)                    
 glue          1.3.2       2020-03-12 [1] CRAN (R 3.6.0)                    
 htmltools     0.4.0.9003  2020-03-26 [1] local                             
 htmlwidgets   1.5.1       2019-10-08 [1] CRAN (R 3.6.0)                    
 lifecycle     0.2.0       2020-03-06 [1] CRAN (R 3.6.0)                    
 magrittr      1.5         2014-11-22 [1] CRAN (R 3.6.0)                    
 memoise       1.1.0       2017-04-21 [1] CRAN (R 3.6.0)                    
 parsedate     1.2.0       2019-05-08 [1] CRAN (R 3.6.0)                    
 pillar        1.4.3.9001  2020-03-27 [1] Github (r-lib/pillar@52b4503)     
 pkgbuild      1.0.6       2019-10-09 [1] CRAN (R 3.6.1)                    
 pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 3.6.1)                    
 pkgload       1.0.2       2018-10-29 [1] CRAN (R 3.6.0)                    
 prettyunits   1.1.1       2020-01-24 [1] CRAN (R 3.6.0)                    
 processx      3.4.2       2020-02-09 [1] CRAN (R 3.6.2)                    
 ps            1.3.2       2020-02-13 [1] CRAN (R 3.6.0)                    
 R6            2.4.1       2019-11-12 [1] CRAN (R 3.6.0)                    
 rappdirs      0.3.1       2016-03-28 [1] CRAN (R 3.6.0)                    
 Rcpp          1.0.4.6     2020-04-02 [1] Github (RcppCore/Rcpp@2da7d9c)    
 rematch2      2.1.1       2020-03-28 [1] CRAN (R 3.6.2)                    
 remotes       2.1.1       2020-02-15 [1] CRAN (R 3.6.0)                    
 rlang         0.4.5       2020-03-01 [1] CRAN (R 3.6.0)                    
 rprojroot     1.3-2       2018-01-03 [1] CRAN (R 3.6.0)                    
 RSQLite       2.2.0       2020-01-07 [1] CRAN (R 3.6.2)                    
 sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 3.6.0)                    
 testthat      2.3.2       2020-03-02 [1] CRAN (R 3.6.2)                    
 tibble        3.0.0       2020-03-30 [1] CRAN (R 3.6.2)                    
 usethis     * 1.5.1.9000  2020-03-27 [1] Github (r-lib/usethis@a2c118f)    
 vctrs         0.2.99.9010 2020-03-31 [1] Github (r-lib/vctrs@fd24927)      
 withr         2.1.2       2018-03-15 [1] CRAN (R 3.6.0)                    

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

BUG when installing the library

Hi,

I am trying to install the library in a linux machine and I am getting this error

> install.packages("systemfonts")
Installing package into ‘/****/library/3.6.2’
(as ‘lib’ is unspecified)
trying URL '*****/src/contrib/systemfonts_1.0.1.tar.gz'
Content type 'application/x-gzip' length 80368 bytes (78 KB)
==================================================
downloaded 78 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/freetype2  
Using PKG_LIBS=-lfontconfig -lfreetype  
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c caches.cpp -o caches.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c cpp11.cpp -o cpp11.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c dev_metrics.cpp -o dev_metrics.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c font_matching.cpp -o font_matching.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c font_registry.cpp -o font_registry.o
g++ -std=gnu++11 -I"/opt/R/3.6.2/lib/R/include" -DNDEBUG -I/usr/include/freetype2   -I"/ingesta/library/3.6.2/cpp11/include" -I/usr/local/include  -fpic  -g -O2  -c ft_cache.cpp -o ft_cache.o
ft_cache.cpp: In member function ‘int FreetypeCache::get_weight()’:
ft_cache.cpp:335:41: error: ‘FT_SFNT_OS2’ was not declared in this scope
  335 |   void* table = FT_Get_Sfnt_Table(face, FT_SFNT_OS2);
      |                                         ^~~~~~~~~~~
ft_cache.cpp: In member function ‘int FreetypeCache::get_width()’:
ft_cache.cpp:344:41: error: ‘FT_SFNT_OS2’ was not declared in this scope
  344 |   void* table = FT_Get_Sfnt_Table(face, FT_SFNT_OS2);
      |                                         ^~~~~~~~~~~
make: *** [ft_cache.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/****/library/3.6.2/systemfonts’
Warning in install.packages :
  installation of package ‘systemfonts’ had non-zero exit status

The downloaded source packages are in
	‘/*****/Rtmp4cxHxM/downloaded_packages’

I was looking why is this happening, and I discovered the bug. In the following lines FT_SFNT_OS2 must not be in capital letters according https://www.freetype.org/freetype2/docs/reference/ft2-truetype_tables.html

#define ft_sfnt_os2   FT_SFNT_OS2

void* table = FT_Get_Sfnt_Table(face, FT_SFNT_OS2);

void* table = FT_Get_Sfnt_Table(face, FT_SFNT_OS2);

Release systemfonts 0.3.2

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

match_font crashes R

In running match_font('sans', italic = TRUE), R crashes. It just abruptly closes, and if I run in RStudio, it aborts the session by saying R encountered a fatal error. I am on windows 10 and am running R 3.6.1.

Edit: In fact, it crashes on every single function used in systemfonts.

XQuartz Details

Hello! I am hoping to add functionality in one of my packages in the next release that would make systemfonts a dependency.

During some testing it seems that XQuartz needs to be installed by the user separately on Catalina, and that perhaps this is not the case for R >=4.0? Is there some place that documents the installation process for systemfonts (e.g. when it should install smoothly and when it needs users to install additional software)? I am nervous that if I add the dependency, I may introduce installation issues for mac users, and as a non-mac user, I get confused easily!

Thank you!

Build error on Linux (Ubuntu 20.04): "ft2build.h: No such file or directory"

I tried search first in previous issues to see if others had run into this and found similar issues posted for #48 (Windows) #21 (macos Catalina), but wanted to add that I also encountered the issue on Linux.

For me, the fix was to install libfontconfig1-dev

sudo apt-get install libfontconfig1-dev

Hoping that if others run into the issue that they can find the solution here.

Can't compile on Linux

I tried to install the package using devtools and it seems there's a problem with the definition of
strlen and strcpy on the <cstring> header.

Below the log of the installation:

devtools::install_git("https://github.com/thomasp85/systemfonts")
Downloading git repo https://github.com/thomasp85/systemfontschecking for file/tmp/Rtmp4AjfOF/file297678710ad6/DESCRIPTION’ (380ms)
─  preparingsystemfonts:checking DESCRIPTION meta-information ...cleaning srcchecking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildingsystemfonts_0.0.1.tar.gzInstalling package into/home/aldomann/.R/x86_64-pc-linux-gnu-library/3.6’
(aslibis unspecified)
* installing *source* packagesystemfonts...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG   -D_FORTIFY_SOURCE=2  -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt  -c FontManagerLinux.cpp -o FontManagerLinux.o
In file included from FontManagerLinux.cpp:2:
FontDescriptor.h: In member functionchar* FontDescriptor::copyString(const char*)’:
FontDescriptor.h:100:26: error:strlenwas not declared in this scope
     char *str = new char[strlen(input) + 1];
                          ^~~~~~
FontDescriptor.h:100:26: note:strlenis defined in header<cstring>’; did you forget to#include <cstring>’?
FontDescriptor.h:5:1:
+#include <cstring>
 
FontDescriptor.h:100:26:
     char *str = new char[strlen(input) + 1];
                          ^~~~~~
FontDescriptor.h:101:5: error:strcpywas not declared in this scope
     strcpy(str, input);
     ^~~~~~
FontDescriptor.h:101:5: note:strcpyis defined in header<cstring>’; did you forget to#include <cstring>’?
FontManagerLinux.cpp: In functionFontDescriptor* substituteFont(char*, char*)’:
FontManagerLinux.cpp:223:13: error:strlenwas not declared in this scope
   int len = strlen(string);
             ^~~~~~
FontManagerLinux.cpp:223:13: note:strlenis defined in header<cstring>’; did you forget to#include <cstring>’?
FontManagerLinux.cpp:3:1:
+#include <cstring>
 
FontManagerLinux.cpp:223:13:
   int len = strlen(string);
             ^~~~~~
make: *** [/usr/lib64/R/etc/Makeconf:176: FontManagerLinux.o] Error 1
ERROR: compilation failed for packagesystemfonts* removing/home/aldomann/.R/x86_64-pc-linux-gnu-library/3.6/systemfontsError in i.p(...) : 
  (converted from warning) installation of package/tmp/Rtmp4AjfOF/file297631e1772b/systemfonts_0.0.1.tar.gzhad non-zero exit status

deployment error with shinyapps involving systemfonts build

Tried multiple times with no success. Any idea why shinyapps won't build systemfonts ? Thanks.

make: *** Waiting for unfinished jobs....
make: Leaving directory '/tmp/RtmpAWuAjg/R.INSTALL38044a33430/systemfonts/src'
make: Entering directory '/tmp/RtmpAWuAjg/R.INSTALL38044a33430/systemfonts/src'
make: Leaving directory '/tmp/RtmpAWuAjg/R.INSTALL38044a33430/systemfonts/src'
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/opt/R/4.0.2/lib/R/library/systemfonts’
GET /v1/tasks/?filter=account_id:397877&filter=parent_id:815332825&count=100&offset=0 599ms
################################# End Task Log ################################# 
----- Deployment error -----
Error: Unhandled Exception: Child Task 815332825 failed: Error building image: Error building systemfonts (0.3.0). Build exited with non-zero status: 1
 
----- Error stack trace -----
Error: Unhandled Exception: Child Task 815332825 failed: Error building image: Error building systemfonts (0.3.0). Build exited with non-zero status: 1
Error during wrapup: length(max.lines) <= 1 is not TRUE
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
Execution halted

R version

$version.string
[1] "R version 4.0.2 (2020-06-22)"

Release systemfonts 0.2.0

Prepare for release:

  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Correct way of retrieving the width of a space

Prompted by: rstudio/rstudio#7010

I'm trying to retrieve the correct width of a space (" "), and I'm getting inconsistent results. In the past, I have simply made a textgrob and calculated the grob width, but that apparently fails for any of the agg graphics devices. Now I'm trying to use systemfonts, but I'm getting slightly different metrics. Which is correct? Should I just trust the systemfonts result and ignore that different graphics devices report different numbers?

library(grid)

fontsize <- 12
fontfamily <- "Helvetica"
fontface <- "plain"

# function that calculates the width of a space in pt by calling textGrob()
f <- function() {
  convertWidth(grobWidth(textGrob(
    label = " ",
    gp = gpar(
      fontsize = fontsize,
      fontfamily = fontfamily,
      fontface = fontface,
      cex = 1
    )
  )), "pt", valueOnly = TRUE)
}

# pdf() and png() report slightly different values, but they're close (~3.35)
pdf()
f()
#> [1] 3.34851
dev.off()
#> quartz_off_screen 
#>                 2

png()
f()
#> [1] 3.346487
dev.off()
#> quartz_off_screen 
#>                 2

# agg_png() reports 2.0075
ragg::agg_png()
f()
#> [1] 2.0075
dev.off()
#> quartz_off_screen 
#>                 2


library(systemfonts)
#> Warning: package 'systemfonts' was built under R version 3.6.2

fontsize <- 12
fontfamily <- "Helvetica"

g <- glyph_info(
  " ",
  family = fontfamily,
  size = fontsize
)

# systemfonts reports a zero width (fine, if we know that's the case)
g$width
#> [1] 0

# systemfonts reports an advance of 3, inconsistent with all previous results
g$x_advance
#> [1] 3

# grid pt unit is 72.27 / inch, not 72 / inch, but that doesn't fix the problem
g$x_advance * 72.27 / 72
#> [1] 3.01125

Created on 2020-05-30 by the reprex package (v0.3.0)

Enable adding a custom directory to the system font search path(s)?

From what I gather, with something like this — https://github.com/hrbrmstr/hrbragg/tree/master/inst/fonts/inter

fs::dir_tree(system.file("fonts/inter", package = "hrbragg"))
## /Library/Frameworks/R.framework/Versions/4.0/Resources/library/hrbragg/fonts/inter
## ├── Inter-Black.otf
## ├── Inter-BlackItalic.otf
## ├── Inter-Bold.otf
## ├── Inter-BoldItalic.otf
## ├── Inter-ExtraBold.otf
## ├── Inter-ExtraBoldItalic.otf
## ├── Inter-ExtraLight.otf
## ├── Inter-ExtraLightItalic.otf
## ├── Inter-Italic.otf
## ├── Inter-Light.otf
## ├── Inter-LightItalic.otf
## ├── Inter-Medium.otf
## ├── Inter-MediumItalic.otf
## ├── Inter-Regular.otf
## ├── Inter-SemiBold.otf
## ├── Inter-SemiBoldItalic.otf
## ├── Inter-Thin.otf
## └── Inter-ThinItalic.otf

in a package, to get the equivalent of this:

# A tibble: 18 x 9
   path                                        index name               family style           weight   width italic monospace
   <chr>                                       <int> <chr>              <chr>  <chr>           <ord>    <ord> <lgl>  <lgl>    
 1 /Users/hrbrmstr/Library/Fonts/Inter-ExtraL…     0 Inter-ExtraLight   Inter  Extra Light     light    norm… FALSE  FALSE    
 2 /Users/hrbrmstr/Library/Fonts/Inter-Bold.o…     0 Inter-Bold         Inter  Bold            bold     norm… FALSE  FALSE    
 3 /Users/hrbrmstr/Library/Fonts/Inter-Italic…     0 Inter-Italic       Inter  Italic          normal   norm… TRUE   FALSE    
 4 /Users/hrbrmstr/Library/Fonts/Inter-ExtraB…     0 Inter-ExtraBold    Inter  Extra Bold      ultrabo… norm… FALSE  FALSE    
 5 /Users/hrbrmstr/Library/Fonts/Inter-Regula…     0 Inter-Regular      Inter  Regular         normal   norm… FALSE  FALSE    
 6 /Users/hrbrmstr/Library/Fonts/Inter-Medium…     0 Inter-MediumItalic Inter  Medium Italic   medium   norm… TRUE   FALSE    
 7 /Users/hrbrmstr/Library/Fonts/Inter-ExtraL…     0 Inter-ExtraLightI… Inter  Extra Light It… light    norm… TRUE   FALSE    
 8 /Users/hrbrmstr/Library/Fonts/Inter-ExtraB…     0 Inter-ExtraBoldIt… Inter  Extra Bold Ita… ultrabo… norm… TRUE   FALSE    
 9 /Users/hrbrmstr/Library/Fonts/Inter-Black.…     0 Inter-Black        Inter  Black           heavy    norm… FALSE  FALSE    
10 /Users/hrbrmstr/Library/Fonts/Inter-SemiBo…     0 Inter-SemiBoldIta… Inter  Semi Bold Ital… semibold norm… TRUE   FALSE    
11 /Users/hrbrmstr/Library/Fonts/Inter-LightI…     0 Inter-LightItalic  Inter  Light Italic    normal   norm… TRUE   FALSE    
12 /Users/hrbrmstr/Library/Fonts/Inter-Light.…     0 Inter-Light        Inter  Light           normal   norm… FALSE  FALSE    
13 /Users/hrbrmstr/Library/Fonts/Inter-Thin.o…     0 Inter-Thin         Inter  Thin            ultrali… norm… FALSE  FALSE    
14 /Users/hrbrmstr/Library/Fonts/Inter-ThinIt…     0 Inter-ThinItalic   Inter  Thin Italic     ultrali… norm… TRUE   FALSE    
15 /Users/hrbrmstr/Library/Fonts/Inter-SemiBo…     0 Inter-SemiBold     Inter  Semi Bold       semibold norm… FALSE  FALSE    
16 /Users/hrbrmstr/Library/Fonts/Inter-BlackI…     0 Inter-BlackItalic  Inter  Black Italic    heavy    norm… TRUE   FALSE    
17 /Users/hrbrmstr/Library/Fonts/Inter-Medium…     0 Inter-Medium       Inter  Medium          medium   norm… FALSE  FALSE    
18 /Users/hrbrmstr/Library/Fonts/Inter-BoldIt…     0 Inter-BoldItalic   Inter  Bold Italic     bold     norm… TRUE   FALSE    

in an R session registry, I'd have to deal with the individual registrations for the various weights. Is there any way with the new underlying tooling to specify another search path or have a registration function that just takes a path and registers all the fonts in that directory?

'glyph_info' idea: add a column of which font family would actually be used for glyph

  • One thing I've occasionally noticed with cairo_pdf and png graphic devices and grid.text is that sometimes it will use a glyph from a different font family rather than the one you requested even if that font family is named correctly (i.e. matched by fc-match) and contains that particular glyph. This seems to be because font-config sometimes overrides your font family decision for certain glyphs. For glyph_info it may be nice to add a column letting users know from which font family that glyph will actually be from (especially when not equal to the family argument). I sometimes use this info to remove font-config's favoured fonts from my system to force font-config (and hence grid.text with cairo graphics devices) to use the system font I want to be used.

  • A few years ago I wrote a utility function for myself that determines this by trying to embedd the actually dispatched font with cairo_pdf and then grabbing it with pdffonts but probably not the best solution since

    1. not sure if will work cross-platform since relies on font embedding behaviour of cairo_pdf and grid.text
    2. requires pdffonts utility from poppler-uitls to grab which font is actually embedded
    3. can't figure out which color emoji font is used if a color emoji font is dispatched since cairo_pdf and grid.text doesn't "embed" color emoji fonts
get_embedded_font_helper <- function(font, char) {
    file <- tempfile(fileext=".pdf")
    on.exit(unlink(file))
    grDevices::cairo_pdf(file)
    grid::grid.text(char, gp=grid::gpar(fontsize=72, fontfamily=font))
    invisible(grDevices::dev.off())

    pf_output <- system2("pdffonts", file, stdout=TRUE)
    if (length(pf_output) == 2)
        embedded_font <- NA # likely no font found or some color emoji font used
    else
        embedded_font <- gsub(".*\\+(.*)", "\\1", strsplit(pf_output[3], " +")[[1]][1])
    embedded_font
}
#' @param font A character vector of font(s) passed to the \code{fontfamily} argument of \code{grid::gpar}.
#' @param char A character vector of character(s) to be embedded by \code{grid::grid.text}
#' @return \code{get_embedded_font} returns character vector of fonts that were actually embedded by \code{cairo_pdf}.
#'         \code{NA}'s means no embedded font detected: this either means that no font
#'          was found or that a color emoji font was found and instead of a font an image was embedded.
#' @details \code{get_embedded_font} depends on \code{pdffonts} being on the system path
#'          (on many OSes found in a \code{poppler-utils} package).
#' @export
get_embedded_font <- function(font, char) {
    if (Sys.which("pdffonts") == "") {
        stop("'get_embedded_font' depends on 'pdffonts' being on the system path. ",
             " On many OSes it is found in a 'poppler-utils' package.")
    }
    df <- expand.grid(char, font, stringsAsFactors=FALSE)
    names(df) <- c("char", "requested_font")
    df$embedded_font <- NA
    for (ii in seq(nrow(df))) {
        df[ii, 3] <- get_embedded_font_helper(df[ii,2], df[ii,1])
    }
    df
}

Can't load systemfonts in R 3.6.1 in OSX Catalina

Hi seems there is a problem atleast under OSX Catalina :
The package installs without problem but when loading it with library(systemfonts) it crashes :

library(systemfonts)

Erreur : package or namespace load failed for ‘systemfonts’ in dyn.load(file, DLLpath = DLLpath, ...):
impossible de charger l'objet partagé '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/systemfonts/libs/systemfonts.so
Reason: image not found

I'm on OSX Catalina(10.15.1). Same problem on 2 different osx catalina computer.

Doesn't install at all not even through "devtools::install_github("r-lib/svglite")"

Here is the log :

trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.1.tar.gz'
Content type 'application/x-gzip' length 80368 bytes (78 KB)
==================================================
downloaded 78 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c caches.cpp -o caches.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c cpp11.cpp -o cpp11.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c dev_metrics.cpp -o dev_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_matching.cpp -o font_matching.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_registry.cpp -o font_registry.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ft_cache.cpp -o ft_cache.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c string_shape.cpp -o string_shape.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_metrics.cpp -o font_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_fallback.cpp -o font_fallback.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c string_metrics.cpp -o string_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c emoji.cpp -o emoji.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c cache_store.cpp -o cache_store.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.cpp -o init.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c unix/FontManagerLinux.cpp -o unix/FontManagerLinux.o
In file included from /usr/include/x86_64-linux-gnu/asm/types.h:1,
                 from /usr/include/linux/types.h:5,
                 from /usr/include/linux/stat.h:5,
                 from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/asm-generic/types.h:7:10: error: /usr/include/asm-generic/int-ll64.h: Input/output error
    7 | #include <asm-generic/int-ll64.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/stat.h:5,
                 from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/linux/types.h:24:9: error: ‘__u16’ does not name a type
   24 | typedef __u16 __bitwise __le16;
      |         ^~~~~
/usr/include/linux/types.h:25:9: error: ‘__u16’ does not name a type
   25 | typedef __u16 __bitwise __be16;
      |         ^~~~~
/usr/include/linux/types.h:26:9: error: ‘__u32’ does not name a type
   26 | typedef __u32 __bitwise __le32;
      |         ^~~~~
/usr/include/linux/types.h:27:9: error: ‘__u32’ does not name a type
   27 | typedef __u32 __bitwise __be32;
      |         ^~~~~
/usr/include/linux/types.h:28:9: error: ‘__u64’ does not name a type
   28 | typedef __u64 __bitwise __le64;
      |         ^~~~~
/usr/include/linux/types.h:29:9: error: ‘__u64’ does not name a type
   29 | typedef __u64 __bitwise __be64;
      |         ^~~~~
/usr/include/linux/types.h:31:9: error: ‘__u16’ does not name a type
   31 | typedef __u16 __bitwise __sum16;
      |         ^~~~~
/usr/include/linux/types.h:32:9: error: ‘__u32’ does not name a type
   32 | typedef __u32 __bitwise __wsum;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/linux/stat.h:57:2: error: ‘__s64’ does not name a type
   57 |  __s64 tv_sec;
      |  ^~~~~
/usr/include/linux/stat.h:58:2: error: ‘__u32’ does not name a type
   58 |  __u32 tv_nsec;
      |  ^~~~~
/usr/include/linux/stat.h:59:2: error: ‘__s32’ does not name a type
   59 |  __s32 __reserved;
      |  ^~~~~
/usr/include/linux/stat.h:101:2: error: ‘__u32’ does not name a type
  101 |  __u32 stx_mask; /* What results were written [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:102:2: error: ‘__u32’ does not name a type
  102 |  __u32 stx_blksize; /* Preferred general I/O size [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:103:2: error: ‘__u64’ does not name a type
  103 |  __u64 stx_attributes; /* Flags conveying information about the file [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:105:2: error: ‘__u32’ does not name a type
  105 |  __u32 stx_nlink; /* Number of hard links */
      |  ^~~~~
/usr/include/linux/stat.h:106:2: error: ‘__u32’ does not name a type
  106 |  __u32 stx_uid; /* User ID of owner */
      |  ^~~~~
/usr/include/linux/stat.h:107:2: error: ‘__u32’ does not name a type
  107 |  __u32 stx_gid; /* Group ID of owner */
      |  ^~~~~
/usr/include/linux/stat.h:108:2: error: ‘__u16’ does not name a type
  108 |  __u16 stx_mode; /* File mode */
      |  ^~~~~
/usr/include/linux/stat.h:109:2: error: ‘__u16’ does not name a type
  109 |  __u16 __spare0[1];
      |  ^~~~~
/usr/include/linux/stat.h:111:2: error: ‘__u64’ does not name a type
  111 |  __u64 stx_ino; /* Inode number */
      |  ^~~~~
/usr/include/linux/stat.h:112:2: error: ‘__u64’ does not name a type
  112 |  __u64 stx_size; /* File size */
      |  ^~~~~
/usr/include/linux/stat.h:113:2: error: ‘__u64’ does not name a type
  113 |  __u64 stx_blocks; /* Number of 512-byte blocks allocated */
      |  ^~~~~
/usr/include/linux/stat.h:114:2: error: ‘__u64’ does not name a type
  114 |  __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
      |  ^~~~~
/usr/include/linux/stat.h:121:2: error: ‘__u32’ does not name a type
  121 |  __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
      |  ^~~~~
/usr/include/linux/stat.h:122:2: error: ‘__u32’ does not name a type
  122 |  __u32 stx_rdev_minor;
      |  ^~~~~
/usr/include/linux/stat.h:123:2: error: ‘__u32’ does not name a type
  123 |  __u32 stx_dev_major; /* ID of device containing file [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:124:2: error: ‘__u32’ does not name a type
  124 |  __u32 stx_dev_minor;
      |  ^~~~~
/usr/include/linux/stat.h:126:2: error: ‘__u64’ does not name a type
  126 |  __u64 __spare2[14]; /* Spare space for future expansion */
      |  ^~~~~
make: *** [/usr/lib/R/etc/Makeconf:181: unix/FontManagerLinux.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/systemfonts’
Error: Failed to install 'svglite' from GitHub:
  (converted from warning) installation of package ‘systemfonts’ had non-zero exit status
> devtools::install_git("https://github.com/thomasp85/systemfonts")
Downloading git repo https://github.com/thomasp85/systemfonts
'/usr/bin/git' clone --depth 1 --no-hardlinks https://github.com/thomasp85/systemfonts /tmp/Rtmp314eZ9/file46ed33f0ba9
Cloning into '/tmp/Rtmp314eZ9/file46ed33f0ba9'...
✓  checking for file ‘/tmp/Rtmp314eZ9/file46ed33f0ba9/DESCRIPTION’ ...
─  preparing ‘systemfonts’:
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘systemfonts_1.0.1.9000.tar.gz’
   
Installing package into ‘/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package ‘systemfonts’ ...
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c caches.cpp -o caches.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c cpp11.cpp -o cpp11.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c dev_metrics.cpp -o dev_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_matching.cpp -o font_matching.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_registry.cpp -o font_registry.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c ft_cache.cpp -o ft_cache.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c string_shape.cpp -o string_shape.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_metrics.cpp -o font_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c font_fallback.cpp -o font_fallback.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c string_metrics.cpp -o string_metrics.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c emoji.cpp -o emoji.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c cache_store.cpp -o cache_store.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.cpp -o init.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I'/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-fhxXXR/r-base-4.0.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c unix/FontManagerLinux.cpp -o unix/FontManagerLinux.o
In file included from /usr/include/x86_64-linux-gnu/asm/types.h:1,
                 from /usr/include/linux/types.h:5,
                 from /usr/include/linux/stat.h:5,
                 from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/asm-generic/types.h:7:10: error: /usr/include/asm-generic/int-ll64.h: Input/output error
    7 | #include <asm-generic/int-ll64.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/stat.h:5,
                 from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/linux/types.h:24:9: error: ‘__u16’ does not name a type
   24 | typedef __u16 __bitwise __le16;
      |         ^~~~~
/usr/include/linux/types.h:25:9: error: ‘__u16’ does not name a type
   25 | typedef __u16 __bitwise __be16;
      |         ^~~~~
/usr/include/linux/types.h:26:9: error: ‘__u32’ does not name a type
   26 | typedef __u32 __bitwise __le32;
      |         ^~~~~
/usr/include/linux/types.h:27:9: error: ‘__u32’ does not name a type
   27 | typedef __u32 __bitwise __be32;
      |         ^~~~~
/usr/include/linux/types.h:28:9: error: ‘__u64’ does not name a type
   28 | typedef __u64 __bitwise __le64;
      |         ^~~~~
/usr/include/linux/types.h:29:9: error: ‘__u64’ does not name a type
   29 | typedef __u64 __bitwise __be64;
      |         ^~~~~
/usr/include/linux/types.h:31:9: error: ‘__u16’ does not name a type
   31 | typedef __u16 __bitwise __sum16;
      |         ^~~~~
/usr/include/linux/types.h:32:9: error: ‘__u32’ does not name a type
   32 | typedef __u32 __bitwise __wsum;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/statx.h:31,
                 from /usr/include/x86_64-linux-gnu/sys/stat.h:446,
                 from /usr/include/fontconfig/fontconfig.h:29,
                 from unix/FontManagerLinux.cpp:1:
/usr/include/linux/stat.h:57:2: error: ‘__s64’ does not name a type
   57 |  __s64 tv_sec;
      |  ^~~~~
/usr/include/linux/stat.h:58:2: error: ‘__u32’ does not name a type
   58 |  __u32 tv_nsec;
      |  ^~~~~
/usr/include/linux/stat.h:59:2: error: ‘__s32’ does not name a type
   59 |  __s32 __reserved;
      |  ^~~~~
/usr/include/linux/stat.h:101:2: error: ‘__u32’ does not name a type
  101 |  __u32 stx_mask; /* What results were written [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:102:2: error: ‘__u32’ does not name a type
  102 |  __u32 stx_blksize; /* Preferred general I/O size [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:103:2: error: ‘__u64’ does not name a type
  103 |  __u64 stx_attributes; /* Flags conveying information about the file [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:105:2: error: ‘__u32’ does not name a type
  105 |  __u32 stx_nlink; /* Number of hard links */
      |  ^~~~~
/usr/include/linux/stat.h:106:2: error: ‘__u32’ does not name a type
  106 |  __u32 stx_uid; /* User ID of owner */
      |  ^~~~~
/usr/include/linux/stat.h:107:2: error: ‘__u32’ does not name a type
  107 |  __u32 stx_gid; /* Group ID of owner */
      |  ^~~~~
/usr/include/linux/stat.h:108:2: error: ‘__u16’ does not name a type
  108 |  __u16 stx_mode; /* File mode */
      |  ^~~~~
/usr/include/linux/stat.h:109:2: error: ‘__u16’ does not name a type
  109 |  __u16 __spare0[1];
      |  ^~~~~
/usr/include/linux/stat.h:111:2: error: ‘__u64’ does not name a type
  111 |  __u64 stx_ino; /* Inode number */
      |  ^~~~~
/usr/include/linux/stat.h:112:2: error: ‘__u64’ does not name a type
  112 |  __u64 stx_size; /* File size */
      |  ^~~~~
/usr/include/linux/stat.h:113:2: error: ‘__u64’ does not name a type
  113 |  __u64 stx_blocks; /* Number of 512-byte blocks allocated */
      |  ^~~~~
/usr/include/linux/stat.h:114:2: error: ‘__u64’ does not name a type
  114 |  __u64 stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
      |  ^~~~~
/usr/include/linux/stat.h:121:2: error: ‘__u32’ does not name a type
  121 |  __u32 stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
      |  ^~~~~
/usr/include/linux/stat.h:122:2: error: ‘__u32’ does not name a type
  122 |  __u32 stx_rdev_minor;
      |  ^~~~~
/usr/include/linux/stat.h:123:2: error: ‘__u32’ does not name a type
  123 |  __u32 stx_dev_major; /* ID of device containing file [uncond] */
      |  ^~~~~
/usr/include/linux/stat.h:124:2: error: ‘__u32’ does not name a type
  124 |  __u32 stx_dev_minor;
      |  ^~~~~
/usr/include/linux/stat.h:126:2: error: ‘__u64’ does not name a type
  126 |  __u64 __spare2[14]; /* Spare space for future expansion */
      |  ^~~~~
make: *** [/usr/lib/R/etc/Makeconf:181: unix/FontManagerLinux.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/home/aanzil/R/x86_64-pc-linux-gnu-library/4.0/systemfonts’

Release systemfonts 1.0.0

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • urlchecker::url_check()
  • Update cran-comments.md
  • Polish NEWS
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('major')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

install fail

R version 3.6.2
platform: x86_64-w64-mingw32/x64 (64bit)
running under: window 10 x64 (build 18363)

when I install this package, a warmming message as follow, and i do not konw why and how to deal it:

Warning in install.packages :
installation of package ‘systemfonts’ had non-zero exit status

Feature request: has_font()

It seems useful to know whether a user specified font family will result in a "positive" match in systemfonts. Currently, it seems the best way to go about this with systemfonts is to do something like this, but it's not entirely clear how to account for systemfont's matching algorithm. Perhaps systemfonts could export something like has_font()?

library(systemfonts)

has_font <- function(family, italic = FALSE, bold = FALSE) {
  if (is_generic_font(family)) return(TRUE)
  m <- match_font(family, italic, bold)
  resolved <- font_info(path = m$path, index = m$index)$family
  sub("\\s*", "-", tolower(resolved)) %in% sub("\\s*", "-", tolower(family))
}

is_generic_font <- function(family) {
  if (family %in% c("sans", "serif", "mono", "etc")) TRUE else FALSE
}

has_font("roboto condensed")

User directory fonts on Windows not detected

The example currently rendered in README.md demonstrates that, on macOS, fonts are detected whether they're installed in /Library/Fonts, /System/Library/Fonts or in a user folder (note rows 1, 6 and 9):

system_fonts()
#> # A tibble: 627 x 9
#>    path         index name    family   style  weight width italic monospace
#>    <chr>        <int> <chr>   <chr>    <chr>  <fct>  <fct> <lgl>  <lgl>    
#>  1 /Users/thom…     0 Averia… Averia … Regul… normal norm… FALSE  FALSE    
#>  2 /Library/Fo…     1 ITFDev… ITF Dev… Bold   bold   norm… FALSE  FALSE    
#>  3 /Library/Fo…     0 SignPa… SignPai… House… normal semi… FALSE  FALSE    
#>  4 /Library/Fo…     1 Kannad… Kannada… Bold   bold   norm… FALSE  FALSE    
#>  5 /Library/Fo…     0 Damasc… Damascus Regul… normal norm… FALSE  FALSE    
#>  6 /Users/thom…     0 Spectr… Spectral Extra… ultra… norm… TRUE   FALSE    
#>  7 /System/Lib…     3 Kohino… Kohinoo… Bold   bold   norm… FALSE  FALSE    
#>  8 /System/Lib…     5 PingFa… PingFan… Medium medium norm… FALSE  FALSE    
#>  9 /Users/thom…     0 Source… Source … Bold   bold   norm… FALSE  FALSE    
#> 10 /Library/Fo…     7 PTSans… PT Sans  Bold   bold   norm… FALSE  FALSE    
#> # … with 617 more rows

Windows 10 1809 introduced the ability to install fonts to a user directory as well (%userprofile%\AppData\Local\Microsoft\Windows\Fonts), but these don't appear to be detected. I'm not sure how to demo a reprex here, but the only fonts detected on my Windows 10 system (version 1903) are in the system folder, although I also have ones installed in the user folder.

library(systemfonts)
unique(dirname(system_fonts()$path))
# [1] "C:/WINDOWS/Fonts"

Matplotlib also looked at this issue and considered iterating over registry keys that points to these user folder fonts. I'm not sure how feasible this is for systemfonts if it delegates this work to FreeType, but I wanted to at least describe it given the behaviour is different on macOS.

Release systemfonts 0.3.0

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Installation fails

OS: Ubuntu 18.04
install.packages('devtools') # Successfull
devtools::install_github('r-lib/systemfonts') # Fails
-------------------------- [ERROR MESSAGE] ---------------------------
:1:10: fatal error: fontconfig/fontconfig.h: No such file or directory
compilation terminated.

Full output:

Downloading GitHub repo r-lib/systemfonts@master
(ok) checking for file ‘/tmp/Rtmpx8abxQ/remotes494065856b57/r-lib-systemfonts-6ec572a/DESCRIPTION’ (338ms)

  • preparing ‘systemfonts’:
    (ok) checking DESCRIPTION meta-information ...
  • cleaning src
  • running ‘cleanup’
  • checking for LF line-endings in source and make files and shell scripts
  • checking for empty or unneeded directories
  • looking to see if a ‘data/datalist’ file should be added
  • building ‘systemfonts_0.2.2.9000.tar.gz’

Installing package into ‘/home/john/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)

  • installing source package ‘systemfonts’ ...
    Package fontconfig was not found in the pkg-config search path.
    Perhaps you should add the directory containing fontconfig.pc' to the PKG_CONFIG_PATH environment variable No package 'fontconfig' found Package freetype2 was not found in the pkg-config search path. Perhaps you should add the directory containing freetype2.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'freetype2' found
    Using PKG_CFLAGS=
    Using PKG_LIBS=-lfontconfig -lfreetype
    --------------------------- [ANTICONF] --------------------------------
    Configuration failed to find the fontconfig freetype2 library. Try installing:
  • deb: libfontconfig1-dev (Debian, Ubuntu, etc)
  • rpm: fontconfig-devel (Fedora, EPEL)
  • csw: fontconfig_dev (Solaris)
  • brew: freetype (OSX)
    If fontconfig freetype2 is already installed, check that 'pkg-config' is in your
    PATH and PKG_CONFIG_PATH contains a fontconfig freetype2.pc file. If pkg-config
    is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
    -------------------------- [ERROR MESSAGE] ---------------------------
    :1:10: fatal error: fontconfig/fontconfig.h: No such file or directory
    compilation terminated.

ERROR: configuration failed for package ‘systemfonts’

  • removing ‘/home/john/R/x86_64-pc-linux-gnu-library/3.4/systemfonts’
    Error: Failed to install 'systemfonts' from GitHub:
    (converted from warning) installation of package ‘/tmp/Rtmpx8abxQ/file49406762b343/systemfonts_0.2.2.9000.tar.gz’ had non-zero exit status

Installation fails on Windows

Sounds like FreeType is needed but not packaged.
(I also tried the latest version from GitHub)

install.packages('systemfonts')
#> Retrieving 'https://cloud.r-project.org/src/contrib/systemfonts_0.3.1.tar.gz' ...
#>  OK [file is up to date]
#> Installing systemfonts [0.3.1] ...
#>  FAILED
#> Error installing package 'systemfonts':
#> =======================================
#> 
#> * installing *source* package 'systemfonts' ...
#> ** package 'systemfonts' successfully unpacked and MD5 sums checked
#> ** using staged installation
#> 
#>    **********************************************
#>    WARNING: this package has a configure script
#>          It probably needs manual configuration
#>    **********************************************
#> 
#> 
#> ** libs
#> rm -f caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o cache_store.o init.o win/FontManagerWindows.o systemfonts.dll
#> "C:/R/R-3.6.3/bin/x64/Rscript.exe" "../tools/winlibs.R" 2.6.2
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c caches.cpp -o caches.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c cpp11.cpp -o cpp11.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c dev_metrics.cpp -o dev_metrics.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c font_matching.cpp -o font_matching.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c font_registry.cpp -o font_registry.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c ft_cache.cpp -o ft_cache.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c string_shape.cpp -o string_shape.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c font_metrics.cpp -o font_metrics.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c string_metrics.cpp -o string_metrics.o
#> C:/Rtools/mingw_64/bin/g++  -std=gnu++11 -I"C:/R/R-3.6.3/include" -DNDEBUG -I../windows/harfbuzz-2.6.2/include/freetype2 -I"C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32/cpp11/include"   -march=corei7 -mtune=corei7     -O3 -march=corei7 -c emoji.cpp -o emoji.o
#> In file included from ft_cache.cpp:1:0:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> In file included from caches.h:6:0,
#>                  from caches.cpp:1:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> compilation terminated.
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: caches.o] Error 1
#> make: *** Waiting for unfinished jobs....
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: ft_cache.o] Error 1
#> In file included from string_shape.cpp:4:0:
#> string_shape.h:6:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: string_shape.o] Error 1
#> In file included from string_metrics.cpp:2:0:
#> string_shape.h:6:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> In file included from caches.h:6:0,
#>                  from font_registry.cpp:2:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> In file included from caches.h:6:0,
#>                  from emoji.cpp:3:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: string_metrics.o] Error 1
#> In file included from caches.h:6:0,
#>                  from font_metrics.cpp:3:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> In file included from caches.h:6:0,
#>                  from font_matching.h:9,
#>                  from font_matching.cpp:1:
#> ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
#>  #include <ft2build.h>
#>                       ^
#> compilation terminated.
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: font_registry.o] Error 1
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: emoji.o] Error 1
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: font_matching.o] Error 1
#> make: *** [C:/R/R-3.6.3/etc/x64/Makeconf:215: font_metrics.o] Error 1
#> ERROR: compilation failed for package 'systemfonts'
#> * removing 'C:/Users/LG/renv/staging/7/systemfonts'
#> Error: install of package 'systemfonts' failed

Created on 2020-09-13 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.3 (2020-02-29)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_Switzerland.1252    
#>  ctype    English_Switzerland.1252    
#>  tz       Europe/Berlin               
#>  date     2020-09-13                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.0)
#>  backports     1.1.8   2020-06-17 [1] CRAN (R 3.6.3)
#>  callr         3.4.3   2020-03-28 [1] CRAN (R 3.6.3)
#>  cli           2.0.2   2020-02-28 [1] CRAN (R 3.6.3)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 3.6.0)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 3.6.0)
#>  devtools      2.3.1   2020-07-21 [1] CRAN (R 3.6.3)
#>  digest        0.6.25  2020-02-23 [1] CRAN (R 3.6.3)
#>  ellipsis      0.3.1   2020-05-15 [1] CRAN (R 3.6.3)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 3.6.2)
#>  fansi         0.4.1   2020-01-08 [1] CRAN (R 3.6.2)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 3.6.3)
#>  glue          1.4.1   2020-05-13 [1] CRAN (R 3.6.3)
#>  highr         0.8     2019-03-20 [1] CRAN (R 3.6.2)
#>  htmltools     0.5.0   2020-06-16 [1] CRAN (R 3.6.3)
#>  knitr         1.29    2020-06-23 [1] CRAN (R 3.6.3)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.2)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.2)
#>  pkgbuild      1.1.0   2020-07-13 [1] CRAN (R 3.6.3)
#>  pkgload       1.1.0   2020-05-29 [1] CRAN (R 3.6.3)
#>  prettyunits   1.1.1   2020-01-24 [1] CRAN (R 3.6.3)
#>  processx      3.4.3   2020-07-05 [1] CRAN (R 3.6.3)
#>  ps            1.3.4   2020-08-11 [1] CRAN (R 3.6.3)
#>  R6            2.4.1   2019-11-12 [1] CRAN (R 3.6.1)
#>  remotes       2.2.0   2020-07-21 [1] CRAN (R 3.6.3)
#>  renv          0.11.0  2020-06-26 [1] CRAN (R 3.6.3)
#>  rlang         0.4.7   2020-07-09 [1] CRAN (R 3.6.3)
#>  rmarkdown     2.3     2020-06-18 [1] CRAN (R 3.6.3)
#>  rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.6.1)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.2)
#>  stringi       1.4.6   2020-02-17 [1] CRAN (R 3.6.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 3.6.2)
#>  testthat      2.3.2   2020-03-02 [1] CRAN (R 3.6.3)
#>  usethis       1.6.1   2020-04-29 [1] CRAN (R 3.6.3)
#>  withr         2.2.0   2020-04-20 [1] CRAN (R 3.6.3)
#>  xfun          0.16    2020-07-24 [1] CRAN (R 3.6.3)
#>  yaml          2.2.1   2020-02-01 [1] CRAN (R 3.6.2)
#> 
#> [1] C:/Users/LG/renv/library/R-3.6/x86_64-w64-mingw32
#> [2] C:/Users/LG/AppData/Local/Temp/RtmpQbbnpa/renv-system-library
#> [3] C:/Users/LG/AppData/Local/Temp/RtmpAVgtJy/renv-system-library

Release systemfonts 0.1.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • devtools::check()
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • Polish pkgdown reference index
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • Update cran-comments.md
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • usethis::use_news()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

installation fails on RHEL 6.1

install.packages("systemfonts")

Here is the output:

Installing package into ‘/home/btyner/R/x86_64-redhat-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://mirror.las.iastate.edu/CRAN/src/contrib/systemfonts_0.3.2.tar.gz'
Content type 'application/x-gzip' length 73885 bytes (72 KB)
==================================================
downloaded 72 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/freetype2
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -m64 -std=gnu++0x -I"/usr/include/R" -DNDEBUG -I/usr/include/freetype2   -I"/home/btyner/R/x86_64-redhat-linux-gnu-library/3.5/cpp11/include" -I/usr/local/include   -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c caches.cpp -o caches.o
In file included from caches.h:3,
                 from caches.cpp:1:
/home/btyner/R/x86_64-redhat-linux-gnu-library/3.5/cpp11/include/cpp11/R.hpp:22: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
In file included from caches.h:3,
                 from caches.cpp:1:
/home/btyner/R/x86_64-redhat-linux-gnu-library/3.5/cpp11/include/cpp11/R.hpp:32: error: ‘constexpr’ does not name a type
In file included from caches.cpp:1:
caches.h:19: error: expected unqualified-id before ‘[’ token
make: *** [caches.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/home/btyner/R/x86_64-redhat-linux-gnu-library/3.5/systemfonts’

The downloaded source packages are in
        ‘/tmp/RtmpjCtOEm/downloaded_packages’
Warning message:
In install.packages("systemfonts") :
  installation of package ‘systemfonts’ had non-zero exit status

Any suggestions? I am using R version 3.5.2, on Red Hat Enterprise Linux Server release 6.10.

Build Error: /bin/sh: I/Library/Frameworks//R.framework/Resources/include: No such file or directory

Good evening,
I upgraded my version of R, and I'm having problems installing a couple of libraries that use systemfonts.

While compiling, the log reports I/Library/Frameworks//R.framework/Resources/include: No such file or directory ; however, the directory is present as shown below.

Do you know how to make sure that when running install.packages("systemfonts") I can manually point to this include ? or maybe add it to an environment variable ?

Many thanks,

  • include/
ls /Library/Frameworks//R.framework/Resources/include
R.h          Rconfig.h    Rembedded.h  Rinternals.h Rversion.h   libintl.h
R_ext        Rdefines.h   Rinterface.h Rmath.h      S.h
  • Error Message
> install.packages("systemfonts", dependencies = TRUE, ask = FALSE)
trying URL 'https://cran.uni-muenster.de/src/contrib/systemfonts_0.3.2.tar.gz'
Content type 'application/x-gzip' length 73885 bytes (72 KB)
==================================================
downloaded 72 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/local/opt/freetype/include/freetype2
Using PKG_LIBS=-L/usr/local/opt/freetype/lib -L/usr/local/Cellar/libpng/1.6.37/lib -lfreetype -lz -lbz2 -lpng16 -lz
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o cache_store.o init.o mac/FontManagerMac.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c caches.cpp -o caches.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c cpp11.cpp -o cpp11.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c dev_metrics.cpp -o dev_metrics.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c font_matching.cpp -o font_matching.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c font_registry.cpp -o font_registry.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c ft_cache.cpp -o ft_cache.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c string_shape.cpp -o string_shape.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c font_metrics.cpp -o font_metrics.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c string_metrics.cpp -o string_metrics.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c emoji.cpp -o emoji.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c cache_store.cpp -o cache_store.o
clang++ -std=gnu++11 -I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include   -fPIC  -Wall -g -O3  -c init.cpp -o init.o
I"/Library/Frameworks//R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/freetype/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/cpp11/include' -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/opt/icu4c/include -I/usr/local/opt/gettext/include -I/usr/local/opt/curl/include -I/usr/local/include -I/usr/local/opt/cairo/include -I/usr/local/opt/pango/include/pango-1.0/pango -I/usr/local/opt/tcl-tk/include  -fobjc-arc -fPIC   -c mac/FontManagerMac.mm -o mac/FontManagerMac.o
/bin/sh: I/Library/Frameworks//R.framework/Resources/include: No such file or directory
make: [mac/FontManagerMac.o] Error 127 (ignored)
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks//R.framework/Resources/lib -L/usr/local/opt/curl/lib -L/usr/local/opt/tcl-tk/lib -o systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o cache_store.o init.o mac/FontManagerMac.o -L/usr/local/opt/freetype/lib -L/usr/local/Cellar/libpng/1.6.37/lib -lfreetype -lz -lbz2 -lpng16 -lz -framework CoreText -framework Foundation -F/Library/Frameworks//R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
clang: error: no such file or directory: 'mac/FontManagerMac.o'
make: *** [systemfonts.so] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts’

The downloaded source packages are in
	‘/private/var/folders/f7/v_vt_5bn07z9tljnh56n9crnrzdbg9/T/RtmpBuQuLQ/downloaded_packages’
Warning message:
In install.packages("systemfonts", dependencies = TRUE, ask = FALSE) :
  installation of package ‘systemfonts’ had non-zero exit status
  • R Session Info
> sessionInfo()
R Under development (unstable) (2020-09-29 r79279)
Platform: x86_64-apple-darwin18.7.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] ps_1.3.4          fansi_0.4.1       prettyunits_1.1.1 withr_2.3.0      
 [5] crayon_1.3.4      rprojroot_1.3-2   assertthat_0.2.1  R6_2.4.1         
 [9] backports_1.1.10  cli_2.0.2         curl_4.3          remotes_2.2.0    
[13] callr_3.4.4       tools_4.1.0       glue_1.4.2        compiler_4.1.0   
[17] processx_3.4.4    pkgbuild_1.1.0    tcltk_4.1.0      

Release systemfonts 0.2.3

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Release systemfonts 0.2.2

Prepare for release:

  • devtools::build_readme()
  • Check current CRAN check results
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • rhub::check_with_valgrind(env_vars = c(VALGRIND_OPTS = "--leak-check=full --track-origins=yes"))
  • rhub::check_on_solaris(env_vars = c('_R_CHECK_FORCE_SUGGESTS_' = 'false'))
  • rhub::check(platform = 'macos-highsierra-release-cran')
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Polish NEWS

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()

Difficult to Reproduce Issue with _systemfonts_match_font_c

When I run the following code in an interactive session, I get an error indicating. But, when I try it in a reprex, everything works.

Error in .Call("_systemfonts_match_font_c", family, italic, bold) : 
  "_systemfonts_match_font_c" not resolved from current namespace (systemfonts)
data <- data.frame(A=1, B=2)
ggsave(
  plot=ggplot(data, aes(x=A, y=B)) +
    geom_point(),
  filename="c:/tmp/test.svg",
  width=6, height=4
)

I'm guessing that it is something specific that I have loaded in my session that is conflicting with something else. My sessionInfo is below. Do you know of anything that may cause this issue?

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] gdtools_0.2.2           cowplot_1.1.0           forcats_0.5.0           purrr_0.3.4             tibble_3.0.3            ggplot2_3.3.2           tidyverse_1.3.0        
 [8] bsd.report_0.0.0.9088   Rsdtm_0.0.0.9010        tidyr_1.1.2             rio_0.5.16              readr_1.3.1             lubridate_1.7.9         dplyr_1.0.2            
[15] latex.makers_0.0.0.9000 assertr_2.7             drake_7.12.5            brms_2.13.9             Rcpp_1.0.5              nlme_3.1-149            emmeans_1.5.1          
[22] lme4_1.1-23             Matrix_1.2-18           pmxTools_1.2.1          DiagrammeR_1.0.6.1      data.tree_1.0.0         magrittr_1.5            stringr_1.4.0          
[29] MASS_7.3-53             mrgsolve_0.10.4         rmutil_1.1.5           

loaded via a namespace (and not attached):
  [1] estimability_1.3          coda_0.19-3               knitr_1.29                dygraphs_1.1.1.6          data.table_1.13.0         rpart_4.1-15             
  [7] inline_0.3.16             generics_0.0.2            callr_3.4.4               usethis_1.6.3             base64url_1.4             xml2_1.3.2               
 [13] httpuv_1.5.4              StanHeaders_2.21.0-6      assertthat_0.2.1          xfun_0.17                 hms_0.5.3                 bayesplot_1.7.2          
 [19] evaluate_0.14             promises_1.1.1            fansi_0.4.1               progress_1.2.2            dbplyr_1.4.4              readxl_1.3.1             
 [25] km.ci_0.5-2               igraph_1.2.5              DBI_1.1.0                 htmlwidgets_1.5.1         RcppArmadillo_0.9.900.3.0 stats4_4.0.2             
 [31] ellipsis_0.3.1            crosstalk_1.1.0.1         ggpubr_0.4.0              backports_1.1.10          V8_3.2.0                  arsenal_3.5.0            
 [37] markdown_1.1              RcppParallel_5.0.2        vctrs_0.3.4               remotes_2.2.0             abind_1.4-5               withr_2.2.0              
 [43] checkmate_2.0.0           xts_0.12.1                prettyunits_1.1.1         svglite_1.2.3.2           cluster_2.1.0             crayon_1.3.4             
 [49] pkgconfig_2.0.3           labeling_0.3              pkgload_1.1.0             nnet_7.3-14               devtools_2.3.2            rlang_0.4.7              
 [55] lifecycle_0.2.0           miniUI_0.1.1.1            colourpicker_1.1.0        filelock_1.0.2            modelr_0.1.8              cellranger_1.1.0         
 [61] rprojroot_1.3-2           matrixStats_0.56.0        knitcitations_1.0.10      loo_2.3.1                 KMsurv_0.1-5              carData_3.0-4            
 [67] boot_1.3-25               zoo_1.8-8                 reprex_0.3.0              base64enc_0.1-3           whisker_0.4               ggridges_0.5.2           
 [73] processx_3.4.4            png_0.1-7                 visNetwork_2.0.9          blob_1.2.1                qpdf_1.1                  jpeg_0.1-8.1             
 [79] shinystan_2.5.0           rstatix_0.6.0             ggsignif_0.6.0            scales_1.1.1              memoise_1.1.0             plyr_1.8.6               
 [85] bibtex_0.4.2.3            threejs_0.3.3             compiler_4.0.2            RefManageR_1.2.12         rstantools_2.1.1          RColorBrewer_1.1-2       
 [91] snakecase_0.11.0          cli_2.0.2                 ps_1.3.4                  Brobdingnag_1.2-6         htmlTable_2.1.0           Formula_1.2-3            
 [97] mgcv_1.8-33               tidyselect_1.1.0          stringi_1.5.3             yaml_2.2.1                askpass_1.1               latticeExtra_0.6-29      
[103] bridgesampling_1.0-0      survMisc_0.5.5            grid_4.0.2                tools_4.0.2               parallel_4.0.2            rstudioapi_0.11          
[109] foreign_0.8-80            janitor_2.0.1             gridExtra_2.3             farver_2.0.3              digest_0.6.25             shiny_1.5.0              
[115] storr_1.2.1               car_3.0-9                 broom_0.7.0               later_1.1.0.1             httr_1.4.2                survminer_0.4.8          
[121] rsconnect_0.8.16          colorspace_1.4-1          rvest_0.3.6               fs_1.5.0                  splines_4.0.2             statmod_1.4.34           
[127] shinythemes_1.1.2         sessioninfo_1.1.1         systemfonts_0.3.1         xtable_1.8-4              jsonlite_1.7.1            nloptr_1.2.2.2           
[133] truncdist_1.0-2           rstan_2.21.2              testthat_2.3.2            R6_2.4.1                  Hmisc_4.4-1               pillar_1.4.6             
[139] htmltools_0.5.0           mime_0.9                  txtq_0.2.3                glue_1.4.2                fastmap_1.0.1             minqa_1.2.4              
[145] DT_0.15                   cpp11_0.2.1               codetools_0.2-16          PKNCA_0.9.4               pkgbuild_1.1.0            mvtnorm_1.1-1            
[151] utf8_1.1.4                lattice_0.20-41           evd_2.3-3                 curl_4.3                  gtools_3.8.2              clipr_0.7.0              
[157] zip_2.1.1                 shinyjs_2.0.0             openxlsx_4.2.2            survival_3.2-3            rmarkdown_2.3             desc_1.2.0               
[163] munsell_0.5.0             haven_2.3.1               reshape2_1.4.4            gtable_0.3.0  

systemfonts() can detect a font but C API can't do on Windows

I found that some fonts can't be detected when I'm using svglite package on Widows 10.

It seems that the locate_font_with_features doesn't work. The following is the reprex. In this case, all of three fonts (these are all standard Japanese fonts on Windows 10) are detected by systemfonts() but "BIZ UDPMincho" is not detected by locate_font_with_features and Arial is used instead.

#include <Rcpp.h>
#include <systemfonts.h>
using namespace Rcpp;

// [[Rcpp::export]]
String fontfile(std::string fontfamily) {
  const char* ff = fontfamily.c_str();
  return locate_font_with_features(ff, 0, 0).file;
}


/*** R
library(systemfonts)  # 1.0.2.9000
subset(system_fonts(), family == "Yu Mincho")
##                                path index              name    family    style   weight  width italic monospace
## 258   C:\\WINDOWS\\Fonts\\yumin.ttf     0  YuMincho-Regular Yu Mincho  Regular   normal normal  FALSE     FALSE
## 259 C:\\WINDOWS\\Fonts\\yumindb.ttf     0 YuMincho-Demibold Yu Mincho Demibold semibold normal  FALSE     FALSE
## 260  C:\\WINDOWS\\Fonts\\yuminl.ttf     0    YuMincho-Light Yu Mincho    Light    light normal  FALSE     FALSE


fontfile("Yu Mincho")
## [1] "C:\\WINDOWS\\Fonts\\yumin.ttf"

subset(system_fonts(), family == "BIZ UDPMincho")
##                                      path index                 name        family  style weight  width italic monospace
## 241 C:\\WINDOWS\\Fonts\\BIZ-UDMinchoM.ttc     1 BIZ-UDPMincho-Medium BIZ UDPMincho Medium medium normal  FALSE     FALSE

fontfile("BIZ UDPMincho")
## [1] "C:\\WINDOWS\\Fonts\\arial.ttf"  #  HERE

subset(system_fonts(), family == "BIZ UDPGothic")
## path index               name        family   style weight  width italic monospace
## 237 C:\\WINDOWS\\Fonts\\BIZ-UDGothicR.ttc     1      BIZ-UDPGothic BIZ UDPGothic Regular normal normal  FALSE     FALSE
## 239 C:\\WINDOWS\\Fonts\\BIZ-UDGothicB.ttc     1 BIZ-UDPGothic-Bold BIZ UDPGothic    Bold   bold normal  FALSE     FALSE

fontfile("BIZ UDPGothic")
## [1] "C:\\WINDOWS\\Fonts\\BIZ-UDGothicR.ttc"

*/

Both functions call getAvailableFonts(), but the latter doesn't looks detect the fonts.
It's my mistake.

Allow register_variant() based on a family created with register_font()

Rationale: on GHA, where it is difficult to get fonts registered correctly (and perhaps elsewhere), the workaround is to register_font() from files inside an installed package. Registering variants via register_variant() base on a family created by register_font() is currently not possible, as the font does not appear in the output of system_fonts(). So a variant with different features can only be created by running the entire call to register_font() again with only the features param altered. That gets lengthy with lots of font weights/widths...

This may or may not be related to #68 - I guess that if "system" fonts can be found in other directories, then this whole workaround becomes unnecessary. But from the discussion under #58 I also understand that where fonts are searched for may well not be in systemfonts' power to influence...

variable 'face' is uninitialized when used here

clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/X11/include/freetype2 -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/cpp11/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c cache_store.cpp -o cache_store.o
cache_store.cpp:13:12: warning: variable 'face' is uninitialized when used here [-Wuninitialized]
    return face;
           ^~~~
cache_store.cpp:8:15: note: initialize the variable 'face' to silence this warning
  FT_Face face;
              ^
               = nullptr
1 warning generated.

Can't install on macOS Catalina

Hi there,

I tried to install systemfonts on macOS Catalina, but I got the following error message:

<stdin>:1:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^~~~~~~~~~~~
1 error generated.
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because freetype2 was not found. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fedora, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

I tried to install freetype via brew, didn't worked. Also tried to unlink and relink freetype in brew, still not working.

I'm not sure to understand how to "check that 'pkg-config' is in your PATH" and how to use "R CMD INSTALL".

Any clue on how to solve this?

Thanks!

Compilation issue CentOS

Hi,

I trying to install systemfonts in a HPC environment from CRAN, however I up with a compilation error:

`* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/freetype2
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c caches.cpp -o caches.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c cpp11.cpp -o cpp11.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c dev_metrics.cpp -o dev_metrics.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c font_matching.cpp -o font_matching.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c font_registry.cpp -o font_registry.o
g++ -std=c++0x -I/camhpc/pkg/R/3.2.2/centos6/lib64/R/include -DNDEBUG -I/usr/include/freetype2   -I/usr/local/include -I"/camhpc/home/username/R/x86_64-pc-linux-gnu-library/3.2/cpp11/include"   -fpic  -g -O2 -c ft_cache.cpp -o ft_cache.o
ft_cache.cpp: In member function ‘FT_FaceRec_* FreetypeCache::get_face()’:
ft_cache.cpp:292:25: error: ‘FT_Reference_Face’ was not declared in this scope
   FT_Reference_Face(face);
                         ^
make: *** [ft_cache.o] Error 1
ERROR: compilation failed for package ‘systemfonts’`

This error occurs both under R 3.6.1 as well as 3.2.2. Any help would be greatly appreciated.

Windows fonts not found

I'm encountering an issue on Windows Server 2019. Fonts are not discovered properly (but are present in C:\Windows\Fonts).

font_info() shows a warning like No fonts detected on your system. Using an empty font.
system_fonts() returns:

[1] path      index     name      family    style     weight    width
[8] italic    monospace
<0 rows> (or 0-length row.names)

As a workaround I'm using this trick:
https://stackoverflow.com/questions/55933524/r-can-not-find-fonts-to-be-used-in-plotting
But I would prefer to avoid it.

Here are my sessionInfo():

R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] systemfonts_0.3.2

loaded via a namespace (and not attached):
[1] compiler_3.6.3

Any suggestion?

Is it possible to use the “extra” font styles?

I am using a windows 10 machine and there are many fonts having styles other than the well known styles (regular, bold and italic).
Is it possible to use the “extra” font styles? In case of yes, how these font “extra” styles can be referred and used?
For example in a ggplot() plot, where only a limited set of font faces can be inserted to the element_text() ("plain", "italic", "bold", "bold.italic"). At the same time, I cannot use the systemfonts::font_info() for these font styles.

Here is a list of all font styles found on my laptop (and I am not a font collector)

systemfonts::system_fonts() %>% 
  count(style)
|style                  |   n|
|:----------------------|---:|
|Black                  |   5|
|Black Italic           |   4|
|Bold                   | 107|
|Bold Italic            |  46|
|Bold Oblique           |   3|
|Bold Slanted           |   1|
|BoldItalic             |   1|
|BoldOblique            |   3|
|Book                   |   5|
|BookOblique            |   1|
|Condensed              |   5|
|Condensed Bold         |   5|
|Condensed Bold Italic  |   4|
|Condensed Bold Oblique |   1|
|Condensed Italic       |   4|
|Condensed Oblique      |   1|
|Demibold               |   2|
|Demibold Italic        |   3|
|Demibold Roman         |   1|
|ExtraLight             |   3|
|ExtraLight Italic      |   2|
|Italic                 |  65|
|Light                  |  19|
|Light Italic           |   8|
|LightOblique           |   1|
|Medium                 |   9|
|Medium Italic          |   1|
|MediumItalic           |   1|
|MediumOblique          |   1|
|Narrow                 |   1|
|Narrow Bold            |   1|
|Narrow Bold Italic     |   1|
|Narrow Italic          |   1|
|Normal                 |   2|
|Oblique                |   3|
|Poster Compressed      |   1|
|Regular                | 273|
|Semibold               |   5|
|Semibold Italic        |   4|
|Semilight              |   5|
|Semilight Italic       |   1|
|Slanted                |   1|

R function to reload system font information ?

Hi

I forked the 'gdtools' package (a while ago) in order to add an R-level call to FcInitReinitialize(), so that my package could force a reload of FontConfig configuration files. Now that 'gdtools' has abdicated in favour of 'systemfonts', I no longer have access to that sort of facility.

Is that concept (rescan the font configuration) something that translates to all platforms ?

Would it be something you would consider adding to 'systemfonts' ?

Paul

caught segfault

Hi Thomas,
I'm running a workflow on Debian version 10 and i keep getting the same error with match_font()
Im attaching the traceback logs

Screen Shot 2019-12-07 at 04 08 54

Is there any workaround or fix for this case?
thanks in advance

reset_font_cache() segfaults

Hi,

I recently noticed that calling systemfonts::reset_font_cache() segfaults (I tried both the latest CRAN release and the current development version from Github):

> library(systemfonts)
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] systemfonts_1.0.0.9000

loaded via a namespace (and not attached):
[1] compiler_4.0.3
> reset_font_cache()

 *** caught illegal operation ***
address 0x7fff4b1322ad, cause 'illegal opcode'

Traceback:
 1: reset_font_cache_c()
 2: reset_font_cache()

I saw some other people reporting segfaults for systemfonts::system_fonts() and systemfonts::match_font("Helvetica"), but those both work fine for me.

Best,
Constantin

Inclusion in plain C package fails - Problem with (missing) struct typedefs in systemfonts.h

Adding "#include <systemfonts.h>" in a plain C package on MacOS results in errors when attempting to compile package.

This error appears to be related to the struct declarations in the header.

My package compiles fine if #include <systemfonts.h> is excluded. Note: No actual calls to systemfont functions are included in the package yet.

R4.1.0
systemfonts (‘1.0.2.9000’ from github) - compile clean. all system dependencies installed
MacOS 11.4 (Intel)

First part of error output when building my package

==> devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))

ℹ Updating devoid documentation
ℹ Loading devoid
Re-compiling devoid
─  installing *source* package ‘devoid’ ...
   ** using staged installation
   ** libs

  clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -UNDEBUG -Wall -pedantic -g -O0 -c devoid.c -o devoid.o
   In file included from devoid.c:14:
   /Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts/include/systemfonts.h:23:9: error: must use 'struct' tag to refer to type 'FontFeature'
     const FontFeature* features;
           ^
           struct 
   /Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts/include/systemfonts.h:38:15: error: must use 'struct' tag to refer to type 'FontSettings'
   static inline FontSettings locate_font_with_features(const char *family, int italic, int bold) {
                 ^
                 struct 
   /Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts/include/systemfonts.h:39:25: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
     static FontSettings (*p_locate_font_with_features)(const char*, int, int) = NULL;
                           ^
   /Library/Frameworks/R.framework/Versions/4.1/Resources/library/systemfonts/include/systemfonts.h:39:10: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]

Possible fix

If explicit typedef struct statements are added, then these errors do not occur.

typedef struct FontFeature FontFeature; // Explicit typedef
struct FontFeature {
  char feature[4];
  int setting;
};
// A structure to pass around a single font with features (used by the C interface)

typedef struct FontSettings FontSettings; // Explicit typedef
struct FontSettings  {
  char file[PATH_MAX + 1];
  unsigned int index;
  const FontFeature* features;
  int n_features;
};

Compile error "'u_int32_t' was not declared in this scope" at alpine

Hi, I am trying to install systemfonts in an alpine container but I get this error.

Downloading GitHub repo r-lib/systemfonts@master
✔  checking for file ‘/tmp/Rtmpompeoo/remotes139e5c5ed/r-lib-systemfonts-2c215f8/DESCRIPTION’ ...
─  preparing ‘systemfonts’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘systemfonts_0.1.1.9000.tar.gz’
   
* installing *source* package ‘systemfonts’ ...
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid 
Using PKG_LIBS=-lfontconfig -lfreetype 
** libs
rm -f systemfonts.so systemfonts.o ft_cache.o string_shape.o font_metrics.o string_metrics.o emoji.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/usr/include/R" -DNDEBUG -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid  -DSTRICT_R_HEADERS  -Os -fomit-frame-pointer  -fpic  -g -O2 -Wall -pedantic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -D__MUSL__ -I"/usr/lib/omp/" -c systemfonts.cpp -o systemfonts.o
In file included from systemfonts.cpp:7:
systemfonts.h:22:28: error: 'u_int32_t' was not declared in this scope; did you mean 'uint32_t'?
   22 | typedef std::unordered_map<u_int32_t, u_int8_t> EmojiMap;
      |                            ^~~~~~~~~
      |                            uint32_t
systemfonts.h:22:39: error: 'u_int8_t' was not declared in this scope; did you mean 'uint8_t'?
   22 | typedef std::unordered_map<u_int32_t, u_int8_t> EmojiMap;
      |                                       ^~~~~~~~
      |                                       uint8_t
systemfonts.h:22:47: error: template argument 1 is invalid
   22 | typedef std::unordered_map<u_int32_t, u_int8_t> EmojiMap;
      |                                               ^
systemfonts.h:22:47: error: template argument 2 is invalid
systemfonts.h:22:47: error: template argument 3 is invalid
systemfonts.h:22:47: error: template argument 4 is invalid
systemfonts.h:22:47: error: template argument 5 is invalid
make: *** [/usr/lib/R/etc/Makeconf:175: systemfonts.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/usr/lib/R/library/systemfonts’
Error: Failed to install 'systemfonts' from GitHub:
  (converted from warning) installation of package ‘/tmp/Rtmpompeoo/file15195a54/systemfonts_0.1.1.9000.tar.gz’ had non-zero exit status
Execution halted
The command 'R -e devtools::install_github('r-lib/systemfonts')' returned a non-zero code: 1

I have installed ccache clang clang-dev clang-libs clang-static libc-dev libstdc++ to the system and the sessionInfo is followed.

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-musl (64-bit)
Running under: Alpine Linux v3.11

Matrix products: default
BLAS:   /usr/lib/libopenblasp-r0.3.7.so
LAPACK: /usr/lib/R/lib/libRlapack.so

locale:
[1] C.UTF-8 C       C       C       C       C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.2
devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.2 (2019-12-12)
 os       Alpine Linux v3.11          
 system   x86_64, linux-musl          
 ui       X11                         
 language (EN)                        
 collate  C                           
 ctype    C.UTF-8                     
 tz       <NA>                        
 date     2020-04-23                  

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version    date       lib source        
 assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.2)
 backports     1.1.6      2020-04-05 [1] CRAN (R 3.6.2)
 callr         3.4.3      2020-03-28 [1] CRAN (R 3.6.2)
 cli           2.0.2      2020-02-28 [1] CRAN (R 3.6.2)
 crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.2)
 desc          1.2.0      2018-05-01 [1] CRAN (R 3.6.2)
 devtools      2.2.2      2020-02-17 [1] CRAN (R 3.6.2)
 digest        0.6.25     2020-02-23 [1] CRAN (R 3.6.2)
 ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.2)
 fansi         0.4.1      2020-01-08 [1] CRAN (R 3.6.2)
 fs            1.3.2.9000 2020-03-24 [1] local         
 glue          1.4.0      2020-04-03 [1] CRAN (R 3.6.2)
 magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.2)
 memoise       1.1.0      2017-04-21 [1] CRAN (R 3.6.2)
 pkgbuild      1.0.6      2019-10-09 [1] CRAN (R 3.6.2)
 pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.6.2)
 prettyunits   1.1.1      2020-01-24 [1] CRAN (R 3.6.2)
 processx      3.4.2      2020-02-09 [1] CRAN (R 3.6.2)
 ps            1.3.2      2020-02-13 [1] CRAN (R 3.6.2)
 R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.2)
 Rcpp          1.0.4.6    2020-04-09 [1] CRAN (R 3.6.2)
 remotes       2.1.1      2020-02-15 [1] CRAN (R 3.6.2)
 rlang         0.4.5      2020-03-01 [1] CRAN (R 3.6.2)
 rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.2)
 sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.2)
 testthat      2.3.2      2020-03-02 [1] CRAN (R 3.6.2)
 usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.2)
 withr         2.2.0      2020-04-20 [1] CRAN (R 3.6.2)

It seems like even though it is not a _WIN32 but still lacks of the u_int32_t declaration.
Thank you in advance :)

Fail to install from the source.

R runs and Rstudio runs but does not produce pdf, word, or HTML documents that I knitted. My homebrew, Xcode, and Xquartz are up to date.

`install.packages("systemfonts")

  There is a binary version available but the source
  version is later:
            binary source needs_compilation
systemfonts  1.0.1  1.0.2              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
installing the source package ‘systemfonts’

trying URL 'https://cran.rstudio.com/src/contrib/systemfonts_1.0.2.tar.gz'
Content type 'application/x-gzip' length 80693 bytes (78 KB)
==================================================
downloaded 78 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Homebrew 3.1.7
Homebrew/homebrew-core (git revision 20cd7d8e6d; last commit 2021-05-13)
Using PKG_CFLAGS=-I/usr/local/include -I/usr/local/include/freetype2
Using PKG_LIBS=-lfreetype
--------------------------- [ANTICONF] --------------------------------
Configuration failed to find the --static freetype2 library. Try installing:
 * deb: libfontconfig1-dev (Debian, Ubuntu, etc)
 * rpm: fontconfig-devel (Fedora, EPEL)
 * csw: fontconfig_dev (Solaris)
 * brew: freetype (OSX)
If --static freetype2 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a --static freetype2.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
-------------------------- [ERROR MESSAGE] ---------------------------
<stdin>:1:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
         ^~~~~~~~~~~~
1 error generated.
--------------------------------------------------------------------
ERROR: configuration failed for package ‘systemfonts’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/systemfonts’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/systemfonts’
Warning in install.packages :
  installation of package ‘systemfonts’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/_y/gy3_9sj93ws6kj18xhq1fsyr0000gn/T/RtmpBrNubO/downloaded_packages’`

Here is the session info
` sessionInfo(package = NULL)
R version 4.0.4 (2021-02-15)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] emmeans_1.6.0

loaded via a namespace (and not attached):
 [1] statmod_1.4.36    zoo_1.8-9         tidyselect_1.1.1  xfun_0.22         purrr_0.3.4       splines_4.0.4    
 [7] lattice_0.20-44   vctrs_0.3.8       generics_0.1.0    htmltools_0.5.1.1 yaml_2.2.1        utf8_1.2.1       
[13] survival_3.2-11   rlang_0.4.11      nloptr_1.2.2.2    pillar_1.6.0      glue_1.4.2        DBI_1.1.1        
[19] multcomp_1.4-17   lifecycle_1.0.0   mvtnorm_1.1-1     codetools_0.2-18  coda_0.19-4       evaluate_0.14    
[25] knitr_1.33        fansi_0.4.2       broom_0.7.6       TH.data_1.0-10    Rcpp_1.0.6        xtable_1.8-4     
[31] backports_1.2.1   lme4_1.1-26       digest_0.6.27     bookdown_0.22     dplyr_1.0.6       grid_4.0.4       
[37] tools_4.0.4       sandwich_3.0-0    magrittr_2.0.1    tibble_3.1.1      mice_3.13.0       tidyr_1.1.3      
[43] crayon_1.4.1      pkgconfig_2.0.3   MASS_7.3-54       ellipsis_0.3.2    Matrix_1.3-3      estimability_1.3 
[49] assertthat_0.2.1  minqa_1.2.4       rmarkdown_2.8     R6_2.5.0          boot_1.3-28       nlme_3.1-152     
[55] compiler_4.0.4  ` 

systemfonts::system_fonts crashes (segfault) when used in future

This code produces a hard segfault:

future::plan(future::multiprocess)

fut <- future::future({
  systemfonts::system_fonts()
})

r <- future::value(fut)
print(r)
[1] "Using environment default"

 *** caught segfault ***
address 0x110, cause 'memory not mapped'

Traceback:
 1: systemfonts::system_fonts()
 2: eval(quote({    systemfonts::system_fonts()}), new.env())
 3: eval(quote({    systemfonts::system_fonts()}), new.env())
 4: eval(expr, p)
 5: eval(expr, p)
 6: eval.parent(substitute(eval(quote(expr), envir)))
 7: local({    systemfonts::system_fonts()})
 8: doTryCatch(return(expr), name, parentenv, handler)
 9: tryCatchOne(expr, names, parentenv, handlers[[1L]])
10: tryCatchList(expr, classes, parentenv, handlers)
11: tryCatch({    ...future.value <- local({        systemfonts::system_fonts()    })    future::FutureResult(value = ...future.value, version = "1.8")}, error = function(cond) {    calls <- sys.calls()    structure(list(value = NULL, value2 = NA, condition = cond,         calls = calls, version = "1.8"), class = "FutureResult")}, finally = {    {        {            {                options(mc.cores = ...future.mc.cores.old)            }            future::plan(list(function (expr, envir = parent.frame(),                 substitute = TRUE, lazy = FALSE, seed = NULL,                 globals = TRUE, workers = availableCores(), gc = FALSE,                 earlySignal = FALSE, label = NULL, ...)             {                if (substitute)                   expr <- substitute(expr)                fun <- if (supportsMulticore())                   multicore                else multisession                fun(expr = expr, envir = envir, substitute = FALSE,                   lazy = lazy, seed = seed, globals = globals,                   workers = workers, gc = gc, earlySignal = earlySignal,                   label = label, ...)            }), .cleanup = FALSE, .init = FALSE)        }        options(...future.oldOptions)    }})
12: eval(expr, env)

R 3.6.0, systemfonts 0.2.3 on macos.

lldb backtrace

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x110)
  * frame #0: 0x00007fff6f5a2e47 libdispatch.dylib`_dispatch_mgr_queue_push + 41
    frame #1: 0x00007fff6f59ebab libdispatch.dylib`_dispatch_lane_resume_activate + 58
    frame #2: 0x00007fff44919d9a CarbonCore`connectToCoreServicesD() + 245
    frame #3: 0x00007fff44919c74 CarbonCore`getStatus() + 24
    frame #4: 0x00007fff44919bef CarbonCore`scCreateSystemServiceVersion + 49
    frame #5: 0x00007fff44919964 CarbonCore`FileIDTreeGetCachedPort + 213
    frame #6: 0x00007fff449197d0 CarbonCore`FSNodeStorageGetAndLockCurrentUniverse + 83
    frame #7: 0x00007fff4491965a CarbonCore`FileIDTreeGetAndLockVolumeEntryForDeviceID + 38
    frame #8: 0x00007fff449195b7 CarbonCore`FSMount::FSMount(unsigned int, FSMountNumberType, int*, unsigned int const*) + 75
    frame #9: 0x00007fff44919531 CarbonCore`FSMountPrepare + 69
    frame #10: 0x00007fff5784aa30 CoreServicesInternal`MountInfoPrepare(void***, unsigned int, int, void*, unsigned int const*, __CFURL const*, __CFError**) + 43
    frame #11: 0x00007fff5784a428 CoreServicesInternal`parseAttributeBuffer(__CFAllocator const*, unsigned char const*, unsigned char, attrlist const*, void const*, void**, _FileAttributes*, unsigned int*) + 3209
    frame #12: 0x00007fff57849491 CoreServicesInternal`corePropertyProviderPrepareValues(__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 834
    frame #13: 0x00007fff578490ee CoreServicesInternal`prepareValuesForBitmap(__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 360
    frame #14: 0x00007fff5784ca0f CoreServicesInternal`_FSURLCopyResourcePropertyValuesAndFlags + 581
    frame #15: 0x00007fff4368f24b CoreFoundation`_CFURLCopyResourcePropertyValuesAndFlags + 127
    frame #16: 0x00007fff41bb6236 libFontParser.dylib`FPPathGetCatalogValues(char const*, FInfo*, unsigned long long*, unsigned long long*) + 187
    frame #17: 0x00007fff41bb3ec5 libFontParser.dylib`TFont::CreateFontEntities(char const*, bool, bool&, short, char const*, bool) + 85
    frame #18: 0x00007fff41bb664a libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, bool, short, char const*) + 264
    frame #19: 0x00007fff41b6649e libFontParser.dylib`FPFontCreateFontsWithPath + 158
    frame #20: 0x00007fff43a983b7 CoreGraphics`create_private_data_array_with_path + 29
    frame #21: 0x00007fff43a980bf CoreGraphics`CGFontCreateFontsWithPath + 26
    frame #22: 0x00007fff43a97ce9 CoreGraphics`CGFontCreateFontsWithURL + 345
    frame #23: 0x00007fff4528642b CoreText`CreateFontsWithURL(__CFURL const*, bool) + 199
    frame #24: 0x00007fff45368a4c CoreText`CTFontManagerCreateFontDescriptorsFromURL + 37
    frame #25: 0x0000000107ab625a systemfonts.so`addFontIndex(FontDescriptor*) + 378
    frame #26: 0x0000000107ab6c80 systemfonts.so`createFontDescriptor(__CTFontDescriptor const*) + 992
    frame #27: 0x0000000107ab72a8 systemfonts.so`getAvailableFonts() + 520
    frame #28: 0x0000000107aa6103 systemfonts.so`system_fonts() + 467

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.