# Get fontsize in Luxor

**URL:** <https://discourse.julialang.org/t/get-fontsize-in-luxor/105084>\
**Category:** General Usage\
**Tags:** question, plotting, luxor\
**Created:** [October 17, 2023, 5:04pm UTC](https://discourse.julialang.org/t/get-fontsize-in-luxor/105084 "2023-10-17T17:04:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [October 17, 2023, 5:04pm UTC](https://discourse.julialang.org/t/get-fontsize-in-luxor/105084/1 "2023-10-17T17:04:29Z")

</div>

How do I get the font size that has been set with the `setfont` function?  
The function `get_fontsize` gives me the size that has been set with the `fontsize` function.

---

<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 17, 2023, 5:33pm UTC](https://discourse.julialang.org/t/get-fontsize-in-luxor/105084/2 "2023-10-17T17:33:56Z")

</div>

I don’t know. If there’s an answer, it will be in the Cairo.jl package, which I don’t understand.

Some clues to start you off:

`Luxor.setfont(f, n)` calls Cairo::

```julia
function set_font_face(ctx::CairoContext, str::AbstractString)
    fontdesc = ccall((:pango_font_description_from_string,libpango),
                     Ptr{Nothing}, (Ptr{UInt8},), String(str))
    ccall((:pango_layout_set_font_description,libpango), Nothing,
          (Ptr{Nothing},Ptr{Nothing}), ctx.layout, fontdesc)
    ccall((:pango_font_description_free,libpango), Nothing,
          (Ptr{Nothing},), fontdesc)
end

```

`Luxor.fontface(f)` calls Cairo:

```julia
function select_font_face(ctx::CairoContext,family::AbstractString,slant,weight)
    ccall((:cairo_select_font_face, libcairo),
          Nothing, (Ptr{Nothing}, Ptr{UInt8},
                 font_slant_t, font_weight_t),
          ctx.ptr, String(family),
          slant, weight)
end

```

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [October 22, 2023, 1:36am UTC](https://discourse.julialang.org/t/get-fontsize-in-luxor/105084/3 "2023-10-22T01:36:43Z")

</div>

Thank you. That is a good starting point.

---

<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, 2023, 3:08pm UTC](https://discourse.julialang.org/t/get-fontsize-in-luxor/105084/4 "2023-10-22T15:08:20Z")

</div>

Oh, I also found this function:

```julia
Luxor.Cairo.get_layout_size((currentdrawing()).cr)

```

which looks like it returns some kind of Pango layout dimensions:

```julia
julia-1.10> setfont("", 30)

julia-1.10> w, h = Luxor.Cairo.get_layout_size(currentdrawing().cr)
2-element Vector{Int32}:
  0
 30

```
