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

Font handling is strange? #51

Closed
psobolewskiPhD opened this issue Jan 31, 2021 · 14 comments
Closed

Font handling is strange? #51

psobolewskiPhD opened this issue Jan 31, 2021 · 14 comments

Comments

@psobolewskiPhD
Copy link

I originally reported this as an issue with the {sftheme}
amirmasoudabdol/sfthemes#3
This is occurring with
When using this theme that uses the Inter family of fonts, everything works well, except for a strange issue where ggplot legend title doesn't respect the font settings.
The wrong face is used for the bold legend title in VS Code WebView or in Chrome, as well as when saved to png. (Incidentally, in Mac OS Safari I don't get any of the text elements in Inter...)
plot
Here's the output from ggsave():
test

I have the whole Inter family installed, MacOS Big Sur, M1, using {systemfonts} and {extrafont} if that helps.

@nx10
Copy link
Owner

nx10 commented Jan 31, 2021

Thank you for reporting, I will look into it.

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

I just updated the font handling can you try the newest development version from github?

Plots do look a bit broken for me with that package on any graphics device:

image

(This is with the R studio GD)

@psobolewskiPhD
Copy link
Author

On my end, the test plot

ggplot(mtcars) +
   geom_point(aes(x = wt, y = mpg, colour = factor(gear))) +
   labs(title = "Fuel Economy",
        subtitle = "Fuel economy declines as weight increases, 1973-74",
        caption = "Data from the 1974 Motor Trend US magazine.",
        x = "Weight (1000 lbs)",
        y = "MPG",
        colour = "Gears") +
   facet_grid(vs ~ am) +
   sf_set_inter(theme_linedraw()) +
   scale_colour_ios_light()

looks correct in VS Code (and Chrome)
plot
This is with the save to PNG in httpgd. Resolution lower than ggsave() but the font handling appears correct and the behavior is proper with (+)/zoom.

BTW in Safari now the fonts are even more interesting:
plot-2
The font is not respected anywhere but the Legend title?

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

Can you attach the SVG file?

@psobolewskiPhD
Copy link
Author

Here's the dark theme with bumping the font size up:
PNG from VS Code (using the icon in httpgd)
plot
SVG from safari (zipped, apparently not supported by GitHub)
plot-2.svg.zip

PNG from Safari (using the icon in httpgd)
plot-3

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

It seems like Safari can not find the "Inter" font on your computer. Have you tried restarting your computer?
You can also embed it into the SVGs if you start httpgd with:

hgd(extra_css = "@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');")

@psobolewskiPhD
Copy link
Author

So doing:
httpgd::hgd(extra_css = "@import url('https://fonts.googleapis.com/css2?family=Inter&display=swap');")
gives me a blank screen in VS Code and Safari and Chrome...
I'm pretty sure I've restarted numerous times since installing Inter, but probably not since installing the sfthemes and httpgd? Can't be sure..

@psobolewskiPhD
Copy link
Author

I'm going to restart VS Code et al. and see what that does. (sometimes I still get the blank canvas in httpgd randomly).

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

If you have used the script of Kun Ren for using httpgd in vscode, make sure to add the extra_css argument to the hgd(..., extra_css = ...) call in your .Rprofile

The blank screen issue is most likely this #50 bug in R itself which will be fixed in the upcoming R version.

@psobolewskiPhD
Copy link
Author

psobolewskiPhD commented Feb 2, 2021

OK! I'll try that—will it make all plots render with Inter? I actually prefer Fira, just noticed this strange issue with this theme that uses Inter...
Edit: using {firatheme} which is my default Safari also doesn't render it.
Chrome is fine, likewise when switching back to Inter.

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

The extra_css argument will just include an URL for Inter as a source in all plots, in case that font is used but not available.

@psobolewskiPhD
Copy link
Author

Thanks for the info.
Honestly, I never use Safari for this stuff, just VS Code and the issues seem resolved there.
I rather control the font in the theme/ggplot call and not at the .Rprofile level, so I think the current behavior is fine.
Now I'm getting broken PDFs generated via ggsave() with this {sftheme} so something else seems to be an issue...

@nx10
Copy link
Owner

nx10 commented Feb 2, 2021

Thank you for for your reports, yes it does seem like sftheme is a bit unstable at the moment.
Glad it works as expected in vscode now!

@psobolewskiPhD
Copy link
Author

No no, thank you for httpgd which is legit awesome and for being patient with me and my crappy issues!

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