wch / extrafont

Tools for using fonts in R graphics
312 stars 49 forks source link

Correctly finds font directory, but says "No FontName. Skipping" for all fonts #88

Closed wzbillings closed 1 year ago

wzbillings commented 2 years ago

I've installed extrafont and all of the dependencies, but whenever I try to run font_import(), my font directory is detected as C:\Windows\Fonts, but every font in the list just says "No FontName. Skipping" instead of being imported. I have no idea what the issue here is, as I have rtools40 and I have tried uninstalling and then reinstalling the package and its dependencies, as well as running Rstudio as administrator (my account also has admin status). My session info printout is below. Any help is appreciated.

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] 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] extrafont_0.17

loaded via a namespace (and not attached):
[1] compiler_4.1.0  tools_4.1.0     extrafontdb_1.0 Rttf2pt1_1.3.9 
beanumber commented 2 years ago

See #32 .

I have the same problem on Ubuntu 20.04. In #32 the problem is traced to Rttf2pt1, but I had this working on this same machine before upgrading Ubuntu and R to 4.1.

@wch this renders extrafont useless -- what can we do about this? I tried some of the proposed solutions but they didn't work. I don't think this is a permissions issue.

wzbillings commented 2 years ago

Interestingly, it works fine on my office machine which is also running Windows 10 and R 4.1.0. SessionInfo for this machine:

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] 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] extrafont_0.17

loaded via a namespace (and not attached):
[1] compiler_4.1.0  tools_4.1.0     extrafontdb_1.0 Rttf2pt1_1.3.8 

The two differences I notice are that my office machine is running Windows 10 x64 build 19043 (as opposed to 19042) and Rttf2pt1_1.3.8 rather than Rttf2pt1_1.3.9. I'll try downgrading Rttf2pt1/updating Windows when I get a chance. I guess the issue could also be something more esoteric that is not returned by SessionInfo, and I'm happy to provide any more information that could be useful.

wzbillings commented 2 years ago

I installed Rttf2pt1 using remotes::install_version("Rttf2pt1", version = "1.3.8") on my home machine, and now extrafont::font_import() is working correctly (on Windows 10 64-bit build 19042).

montesmariana commented 2 years ago

I installed Rttf2pt1 using remotes::install_version("Rttf2pt1", version = "1.3.8") on my home machine, and now extrafont::font_import() is working correctly (on Windows 10 64-bit build 19042).

I had the same issue: everything was working fine until I installed R 4.1.0, and font_import() returned this message. @wz-billings 's solution fixed it for me too, on Windows 10 64-bit build 19043. Thank you!!

beanumber commented 2 years ago

Confirmed! Downgrading to 1.3.8 fixed my problem on Ubuntu as well. Thanks @wz-billings !

rayuto029 commented 2 years ago

Had the same issue on my office machine, @wz-billings´ solution fixed the problem. Thank you very much, dude!

ypc971579376 commented 2 years ago

how to downgrade to 1.3.8 ? @wz-billings´

I installed Rttf2pt1 using remotes::install_version("Rttf2pt1", version = "1.3.8") on my home machine, and now extrafont::font_import() is working correctly (on Windows 10 64-bit build 19042).

ypc971579376 commented 2 years ago

when I run remotes::install_version("Rttf2pt1", version = "1.3.8")
it show @wz-billings´

Warning messages: 1: In missing_devel_warning(pkgdir) : Package Rttf2pt1 has compiled code, but no suitable compiler(s) were found. Installation will likely fail. Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH. 2: In i.p(...) : installation of package ‘C:/Users/amd/AppData/Local/Temp/RtmpIHZ0vY/remotes5dc40c76e85/Rttf2pt1’ had non-zero exit status

ypc971579376 commented 2 years ago

then i installed Rtools and run remotes::install_version("Rttf2pt1", version = "1.3.8") ,but another problem occured :@wz-billings´, can you help me?

Error in download_version_url(package, version, repos, type) : version '1.3.8' is invalid for package 'Rttf2pt1'

ypc971579376 commented 2 years ago

then I try to install 1.3.7,the same warning accured:

Warning messages: 1: In missing_devel_warning(pkgdir) : Package Rttf2pt1 has compiled code, but no suitable compiler(s) were found. Installation will likely fail. Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH. 2: In i.p(...) : installation of package ‘C:/Users/amd/AppData/Local/Temp/RtmpIHZ0vY/remotes5dc76d04bfe/Rttf2pt1’ had non-zero exit status

wzbillings commented 2 years ago

then I try to install 1.3.7,the same warning accured:

Package Rttf2pt1 has compiled code, but no suitable compiler(s) were found. Installation will likely fail. Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH.

Did you add Rtools to the PATH? You can follow the instructions here

ypc971579376 commented 2 years ago

then I try to install 1.3.7,the same warning accured: Package Rttf2pt1 has compiled code, but no suitable compiler(s) were found. Installation will likely fail. Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH.

Did you add Rtools to the PATH? You can follow the instructions here

