showtext icon indicating copy to clipboard operation
showtext copied to clipboard

Support contextual alternates

Open emiltb opened this issue 5 years ago • 1 comments

I stumpled on this, when trying to display text from my Datalegreya package. The Datalegreya font uses Contextual Alternates to elegantly make axis labels on plots. If I try to do this with showtext, the result is not rendered correctly. I created an issue for reference in my own package (https://github.com/emiltb/datalegreyar/issues/1). The following simple example illustrates the problem:

library(ggplot2)
library(showtext)
#> Loading required package: sysfonts
#> Loading required package: showtextdb

font_add("Datalegreya", "Datalegreya-Gradient.otf")
showtext_auto()

ggplot() +
  annotate("text", x = 0, y = 0, label = "{2008 }d|0a|1t|2a|2l|3e|3g|3r|2e|2y|1a|0{2018 }[2    [0    ]", family = "Datalegreya", size = 12) +
  theme_void()

Created on 2018-07-09 by the reprex package (v0.2.0).

The expected result is text looking like this:

datalegreya

emiltb avatar Jul 09 '18 12:07 emiltb

This looks like an advanced feature of the font, and I'll see if it is possible in showtext. Do you know any existing R graphics device that can handle this?

yixuan avatar Oct 12 '18 17:10 yixuan