# Oddly rotated labels using GLMakie

**URL:** <https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [June 4, 2021, 3:18pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394 "2021-06-04T15:18:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [June 4, 2021, 3:18pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/1 "2021-06-04T15:18:38Z")

</div>

When I create a plot with GLMakie, the labels are all rotated in an odd way. Here’s the legend of a plot I tried to make recently:

![image](https://global.discourse-cdn.com/julialang/original/3X/8/6/86985a82c6155abe2e9cfeedff376db96dc85b85.png)

It’s the same for all of the axis labels, too.

What’s weird is that this plot was working just fine a week ago. I’ve tried downgrading GLMakie, but that hasn’t seemed to help.

Has anyone else experienced this?

Thanks!

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 4, 2021, 3:25pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/2 "2021-06-04T15:25:16Z")

</div>

Do you have an MWE that’s easy to reproduce this issue?

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [June 4, 2021, 3:43pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/3 "2021-06-04T15:43:24Z")

</div>

I just made a fresh environment, added GLMakie (though the version it grabbed was already installed of course), and then did:

```julia
using GLMakie
lines(1:5)

```

And I got this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/2/725ee70f92cf7ebc5808fc9202a0fdcf3697856c.jpeg)

I had tried deleting `~/.julia/makiegallery`. Is there some other cache I can clear out?

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [June 4, 2021, 3:47pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/4 "2021-06-04T15:47:37Z")

</div>

I suspect the odd glyph rotations are the same as what was happening [here](https://github.com/JuliaPlots/WGLMakie.jl/issues/106). I think I tracked down the issue to a problem of changing backend back and forth between WGLMakie and CairoMakie, but I’m not managing to reproduce it now…

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 4, 2021, 3:48pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/5 "2021-06-04T15:48:21Z")

</div>

Ah yeah, this could be a caching issue…Try:  
`dirname(GLMakie.AbstractPlotting.get_cache_path())`  
Or on a newer version:  
`dirname(GLMakie.Makie.get_cache_path())`

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [June 4, 2021, 3:57pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/6 "2021-06-04T15:57:25Z")

</div>

I cleared the cache, and at first I was able to make the simple `lines(1:5)` plot successfully. Then I ran my actual script, and the problem returned.

Interestingly, my script does jump back and forth between using CairoMakie and GLMakie, which sounds similar to what @piever was talking about.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [June 4, 2021, 4:45pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/7 "2021-06-04T16:45:17Z")

</div>

I’m having the same issue, and indeed is also happening when going back and forth between GLMakie and CairoMakie.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 4, 2021, 4:51pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/8 "2021-06-04T16:51:07Z")

</div>

Hm there was indeed an issue with going back and forth between GLMakie/WGLMakie and CairoMakie … I did think we fixed that though 😅  
Cairo does mutate the fonts rotation matrix, so, if you ran some cairo code with the fonts that are shared with GLMakie, and then GLMakie created the text atlas with those mutated fonts, it can mess up the text atlas…

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [June 4, 2021, 9:33pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/9 "2021-06-04T21:33:30Z")

</div>

+1 for cashing issue. I had this happen after a recashing of fonts, for a specifik font only. No package upgrade.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 8, 2021, 9:16pm UTC](https://discourse.julialang.org/t/oddly-rotated-labels-using-glmakie/62394/10 "2021-06-08T21:16:14Z")

</div>

I managed to create an MWE for this, but not sure how to fix it cleanly:

> <https://github.com/MakieOrg/Makie.jl/issues/1033>
>
> Managed to create an MWE for Cairo messing with GLMakie's font atlas:
> 
> \`\`\`juli…a
> using CairoMakie
> using FreeTypeAbstraction
> using Colors
> using Cairo 
> dfont = findfont("Dejavu Sans")
> bitmap, extent = renderface(dfont, '5', 64)
> display(Gray.(bitmap./255))
> \`\`\`
> !\[image\](https://user-images.githubusercontent.com/1010467/121258381-1c9fd180-c8af-11eb-85bf-c3881fad52d1.png)
> 
> \`\`\`julia
> function mwe(ctx, font)
> Cairo.save(ctx)
> cairoface = CairoMakie.set\_ft\_font(ctx, font)
> Cairo.rotate(ctx, 0.5)
> Cairo.text\_path(ctx, "5")
> CairoMakie.cairo\_font\_face\_destroy(cairoface)
> Cairo.rotate(ctx, 0.0)
> Cairo.restore(ctx)
> end
> 
> surf = Cairo.CairoARGBSurface(500, 500)
> ctx = Cairo.CairoContext(surf)
> mwe(ctx, dfont)
> \`\`\`
> \`\`\`julia
> dfont = findfont("Dejavu Sans")
> bitmap, extent = renderface(dfont, '5', 64)
> display(Gray.(bitmap./255))
> \`\`\`
> !\[image\](https://user-images.githubusercontent.com/1010467/121258431-2d504780-c8af-11eb-9019-6d3450416791.png)
> 
> But no idea how to cleanly stop cairo from doing this... Maybe easiest would be to copy the fonts?
> Fun fact: my google skills aren't good enough to figure out how to copy fonts with FreeType, so the copy solution would mean, we need to somehow save the path with the font and load it from there as a copy...Or something like that.