it worked,wow,thanks very much,so kind of you!!!

rizqrama commented 2 years ago

Excuse me, I tried to downgrade the version of Rttf2pt 1, but then another issues coming which says

Error in ttf_extract(ttfiles) : lazy-load database 'C:/Users/Asus/Documents/R/win-library/4.1/Rttf2pt1/R/Rttf2pt1.rdb' is corrupt In addition: Warning messages: 1: In ttf_extract(ttfiles) : restarting interrupted promise evaluation 2: In ttf_extract(ttfiles) : internal error -3 in R_decompress1

I used R 4.10 on Windows 10-64 build 19043.

Thank you!

rizqrama commented 2 years ago

Excuse me, I tried to downgrade the version of Rttf2pt 1, but then another issues coming which says

Error in ttf_extract(ttfiles) : lazy-load database 'C:/Users/Asus/Documents/R/win-library/4.1/Rttf2pt1/R/Rttf2pt1.rdb' is corrupt In addition: Warning messages: 1: In ttf_extract(ttfiles) : restarting interrupted promise evaluation 2: In ttf_extract(ttfiles) : internal error -3 in R_decompress1

I used R 4.10 on Windows 10-64 build 19043.

Thank you!

Solved. I tried to reinstall extrafont package first, and then installed the downgraded version of Rttf2pt1. Sorry for the inconvenience

microly commented 2 years ago

remove.packages("Rttf2pt1") remotes::install_version("Rttf2pt1", version = "1.3.8")

I used R 4.11 on Windows 10-64. It works! Thanks!

HamsomeWANG commented 2 years ago

@wzbillings Hi, I am using R 4.0.5 and RStudio 1.4.1106 based on Windows NT 10.0 x64. I also encountered the "No FontName" Issue when dealing with 'extrafont' package, and based on your kind solutions proposed above, I now know that I should downgrade my Rttf2pt1 1.3.9 to 1.3.8. HOWEVER, I CANNONT successfully do the downgrade! I tried automatic download via RStudio, manually install the tar.gz file (downloaded from CRAN), and by using the the 'remotes' package. BUT ALL OF THESE APPROACHES yielded the same error message below:

Downloading package from url: https://cran.rstudio.com//src/contrib/Archive/Rttf2pt1/Rttf2pt1_1.3.8.tar.gz Installing package into ‘C:/Users/ThinkPad/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified)

Could you kindly offer me any suggestions? In great need of extra fonts!

wzbillings commented 2 years ago

The error message says you should install Rtools and add it to the path, so I would try doing that. 

jpgoldberg commented 2 years ago

Just confirming the same problem (and work-around) for macOS 12.1 (Monterey with Apple Silicon) and R 4.1.1

> R.Version()$version.string
[1] "R version 4.1.1 (2021-08-10)"
> R.Version()$platform
[1] "aarch64-apple-darwin20"

Using the work-around mentioned in previous comments

remotes::install_version("Rttf2pt1", version = "1.3.8")

to downgrade Rttf2pt1 to version 1.3.8 worked for me. That install mechanism will probably not work for those who do not have all of the required development tools installed on their system.

jpgoldberg commented 2 years ago

Quoting from the README at https://github.com/wch/Rttf2pt1

Note 2021-07-19: ttf2pt1 has not been maintained since 2003, and it is getting increasingly difficult to make it compile without significant warnings on modern compilers, which in turn is making it difficult to maintain this package on CRAN. It is possible that in the future, I will not have time to keep this package on CRAN.

That repo has an issue filed about this specific problem. https://github.com/wch/Rttf2pt1/issues/10

msberends commented 2 years ago

Can this please be fixed? StackOverflow also has multiple mentions now. Rttf2pt1 v1.3.9 introduced a nasty bug which prevents knitting to PDF to print plot labels of system font. Downgrading to v1.3.8 does not sound like a reasonable solution to me 🙂

Reference:

wch commented 2 years ago

For a little context around Rttf2pt1, which is a wrapper around ttf2pt1: ttf2pt1 itself has not had any development activity in 19 years, and compiling ttf2pt1 results many compiler warnings. Most of them are innocuous. Every so often, the CRAN maintainers change their standards about which warnings count as "significant warnings". If a package has significant warnings, they will remove that package from CRAN. I occasionally get messages from them saying they will remove Rttf2pt1 from CRAN unless various significant warnings are fixed. I fix them to the best of my ability, but it is possible that some of the fixes have introduced bugs. If someone wants to step up and take over maintenance of Rttf2pt1, I would welcome that change.

msberends commented 2 years ago

In that case, it might be worth something to rely on the {showtext} pkg as part of phasing out? It seems to provide this exact function as well.

BerriJ commented 2 years ago

In that case, it might be worth something to rely on the {showtext} pkg as part of phasing out? It seems to provide this exact function as well.

Are you sure that showtext can be a drop-in replacement of extrafont? I briefly looked over the issues and it seems that ggplot2 would greatly benefit from this being solved: https://github.com/yixuan/showtext/issues/1

