Search code examples
rmacosplotunicodefonts

transgendered / hermaphrodite symbol in base R plot (and other rare unicode glyphs - macOs font problem)


I want to use male/female/transgendered/hermaphrodite symbols in base R plot.

This works for me with male and female symbols (male example below).

a = '\u2642'   # unicode for male (female = '\u2640')
plot(1, 1, pch = a)

male

With hermaphrodite/transgendered, I get a square.

a <- '\u26a5'  # unicode for hermaphrodite/transgendered 
plot(1, 1, pch = a)

hermaphrodite fail

> a
[1] "⚥"

According to what I had read elsewhere, this seemed like it could be a macOs-specific problem. Many other unicodes also failed and gave me the same square.


Solution

  • This was resolved by installing fonts that support transgendered/hermaphrodite unicode. A list of fonts reportedly supporting U+26A5 could be found in the link below.

    https://www.fileformat.info/info/unicode/char/26a5/fontsupport.htm

    I tried using DejaVu Sans (worked), Symbola (worked), and Code2000 (the version I installed did not work - seemingly without a working hermaphrodite symbol). These were downloaded from various sites on the internet and installed with Font Book. Here's a code with a usable font.

    a <- '\u26a5'  # unicode for hermaphrodite/transgendered 
    plot(1, 1, pch = a, family = "DejaVu Sans")
    

    enter image description here

    Here, pch could be replaced with likes of main, xlab, ylab, text, etc. There is no need for Cairo - a code for base R shown below works fine.

    jpeg("~/Desktop/test2a.jpeg")
    a <- '\u26a5' 
    plot(1, 1, main = a, family = "Symbola")
    dev.off()
    

    Hermaphrodite unicode is supported by few fonts. For most things, Arial Unicode MS works fine. List of characters and glyphs with Arial Unicode MS (38,917 characters and 38,917 glyphs).

    http://zuga.net/articles/unicode-all-characters-supported-by-the-font-arial-unicode-ms/