Page 1 of 1

Render TextBlock characters along a path

Posted: 09 Aug 2021, 13:57
by steveh
Hi guys,

We have just been asked to implement a TextBlock such that it follows an arc. For example, I just mocked up the following image in Photoshop which is the effect we're after:
TextAlongPath.png
Looking online, I don't see an easy way to do this. My current thought is to split each character into a separate Run element and then define the location of that inline to be placed along a spline.

Can you think of an easier way to achieve this? Is there some solution we could achieve entirely in the SDF text renderer? Could we define the arc as a cbuffer parameter in a custom shader and render it in a bespoke way?

Any input would be greatly appreciated! Cheers,

-Steven

Re: Render TextBlock characters along a path

Posted: 09 Aug 2021, 16:26
by jsantos
I think the best solution for this is creating a UserControl and overriding the OnRender method to render each glyph at the desired orientation and position. Something similar to this

https://docs.microsoft.com/en-us/archiv ... h-with-wpf

We can help you with this as I think this is something we could include as part of our application framework.

Re: Render TextBlock characters along a path

Posted: 11 Aug 2021, 11:08
by steveh
Awesome, cheers for the pointer Jesús. I'll take a look at this when I get a spare moment.

-Steven

Re: Render TextBlock characters along a path

Posted: 11 Aug 2021, 12:55
by jsantos
Thanks Steven, please keep us posted to help you.