Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: tilde path expansion #1

Closed
r2evans opened this issue Jun 9, 2015 · 3 comments
Closed

request: tilde path expansion #1

r2evans opened this issue Jun 9, 2015 · 3 comments

Comments

@r2evans
Copy link

r2evans commented Jun 9, 2015

I haven't used sysfonts directly, but I'm playing around with showtext -- I think it's a very helpful tool, and I'll likely work it into some of my projects. Thanks!

This issue was "triggered" by showtext but traces down to this package. When I was testing showtext with a font I have in a project directory, I tried to load a font using a tilde-path, and it failed:

library(showtext)
font.add('xkcd', '~/Documents/Projects/GRUMPs/Logo/xkcd.ttf')
## Error in font.add("xkcd", "~/Documents/Projects/GRUMPs/Logo/xkcd.ttf") : 
##   freetype: cannot open resource, error code 1

It works fine if I use the full path myself or use normalizePath() (or even path.expand()) manually. (The problem appears to arise from sysfonts:::.check.font.dir() taking the path literally.)

Even though it's mostly cosmetic, any issues with including normalizePath() in .check.font.path()? Alternatively, would including it in showtext::font.add() be better?

sessionInfo()
## R version 3.2.0 (2015-04-16)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 8 x64 (build 9200)
##
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] 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] showtext_0.4-2 sysfonts_0.5   r2_0.4.15     
##
## loaded via a namespace (and not attached):
## [1] compiler_3.2.0  tools_3.2.0     htmltools_0.2.6 showtextdb_1.0 
## [5] rmarkdown_0.6.1 digest_0.6.8   
@yixuan
Copy link
Owner

yixuan commented Jun 9, 2015

Thank you for the report. This seems to be a real problem. I'll take a look and fix it in the next version.

@r2evans
Copy link
Author

r2evans commented Jun 9, 2015

I wasn't certain if this fits better in .check.font.path or if that function should assume that all paths are already normalized. If that is the case, perhaps the change should go in showtext.

@yixuan
Copy link
Owner

yixuan commented Jun 9, 2015

Actually font.add() is also a function contained in sysfonts, not showtext.
I would prefer adding normalizePath() inside .check.font.path, since it provides more convenience to the user.
Thanks for the catch!

@yixuan yixuan closed this as completed in 22d5401 Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants