yixuan / showtext

Using Fonts More Easily in R Graphs
http://cran.r-project.org/web/packages/showtext/index.html
475 stars 38 forks source link

Arabic Text Support #55

Open iyedg opened 2 years ago

iyedg commented 2 years ago

When trying to use Arabic text in a ggplot, it usually functions normally (as shown in my first example without showtext). However, using a font family with showtext I get a problem where arabic text gets split into individual letters and are reversed. Any idea if there are transofrmations I should do to how I normally load fonts for latin scripts ?

Thank you for the effort you put in this library!

library(magrittr)
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)

airquality %>%
  ggplot(aes(x = Day, y = Temp)) +
  geom_point() +
  scale_y_continuous(position = "right") +
  labs(
    title = "الحب سماء لا تمطر غير الأحلام",
    y = "الحرارة",
    x = "اليوم"
  ) +
  theme(
    axis.title.y.left = element_blank(),
    plot.title = element_text(hjust = 1),
  )

Created on 2022-01-16 by the reprex package (v2.0.1.9000)

Standard output and standard error ``` sh -- nothing to show -- ```
library(magrittr)
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)
library(showtext)
#> Loading required package: sysfonts
#> Loading required package: showtextdb

showtext_auto()
font_add_google("Tajawal", "tajawal")

airquality %>%
  ggplot(aes(x = Day, y = Temp)) +
  geom_point() +
  scale_y_continuous(position = "right") +
  labs(
    title = "الحب سماء لا تمطر غير الأحلام",
    y = "الحرارة",
    x = "اليوم"
  ) +
  theme(
    axis.title.y.left = element_blank(),
    plot.title = element_text(hjust = 1, family = "tajawal"),
  )

Created on 2022-01-16 by the reprex package (v2.0.1.9000)

riyadh-radhi commented 3 months ago

I'm having similar issues. It would be great if someone has hints on how to solve this. Thanks!