However, I cannot assess whether this also holds true for extrafont or not.

hummuscience commented 1 year ago

@msberends showtext works well if you don't care about editing the text afterwards (with Inkscape, for example) as it converts text to vector graphics. extrafont keeps it as text in a PDF export which allows further editing.

wzbillings commented 1 year ago

version 1.3.8 of Rttf2pt1 still does exactly what it needs to, so unless someone is willing to take over maintenance of that package or of ttf2pt1, I don't see the utility of this discussion.

denghb001 commented 1 year ago

将Rttf2pt1降级到1.3.8后,导入字体就没有问题啦 remove.packages("Rttf2pt1") remotes::install_version("Rttf2pt1", version = "1.3.8") extrafont::font_import()

我在win10上用的R 4.2.0 最后成功了 Found FontName for 220 fonts. Scanning afm files in C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/metrics Writing font table in C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/fontmap/fonttable.csv Writing Fontmap to C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/fontmap/Fontmap...

sessionInfo() R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8
[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.utf8

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

loaded via a namespace (and not attached): [1] pillar_1.7.0 compiler_4.2.0 BiocManager_1.30.18 prettyunits_1.1.1 remotes_2.4.2
[6] tools_4.2.0 extrafont_0.18 pkgbuild_1.3.1 lifecycle_1.0.1 tibble_3.1.7
[11] gtable_0.3.0 pkgconfig_2.0.3 rlang_1.0.2 DBI_1.1.2 cli_3.3.0
[16] Rttf2pt1_1.3.8 withr_2.5.0 dplyr_1.0.9 stringr_1.4.0 generics_0.1.2
[21] vctrs_0.4.1 grid_4.2.0 tidyselect_1.1.2 glue_1.6.2 R6_2.5.1
[26] processx_3.5.3 fansi_1.0.3 ggplot2_3.3.6 purrr_0.3.4 callr_3.7.0
[31] extrafontdb_1.0 magrittr_2.0.3 scales_1.2.0 ps_1.7.0 ggthemes_4.2.4
[36] ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-3 utf8_1.2.2 stringi_1.7.6
[41] munsell_0.5.0 crayon_1.5.1

HamsomeWANG commented 1 year ago

建议收到,非常感谢!祝好 :)-------- 原始邮件 --------发件人: denghb001 @.>日期: 2022年11月17日周四 16:44收件人: wch/extrafont @.>抄送: HamsomeWANG @.>, Comment @.>主 题: Re: [wch/extrafont] Correctly finds font directory, but says "No FontName. Skipping" for all fonts (#88)

将Rttf2pt1降级到1.3.8后,导入字体就没有问题啦

remove.packages("Rttf2pt1")

remotes::install_version("Rttf2pt1", version = "1.3.8")

extrafont::font_import()

我在win10上用的R 4.2.0

最后成功了

Found FontName for 220 fonts.

Scanning afm files in C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/metrics

Writing font table in C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/fontmap/fonttable.csv

Writing Fontmap to C:/Users/86182/AppData/Local/R/win-library/4.2/extrafontdb/fontmap/Fontmap...

sessionInfo()

R version 4.2.0 (2022-04-22 ucrt)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:

[1] LC_COLLATE=Chinese (Simplified)_China.utf8 LC_CTYPE=Chinese (Simplified)_China.utf8

[3] LC_MONETARY=Chinese (Simplified)_China.utf8 LC_NUMERIC=C

[5] LC_TIME=Chinese (Simplified)_China.utf8

attached base packages:

[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):

[1] pillar_1.7.0 compiler_4.2.0 BiocManager_1.30.18 prettyunits_1.1.1 remotes_2.4.2

[6] tools_4.2.0 extrafont_0.18 pkgbuild_1.3.1 lifecycle_1.0.1 tibble_3.1.7

[11] gtable_0.3.0 pkgconfig_2.0.3 rlang_1.0.2 DBI_1.1.2 cli_3.3.0

[16] Rttf2pt1_1.3.8 withr_2.5.0 dplyr_1.0.9 stringr_1.4.0 generics_0.1.2

[21] vctrs_0.4.1 grid_4.2.0 tidyselect_1.1.2 glue_1.6.2 R6_2.5.1

[26] processx_3.5.3 fansi_1.0.3 ggplot2_3.3.6 purrr_0.3.4 callr_3.7.0

[31] extrafontdb_1.0 magrittr_2.0.3 scales_1.2.0 ps_1.7.0 ggthemes_4.2.4

[36] ellipsis_0.3.2 assertthat_0.2.1 colorspace_2.0-3 utf8_1.2.2 stringi_1.7.6

[41] munsell_0.5.0 crayon_1.5.1

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

msberends commented 1 year ago

Please don’t spam here, and explain what you do when posting code. Thanks.

wzbillings commented 1 year ago

@wch is it possible to lock this thread? the solution still works and I don't see any reason to continue discussion if no one is volunteering to maintain the package.