# Luxor and Unicode

**URL:** <https://discourse.julialang.org/t/luxor-and-unicode/121587>\
**Category:** General Usage\
**Created:** [October 22, 2024, 12:17pm UTC](https://discourse.julialang.org/t/luxor-and-unicode/121587 "2024-10-22T12:17:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [October 22, 2024, 12:17pm UTC](https://discourse.julialang.org/t/luxor-and-unicode/121587/1 "2024-10-22T12:17:32Z")

</div>

Is there a way to represent the unicode `⇐` (\u21D0) etc in a Luxor plot? I guess I need to specifiy an adequate typeface, but is is annoying that the repl and jupyter show what I want for the Array A, but not Luxor, not even in png raster format. Any suggestion ?

```julia
using Luxor

function drawmatrix(A::Matrix;
        cellsize = (10, 10))
    table = Table(size(A)..., cellsize...)
    used = Set()
    for i in CartesianIndices(A)
        r, c = Tuple(i)
        @show A[r,c]
        text(A[r, c], table[r, c],
            halign=:center,
            valign=:middle)
        sethue("white")
        box(table, r, c, action = :stroke)
    end
end

A = Any["1" "2" "3" "4" "5" "6"; "1⇐" "6⇒" "1⇒" "4⇐" "3⇒" "2⇐"; "15⇑" "" "15⇓" "1⇑" "14⇓" "2⇑"]

@png begin
    fontface("Arial")
    background("black")
    fontsize(30)
    setline(0.5)
    sethue("white")
    drawmatrix(A, cellsize = 20 .* size(A))
end

```

 ![Untitled](https://global.discourse-cdn.com/julialang/original/3X/1/f/1fb050bd09150e98c47b0c1ea7c6e07c7570ed79.png)

---

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [October 22, 2024, 1:11pm UTC](https://discourse.julialang.org/t/luxor-and-unicode/121587/2 "2024-10-22T13:11:22Z")

</div>

I did it the hard way: looking into the fonts installed on my system and “cut/pasting” `⇐`  
into the preview option for each font until I found a font that was able to display the arrow (here “Lucida Sans Unicode”). Not nice but at least I have a solution

```julia
using Luxor

function drawmatrix(A::Matrix;
        cellsize = (10, 10))
    table = Table(size(A)..., cellsize...)
    used = Set()
    for i in CartesianIndices(A)
        r, c = Tuple(i)
        @show A[r,c]
        text(A[r, c], table[r, c],
            halign=:center,
            valign=:middle)
        sethue("white")
        box(table, r, c, action = :stroke)
    end
end

A = Any["1" "2" "3" "4" "5" "6"; "1⇐" "6⇒" "1⇒" "4⇐" "3⇒" "2⇐"; "15⇑" "" "15⇓" "1⇑" "14⇓" "2⇑"]

@png begin
    fontface("Lucida Sans Unicode")
    background("black")
    fontsize(30)
    setline(0.5)
    sethue("white")
    drawmatrix(A, cellsize = 20 .* size(A))
end

```

 ![Untitled](https://global.discourse-cdn.com/julialang/original/3X/e/7/e7ad1bac07b33d856ecc29dee6e1418e1b5511f4.png)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [October 22, 2024, 1:24pm UTC](https://discourse.julialang.org/t/luxor-and-unicode/121587/3 "2024-10-22T13:24:59Z")

</div>

Font fallback is great in most environments, finding a font with the required glyph automatically fo you, but I don’t think Cairo does it. 😟

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 22, 2024, 3:09pm UTC](https://discourse.julialang.org/t/luxor-and-unicode/121587/4 "2024-10-22T15:09:47Z")

</div>

You can check here how Makie does this, you can test programmatically if some font has a given glyph [Makie.jl/src/utilities/texture\_atlas.jl at 6dfb420445065c56f5af7944c87ecdfc22eff507 · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/blob/6dfb420445065c56f5af7944c87ecdfc22eff507/src/utilities/texture_atlas.jl#L255-L266)
