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

Issue with some unicode not rendering #35

Closed
ghost opened this issue Apr 20, 2018 · 4 comments
Closed

Issue with some unicode not rendering #35

ghost opened this issue Apr 20, 2018 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 20, 2018

Hi,

I'm trying to create a PDF file in which I am using some wingding font within my chart, and it's not rendering properly when I'm knitting it. This wasn't an issue until switching from MikTex to tinytex.

---
title: "Untitled"
output: pdf_document
---

```{r}
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp)) + geom_point(shape = sprintf("\u2714"), size = 3)
```

The plot with the code above looks fine when I run the plot in R, but I get the following warning message when I knit it:

Warning in grid.Call.graphics(C_points, x$x, x$y, x$pch, x$size):
conversion failure on '✔' in 'mbcsToSbcs': dot substituted for < e2>
Warning in grid.Call.graphics(C_points, x$x, x$y, x$pch, x$size):
conversion failure on '✔' in 'mbcsToSbcs': dot substituted for <9c>
Warning in grid.Call.graphics(C_points, x$x, x$y, x$pch, x$size):
conversion failure on '✔' in 'mbcsToSbcs': dot substituted for <94>
Warning in grid.Call.graphics(C_points, x$x, x$y, x$pch, x$size): font
metrics unknown for Unicode character U+2714

The plot gets rendered, but instead of checkmarks, I get "...".

I assume the issue is just a missing latex package, but I'm not sure which one I need to download to fix it.

EDIT: Please note that I added a space between "<" and "e2>" in the warning message above. Oddly the text disappears without that space.

@yihui
Copy link
Member

yihui commented Apr 20, 2018

I'm pretty sure this issue has nothing to do with tinytex or MiKTeX. The problem is from R, not LaTeX.

Please see the section "Encoding of multibyte characters" at https://yihui.name/knitr/demo/graphics/

@yihui yihui closed this as completed Apr 20, 2018
@ghost
Copy link
Author

ghost commented Apr 20, 2018

Hi Yihui,

Thanks for pointing me in the right direction - Unfortunately, the various solutions proposed there did not work. Should I open an issue in the knitr repo?

@yihui
Copy link
Member

yihui commented Apr 20, 2018

The default LaTeX engine pdflatex is not good at dealing with Unicode characters. You may try xelatex instead:

---
title: "Untitled"
output:
  pdf_document:
    latex_engine: xelatex
---

```{r dev='cairo_pdf'}
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp)) + geom_point(shape = sprintf("\u2714"), size = 3)
```

@ghost
Copy link
Author

ghost commented Apr 20, 2018

Thank you very much for your help, Yihui. xelatex did the trick.

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

1 participant