daqana / tikzDevice

A R package for producing graphics output as PGF/TikZ code for use in TeX documents.
https://daqana.github.io/tikzDevice
132 stars 26 forks source link

tikzDevice hang afte measuring dimensions correctly #155

Closed jszhao closed 6 years ago

jszhao commented 7 years ago

Here is a mini example:

library(tikzDevice)
options(tikzDefaultEngine = "xetex")
options(tikzXelatexPackages = c(getOption("tikzXelatexPackages"),
                                "\\setmainfont{Times New Roman}\n",
                                "\\usepackage[math-style=TeX]{unicode-math}\n",
                                "\\setmathfont{Times New Roman}\n",
                                "\\usepackage{xeCJK}\n", 
                                "\\setCJKmainfont{SimHei}\n\n"
                                ))
tikz('Fig2-a.tex', standAlone = TRUE, width=4, height=4)
plot(1:10, type = "n", xlab = "", ylab = "模式")
text(5,2, "江汉平原")
dev.off()

R output the following message:

> tikz('Fig2-a.tex', standAlone = TRUE, width=4, height=4)
> plot(1:10, type = "n", xlab = "", ylab = "模式")
Measuring dimensions of:  2
Measuring dimensions of:  4
Measuring dimensions of:  6
Measuring dimensions of:  8
Measuring dimensions of:  10
Measuring dimensions of:  模式
Warning message:
In getMetricsFromLatex(TeXMetrics, verbose = verbose) :
  XeLaTeX was unable to calculate metrics for some characters:
         Missing character: There is no 模 in font ecrm1000!
         Missing character: There is no 式 in font ecrm1000!
> text(5,2, "江汉平原")
Measuring dimensions of:  江汉平原
Measuring dimensions of: \char27743
Measuring dimensions of: \char27721
Measuring dimensions of: \char24179
Measuring dimensions of: \char21407

At here, R hanged forever, with full CPU utilization. I check the temp file tikzStringWidthCalc.tex and tikzStringWidthCalc.log, and confirmed that the correct size is obtained.

I don't know what's the problem.

jszhao commented 7 years ago

please refer to the comment at https://github.com/yihui/tikzDevice/issues/157.

krlmlr commented 6 years ago

Thanks. Closing in favor of #157.