r-lib/ragg

"Tofu" when newline character is at the edge of character string

long39ng opened this issue · 2 comments

The ragg png device produces a "tofu" symbol when there is a newline character (\n) at the beginning or the end of a text string.

This does not happen with the Cairo png device.

library(ggplot2)

#+ dev = "ragg_png"
ggplot() +
  geom_text(aes(x = 0, y = 0, label = "\n")) +
  labs(x = "\nat the beginning", y = "at the end\n")

#+ dev = "png", dev.args = list(type = "cairo-png")
ggplot() +
  geom_text(aes(x = 0, y = 0, label = "\n")) +
  labs(x = "\nat the beginning", y = "at the end\n")

Created on 2022-04-13 by the reprex package (v2.0.1)

hmm - I'm not able to reproduce this. Can you share what system you are running on?

Sorry for not being specific in the original description.

I have encountered this on Ubuntu 21.10 and Ubuntu 20.04.