# Getting the boundary of fonts as points

**URL:** https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114
**Category:** General Usage
**Tags:** question, plotting, luxor
**Created:** [April 6, 2022, 5:00pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114 "2022-04-06T17:00:49Z")
**Posts on this page:** 9
**Page:** 1

<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: [April 6, 2022, 5:00pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/1 "2022-04-06T17:00:49Z")

</div>

I want to plot letters/fonts as curves, hence access to a more point-like representation.

I’m looking for a way to get a point[all pixels] or curve[boundary] representation of fonts maybe normalised within a unit box, not sure if here sizes between different fonts will change a lot. Any packages out there that might help will be appreciated? Thanks.

---

<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: [April 6, 2022, 5:55pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/2 "2022-04-06T17:55:56Z")

</div>

Probably use FreeType directly although getting the actual glyph data might need a bit of twiddling around with the C api.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 6, 2022, 6:17pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/3 "2022-04-06T18:17:12Z")

</div>

I think Harbuzz has an API for glyph outlines, and it has a prepackaged JLL binary for Julia: [JuliaHub](https://juliahub.com/ui/Packages/HarfBuzz_jll/h60co/2.8.1+1)

But maybe FreeType is easier given [https://github.com/JuliaGraphics/FreeType.jl](https://github.com/JuliaGraphics/FreeType.jl) … see also [cairo - How to get a glyph outline of a true type character on a linux system - Stack Overflow](https://stackoverflow.com/questions/2674070/how-to-get-a-glyph-outline-of-a-true-type-character-on-a-linux-system)

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 7, 2022, 2:36am UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/4 "2022-04-07T02:36:24Z")

</div>

> [@lazarusA](#):
>
> I want to plot letters/fonts as curves, hence access to a more point-like representation.

It looks like [Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl) may provide what you need with a nice high-level interface. For example, this gets a list of points outlining the letter “C” in the current font:

```julia
using Luxor
Drawing(500, 500)
newpath()
fontsize(60) # hide
textpath("C")
plist = reduce(vcat, pathtopoly())

```

---

<div class="post-metadata">

### Author: ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)
#### Post date: [April 7, 2022, 5:56am UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/5 "2022-04-07T05:56:37Z")

</div>

basic funtionality in [Cairo.jl/Samples.md at master · JuliaGraphics/Cairo.jl · GitHub](https://github.com/JuliaGraphics/Cairo.jl/blob/master/samples/Samples.md) copy\_path example.

And this doesn’t work on all fonts.

---

<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: [April 7, 2022, 6:07am UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/6 "2022-04-07T06:07:37Z")

</div>

Ohh… I like this approach and it seems to work really well. Thanks!

Edit: Trying for Latex strings with this approach doesn’t work. Maybe @cormullion ? any hints for a similar function for `textpath(L"\alpha")` ?

---

<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: [April 7, 2022, 10:21am UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/7 "2022-04-07T10:21:01Z")

</div>

This might be what you’re looking for:

```julia
using Luxor
using LaTeXStrings
using MathTeXEngine

@drawsvg begin
	background("black")
	fontsize(120)
	sethue("gold")
	text(L"e^{i\pi} + 1 = 0", Point(0, 0), halign=:center, paths=true)
	pts = pathtopoly()
	for pt in pts
		randomhue()
		poly(pt, :fill)
	end
end

```

 ![Screenshot 2022-04-07 at 11.18.11](https://global.discourse-cdn.com/julialang/original/3X/d/a/da9491c9b660f71c911a2cf2e5432eba8259e603.png)

Remember to pay attention to holes… 🙂

---

<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: [April 7, 2022, 12:59pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/8 "2022-04-07T12:59:34Z")

</div>

This is great! now these can go into RPRMakie! for raytracing 😃

---

<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: [April 7, 2022, 4:29pm UTC](https://discourse.julialang.org/t/getting-the-boundary-of-fonts-as-points/79114/9 "2022-04-07T16:29:59Z")

</div>

It will be Beautiful, with you in charge!😂
