Non-English text rendering in image (e.g., png) through rapache

Skip to first unread message

Hiroki Oura

Feb 18, 2016, 11:19:29 AM2/18/16
to rapache
Hi All,

I am using rapache to generate images in my web application on ubuntu server and need your help or any clue to figure out the reason for this text rendering issue. For example, I can generate a png image with some Japanese text like below without a problem on R console, but cannot render only the Japanese part when processing the code through rapache ("some" rendered correctly but 日本語 rendered as dots ...) on the same machine (ubuntu server).

x <- c(3,4,5)
hist(x, main="some 日本語")

At first, I tried specifying the font family explicitly with e.g., par(family="Japan1") and also using extrafont library, but it didn't fix the problem. Precisely, I can see the font family change, but the Japanese part still becomes dots.  Next, I thought it might come from some environment variable issue like LANGUAGE and R_USER, but it didn't fix yet even if I set it explicitly in Renviron in the same way with running R console, confirming the env. variables are properly set e.g., with message(Sys.getenv()["R_USER"]. Then, I suspected some permission issue and tried enforcing an apparmor profile with unconfined permissions using RAppArmor library, but no luck. 

I am guessing this issue comes from some rendering process rather than rapache itself, but did any of you have a similar experience like this when generating images through rapache? I would be grateful for any clue or comment.


Hiroki Oura

Feb 23, 2016, 5:24:55 PM2/23/16
to rapache
Found the solution.

The problem was "encoding" - Encoding(POST) gives "unknown" - so I set Encoding(POST$data) <- "UTF-8" in my case and Japanese texts were rendered properly.

Reply all
Reply to author
0 new messages