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

showtext and RStudioGD #7

Closed
jolars opened this issue Mar 13, 2016 · 7 comments
Closed

showtext and RStudioGD #7

jolars opened this issue Mar 13, 2016 · 7 comments

Comments

@jolars
Copy link

@jolars jolars commented Mar 13, 2016

showtext does not work with RStudio's built-in graphics device, despite working flawlessly with windows(). It might for example look like this:

Imgur

This is a known issue, but has not yet been fixed.

@yixuan
Copy link
Owner

@yixuan yixuan commented Mar 14, 2016

I guess it's a bit complicated. RStudio's internal graphics device actually consists of two devices: one used to fast preview and the other for the real rendering of graphics. showtext can only affect one of them which results in the failure of using showtext.

@jolars
Copy link
Author

@jolars jolars commented Mar 15, 2016

I see, that's too bad. Can you think of any solution or should I close this down?

@yixuan
Copy link
Owner

@yixuan yixuan commented Mar 20, 2016

I would keep it as an open issue, which reminds me of this problem. 😄

@benjaminrobinson
Copy link

@benjaminrobinson benjaminrobinson commented Jul 3, 2017

Any update on this issue?

@yixuan
Copy link
Owner

@yixuan yixuan commented Aug 7, 2017

@benjaminrobinson I apologize for my non-response. I haven't found a way to solve this issue yet, so you still need to manually open new graphics devices to make showtext work.

@yixuan
Copy link
Owner

@yixuan yixuan commented May 2, 2020

Hi All,

I just figured out a workaround for this issue. The solution is actually simple: before you create plots, run the following code in the RStudio session:

trace(grDevices::png, exit = quote({
    showtext::showtext_begin()
}), print = FALSE)

Note that this will enable showtext for the RStudio graphics device even if you haven't called showtext_auto(). To turn off, use

untrace(grDevices::png)

Please let me know if this works for you.

@yixuan
Copy link
Owner

@yixuan yixuan commented Aug 22, 2020

The new version (0.9) has already solved this issue.

@yixuan yixuan closed this Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.