# Unicode support for other fonts in Plots

**URL:** <https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [October 18, 2021, 12:31pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971 "2021-10-18T12:31:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 18, 2021, 12:31pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/1 "2021-10-18T12:31:34Z")

</div>

We can use unicode symbols in plots, like:

```julia
julia> plot(rand(10),label="π → 10⁻¹ ×")

```

![image](https://global.discourse-cdn.com/julialang/original/3X/7/1/71a3ded3061a1597bf97185e6a89fba81a7f8cb0.png)

However, if we change the fonts, most commonly that not this errors:

```julia
julia> plot(rand(10),label="π → 10⁻¹ ×",fontfamily="Computer Modern")
GKS: glyph missing from current font: 8315
GKS: glyph missing from current font: 185
GKS: glyph missing from current font: 8315
GKS: glyph missing from current font: 185
GKS: glyph missing from current font: 8315
GKS: glyph missing from current font: 185

```

![image](https://global.discourse-cdn.com/julialang/original/3X/2/a/2ae80cba14f6c46bf743465ccc407926267f95b2.png)

How/where is this supposed to be parsed and supported for different fonts? I am particularly interested in `Computer Modern`, as it would make plotting consistent plots using Latex even more practical.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [October 18, 2021, 3:13pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/2 "2021-10-18T15:13:36Z")

</div>

That’s what happens if you use a Unicode character that is not defined in the font you specify… To get these particular characters in a Computer Modern-like font you can use the CMU Serif from the [Computer Modern Unicode](https://cm-unicode.sourceforge.io/download.html) fonts. Another option is the [Latin Modern](http://www.gust.org.pl/projects/e-foundry/latin-modern) font.

Note that these fonts still miss a lot of Unicode characters… Have a look at [https://mono-math.netlify.app/](https://mono-math.netlify.app/) which I just updated to include CMU Typewriter Text and Latin Modern Mono (I think they have the same coverage as the proportional serif variants which you probably want).

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 18, 2021, 5:16pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/3 "2021-10-18T17:16:02Z")

</div>

I am having a hard time figuring out if it is possible to use other fonts in Plots (GR) apart from those in this list: [Fonts — GR Framework 0.66.0 documentation](https://gr-framework.org/fonts.html)

Is it?

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [October 18, 2021, 6:03pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/4 "2021-10-18T18:03:53Z")

</div>

I just tried with the second mono-math example (`∀x ∈ ℝ⁺, ∃n ∈ ℕ : n ≤ x < n+1`) which very few fonts can render properly.

Running

```julia
plot(1:3, label="∀x ∈ ℝ⁺, ∃n ∈ ℕ : n ≤ x < n+1", fontfamily="JuliaMono")

```

gives the expected output so yes, it’s possible to use other fonts. However it seems GR gets into a corrupted state if I make another `plot` call with a different `fontfamily`: I get a mix of two fonts, and later using again `fontfamily=JuliaMono` doesn’t work: I still get a mix of fonts.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 18, 2021, 6:28pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/5 "2021-10-18T18:28:47Z")

</div>

Are you sure it rendered with `JuliaMono` ? Here I get the correct characters:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/8/e80a980d5176843b8b76e12e920dde26fb2d62fc.png)

but I think that is just the default font.

Here I copied the same thing into inkscape and used JuliaMono on the upper text:

![image](https://global.discourse-cdn.com/julialang/original/3X/5/3/53bd39c73f75fb50ef563e54e4b95a4709cce0d4.png)

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [October 18, 2021, 6:39pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/6 "2021-10-18T18:39:34Z")

</div>

You’re right! It’s not JuliaMono. It’s very clear when using the greek letters `α β γ δ ϵ ε ζ η θ` which have a distinctive design in JuliaMono. I don’t know then which fallback font is used, and why the fallback is not used for Computer Modern (maybe Computer Modern actually defines these glyphs using the “undefined” symbol? That would be a bug I think).

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 18, 2021, 7:18pm UTC](https://discourse.julialang.org/t/unicode-support-for-other-fonts-in-plots/69971/7 "2021-10-18T19:18:20Z")

</div>

I think it falls back to the default font, `Helvetica` or something of the sort.
