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

Garbled text when using MS Gothic font #29

Closed
mistval opened this issue Dec 9, 2019 · 4 comments
Closed

Garbled text when using MS Gothic font #29

mistval opened this issue Dec 9, 2019 · 4 comments

Comments

@mistval
Copy link

mistval commented Dec 9, 2019

Hello,

I am seeing an issue when I try to use MS Gothic (installed by default in Windows 10). I have the following code:

library(showtext)
font_add("yxfont", "msgothic.ttc") # Using MS Gothic creates garbled labels on the plot
# font_add("yxfont", "arial.ttf") # Uncomment this to use Arial, and it works fine.
showtext_auto()

png(filename = 'testoutput.png', type = 'cairo', family = 'yxfont')
par(family="yxfont")

plot(1:10, 1:10, main = "ABC",)
points(c(6,2), c(2,1), pch = 3, cex = 4, col = "red")

The output PNG looks like this:

testoutput

I haven't seen this problem using other fonts.

Is this a bug?

Thank you for your work on this library.

@yixuan
Copy link
Owner

yixuan commented Dec 12, 2019

I can reproduce this issue and it seems to be a bug. In fact the pdf() device works fine but png() fails.

@mistval
Copy link
Author

mistval commented Dec 12, 2019

Thanks for checking. It looks like the jpeg() device also has the problem, but like you said pdf() seems okay. Do you have any ideas about workarounds? Using pdf() or a different font are the only workarounds I have found so far.

@yixuan
Copy link
Owner

yixuan commented Jan 27, 2020

Sorry for the late action. I finally located the cause of this bug. It was a very tricky issue of the FreeType library dealing with the MS Gothic font. I will submit the new version to CRAN soon, and it would be nice if you can test the master branch to see if it works for you.

@yixuan yixuan closed this as completed Jan 27, 2020
@mistval
Copy link
Author

mistval commented Jan 27, 2020

That's great news. I installed from the master branch and I can confirm that the issue is fixed in my test case. Thanks!

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