-
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Problems with registering Roboto Condensed on macOS #18
Comments
I run this pkg every day on macOS without issue
…On Sat, May 6, 2017 at 16:00 Paolo Antonini ***@***.***> wrote:
I suggest integrating the following piece of code in the
import_roboto_condensed() function, after running extrafont::font_import()
:
d <- read.csv(extrafont:::fonttable_file(), stringsAsFactors = FALSE)d[grepl("Light", d$FontName), ]$FamilyName <- font_rc_light # "Roboto Condensed Light"
write.csv(d, extrafont:::fonttable_file(), row.names = FALSE)
extrafont::loadfonts()
What the code does is to change the family of Roboto Condensed Light and
Roboto Condensed Light Italic stored in the fonttable CSV file from Roboto
Condensed to Roboto Condensed Light. This operation is needed, because
otherwise extrafont::loadfonts() would detect duplicate fonts, and it
would be impossible to export a plot (e.g., through ggsave()).
This solves problems similar to #2
<#2>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#18>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAfHtqht0dS45Sl0edm8Jd4T-WW9-oBPks5r3NFUgaJpZM4NS44V>
.
|
I see, and I understand that the behaviour is weird. I'll go through the passages I did and my understanding of the issue, in the hope this is of help. In the case I did anything wrong in the installation of the package, which in turn may generate the error, just let me know. Not workingIf I run the following lines to install and test the package, the plot is rendered correctly in a Quartz window, but it won't export to a PDF (or any other format). Notice in particular the output to > install.packages("extrafontdb") # reset fonttable
# ...
> devtools::install_github("hrbrmstr/hrbrthemes", force = TRUE)
# ...
> hrbrthemes::import_roboto_condensed()
You will likely need to install these fonts on your system as well.
You can find them in [/Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed]
> extrafont::loadfonts()
More than one version of regular/bold/italic found for Roboto Condensed. Skipping setup for this font.
> library(hrbrthemes)
> library(ggplot2)
> ggplot(mtcars, aes(mpg, wt)) +
+ geom_point(aes(color=factor(carb))) +
+ labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
+ title="Seminal ggplot2 scatterplot example",
+ subtitle="A plot that is only useful for demonstration purposes",
+ caption="Brought to you by the letter 'g'") +
+ scale_color_ipsum() +
+ theme_ipsum_rc()
> ggsave("test.pdf")
Saving 7 x 7 in image
Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
In addition: There were 50 or more warnings (use warnings() to see the first 50)
> warnings()
Warning messages:
1: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font family 'Roboto Condensed' not found in PostScript font database
# ...
32: In grid.Call(C_textBounds, as.graphicsAnnot(x$label), ... :
font family 'Roboto Condensed Light' not found in PostScript font database
# ...
> The current > extrafont:::fonttable()
package afmfile
1 NA RobotoCondensed-Bold.afm.gz
2 NA RobotoCondensed-BoldItalic.afm.gz
3 NA RobotoCondensed-Italic.afm.gz
4 NA RobotoCondensed-Light.afm.gz
5 NA RobotoCondensed-LightItalic.afm.gz
6 NA RobotoCondensed-Regular.afm.gz
fontfile
1 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Bold.ttf
2 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-BoldItalic.ttf
3 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Italic.ttf
4 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Light.ttf
5 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-LightItalic.ttf
6 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Regular.ttf
FullName FamilyName FontName Bold Italic Symbol afmsymfile
1 Roboto Condensed Bold Roboto Condensed RobotoCondensed-Bold TRUE FALSE FALSE NA
2 Roboto Condensed Bold Italic Roboto Condensed RobotoCondensed-BoldItalic TRUE TRUE FALSE NA
3 Roboto Condensed Italic Roboto Condensed RobotoCondensed-Italic FALSE TRUE FALSE NA
4 Roboto Condensed Light Roboto Condensed RobotoCondensed-Light FALSE FALSE FALSE NA
5 Roboto Condensed Light Italic Roboto Condensed RobotoCondensed-LightItalic FALSE TRUE FALSE NA
6 Roboto Condensed Regular Roboto Condensed RobotoCondensed-Regular FALSE FALSE FALSE NA
> I understand that the problem stands in the fact that there is a conflict between Roboto Condensed Regular and Roboto Condensed Light, because they both are non-bold, non-italic fonts in the same family.
The same conflict exists between Roboto Condensed Italic and Roboto Condensed Light Italic, as they are non-bold, italic fonts in the same family. WorkingInstead, when I run the following, I am able to export correctly the plot. > install.packages("extrafontdb") # reset fonttable
# ...
> devtools::install_github("hrbrmstr/hrbrthemes", force = TRUE)
# ...
> hrbrthemes::import_roboto_condensed()
You will likely need to install these fonts on your system as well.
You can find them in [/Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed]
> library(hrbrthemes)
> # MY SUGGESTED CODE #####################################
> d <- read.csv(extrafont:::fonttable_file(), stringsAsFactors = FALSE)
> d[grepl("Light", d$FontName),]$FamilyName <- font_rc_light
> write.csv(d,extrafont:::fonttable_file(), row.names = FALSE)
> #########################################################
> extrafont::loadfonts()
Registering font with R using pdfFonts(): Roboto Condensed
Registering font with R using pdfFonts(): Roboto Condensed Light
> library(ggplot2)
> ggplot(mtcars, aes(mpg, wt)) +
+ geom_point(aes(color=factor(carb))) +
+ labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
+ title="Seminal ggplot2 scatterplot example",
+ subtitle="A plot that is only useful for demonstration purposes",
+ caption="Brought to you by the letter 'g'") +
+ scale_color_ipsum() +
+ theme_ipsum_rc()
> ggsave("test.pdf")
Saving 7 x 7 in image
> In the code above, > extrafont:::fonttable()
package afmfile
1 NA RobotoCondensed-Bold.afm.gz
2 NA RobotoCondensed-BoldItalic.afm.gz
3 NA RobotoCondensed-Italic.afm.gz
4 NA RobotoCondensed-Light.afm.gz
5 NA RobotoCondensed-LightItalic.afm.gz
6 NA RobotoCondensed-Regular.afm.gz
fontfile
1 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Bold.ttf
2 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-BoldItalic.ttf
3 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Italic.ttf
4 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Light.ttf
5 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-LightItalic.ttf
6 /Library/Frameworks/R.framework/Versions/3.4/Resources/library/hrbrthemes/fonts/roboto-condensed/RobotoCondensed-Regular.ttf
FullName FamilyName FontName Bold Italic Symbol afmsymfile
1 Roboto Condensed Bold Roboto Condensed RobotoCondensed-Bold TRUE FALSE FALSE NA
2 Roboto Condensed Bold Italic Roboto Condensed RobotoCondensed-BoldItalic TRUE TRUE FALSE NA
3 Roboto Condensed Italic Roboto Condensed RobotoCondensed-Italic FALSE TRUE FALSE NA
4 Roboto Condensed Light Roboto Condensed Light RobotoCondensed-Light FALSE FALSE FALSE NA
5 Roboto Condensed Light Italic Roboto Condensed Light RobotoCondensed-LightItalic FALSE TRUE FALSE NA
6 Roboto Condensed Regular Roboto Condensed RobotoCondensed-Regular FALSE FALSE FALSE NA
> BottomlineAgain, I understand that the behaviour of my installation is weird, also because I couldn't find almost any reference about similar situations on the web. I hope that this was of help for you; should you need any further information to understand and troubleshoot the problem, I'll be happy to help you. In case I did anything wrong that prevents the correct installation of the package, just let me know. |
Can confirm this behavior and that the fix is working on Ubuntu 14.04.5 |
Hmm... I cannot seem to get either Roboto Condensed ( I appear to get the above behavior as @AntoniniP describes when first installing the font. After relabling as he recommends, I can run extrafont::loadfonts() and no longer get the message:
but instead see that it sets up the pdf fonts:
Unfortunately, I still cannot export the image to PDF, though I have no trouble with png format. This gets me to a place where instead of the error on creating a PDF (also the same as @AntoniniP gets):
that things run without throwing any error; but the linux box results in a serifed font that is clearly not Roboto, while the Mac results in pdf figures that simply lack any text elements. Color me confused. Debian linux result I'm seeing should at least be pretty reproducible e.g. fire up a |
Looks like my problems with getting the wrong font but not getting an error might be related to the font not getting embedded into the PDF; so some pdf displays (Mac Preview) show it with no fonts, others (RStudio's built-in pdf preview) pull in some other font. Playing around with I forget the current status of default on Cairo graphics compiling with R, and rmarkdown/rstudio/knitr's preferred defaults for how it chooses pdf (vaguely recall it all being Cairo / vector pdf by default...). Will explore more. |
Any headway on this problem? My Win 10 machine does all of the above listed problems. If @AntoniniP workaround it will print to PDF, but like @cboettig I get some other font pulled in. |
I'll see if I can get some time on my Windows VM to debug it better. (I realize I've said the following before) I literally use this every single day on Ubuntu and macOS and generate a ton of both PNGs and PDFs for our various internal departments and the fonts never fail to work. |
Hi all, Just an update that I've found for Win 10 users. When I went and looked in C:\Windows\Fonts it would show only one listing of Roboto. But when I went in with cmd, I noticed more versions (probably because I was accidentally installing it multiple times.) I deleted manually in cmd (running as administrator; Once I was sure all my versions of Roboto were deleted, I went into ~\R\R-3.5.2\library\hrbrthemes\fonts\roboto-condensed and manually installed only one version of Roboto Condensed. Then Threw |
Can also confirm this behaviour on OS 10.14.5 despite thinking I'd installed everything correctly. Used the workaround above which solved the issue. So thank you for that. |
@AntoniniP's fix works for me as well on macOS 10.13.6. |
I am running into the same issue, I cannot get
|
adding |
The same issue under WLS1 with Ubuntu 18.04.4 LTS while rendering into PNG file. Workaround by OP works. |
FWIW, I just had this happen to me on a Mac - and yes, the Roboto Condensed Light font was registered as part of the Roboto Condensed family, creating an entry that looked duplicated to the device/grid/wherever the font selection happens. The solution was to manually edit the fonttable CSV as per #18 (comment). To see where this happened, I then cleared the extrafont db database and imported all Roboto fonts from my system library instead, with Roboto Condensed freshly downloaded from Google Fonts. Now, the Roboto Condensed Light font and its sibling showed up in their own family called "Roboto Condensed Light". Grid throws some errors about unknown font width, but after embedding the fonts using When I retried this with hrbrthemes - clearing extrafont DB again and calling So the solution might simply be replacing the font files in EDIT: the PDF created using the current font files from Google is not in fact fine - non-Latin characters (with diacritics) end up on top of each other. This does not happen using the font files currently in the pacakage. So the solution might be edit the fonttable CSV in |
Hello, |
I also got this error while running the example in a Jupyter notebook, even after installing the Roboto Condensed family. Works in the console, and OP's hack also works. |
@AntoniniP's solution followed by @hamedkhe's (I.e., installing the fonts directly from Google) works in 2023 on macOS 13.2.1 too. It might work to combine these solutions as well, i.e., installing fonts from https://fonts.google.com/specimen/Roboto+Condensed (rather than the package files) right after |
I suggest integrating the following piece of code in the
import_roboto_condensed()
function, after runningextrafont::font_import()
:What the code does is to change the family of Roboto Condensed Light and Roboto Condensed Light Italic stored in the
fonttable
CSV file fromRoboto Condensed
toRoboto Condensed Light
. This operation is needed, because otherwiseextrafont::loadfonts()
would detect duplicate fonts, and it would be impossible to export a plot (e.g., throughggsave()
).This solves problems similar to #2.
The text was updated successfully, but these errors were encountered: