# How to make numbers/texts appear as one single text object in Makie?

**URL:** <https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977>\
**Category:** Visualization\
**Tags:** plotting, makie\
**Created:** [November 8, 2023, 10:51pm UTC](https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977 "2023-11-08T22:51:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yhchang96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yhchang96/32/36499_2.png) [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Post date:** [November 8, 2023, 10:51pm UTC](https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977/1 "2023-11-08T22:51:14Z")

</div>

When I generate vector graphics using `CairoMakie`, very often in the output figure (in `.pdf`) the axis numbers, labels and text (using `text!()` or `Label()`) consists of numbers and words which are ‘disconnected’ when I inspect the figure in Illustrator or Inkscape. By ‘disconnected’, I mean I can’t select the whole number or text as one single text object. Instead, they appear as separate text object. For example, when I create the following figure:

```julia
using CairoMakie, Pkg

Pkg.status(["CairoMakie"]) #v0.10.7

function create_demo(savename; font="Arial")

    set_theme!()
    update_theme!(Theme(fonts = (; regular = font)))

    fig = Figure(resolution=(1000,400))
    ax1 = Axis(fig[1,1])

    x1 = range(0, 1, length=101)
    y1 = sin.(x1)

    lines!(ax1, x1, y1)
    text!(ax1, 0.05, 0.95, text="label for testing", space=:relative)

    save(savename*".pdf", fig, pt_per_unit=1)
    
    return fig
end

@time create_demo("testing")

```

When I open it in Illustrator, I can’t highlight the whole ‘0.0’ in the x-axis label. ‘0.’ appear as one object, and the decimal ‘0’ appear as a separate object. Same when I just to select the text ‘label for testing’. The five alphabets in ‘label’ appear as five separate text, then ‘for’ as one text, ‘sting’ as one text. Sometimes it does output the whole thing as one text, e.g. ‘1.0’.

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

My question is are there ways to make it output each set of words or numbers as one text object? How does the program determine this?

---

<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:** [November 9, 2023, 5:43am UTC](https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977/2 "2023-11-09T05:43:27Z")

</div>

I think we’d need to refactor CairoMakie to use [cairo-show-text-glyphs](https://www.cairographics.org/manual/cairo-text.html#cairo-show-text-glyphs) with text clusters.

---

<div class="post-metadata">

**Author:** ![yhchang96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yhchang96/32/36499_2.png) [@yhchang96](https://discourse.julialang.org/u/yhchang96)\
**Post date:** [November 9, 2023, 2:35pm UTC](https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977/3 "2023-11-09T14:35:41Z")

</div>

So basically if I want the words to appear as one single cluster, right now there is no way to control it unless I change them manually through third party software like Illustrators. Is this correct (at least in the immediate future)?

---

<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:** [November 9, 2023, 7:13pm UTC](https://discourse.julialang.org/t/how-to-make-numbers-texts-appear-as-one-single-text-object-in-makie/105977/4 "2023-11-09T19:13:57Z")

</div>

Right. In principle Makie should be using established text layouting tools like Pango and Harfbuzz, this would automatically do the clustering right in Cairo as well. Not sure when I’ll have the time to take a look at this though, and it hasn’t mattered much for my own projects. Although to be fair, neither do I use right-to-left scripts, complex ligatures, or emojis 🙂
