Is it possible to convert typed text with the font-face (Trace them?) into a PKDrawing to use in a PencilKit app?

Hi,

I have been learning PencilKit, and playing around with the code sample from the WWDC20 talk #10148: https://developer.apple.com/videos/play/wwdc2020/10148/

Read the forum: https://developer.apple.com/forums/tags/wwdc20-10148

and as much documentation as I could ...

But I haven't found an API in PencilKit to use ... to convert typed text (with a selected font-face ... say Times New Roman) --> into a PKDrawing stroke path ...

Think Adobe Illustrator where you can select typed text, with a font-face ... and then choose to convert it into a path ... strokes ...

And I would like to do the same operation with the typed text, with a font-face ... but into a PKDrawing canvas instead ... as a stroke path ...

So I can get access to the stroke data ... and manipulate it with the pen ...

And I don't want to manually hand draw letter shapes in "Times New Roman" face ... or "Verdana" :-) ... like the Apple dev that wrote the sample code: https://developer.apple.com/forums/thread/650272

That is ... defenitly not the route I'd like to go down ...

Has someone any Idea how ... maybe ... I can "trace" a font-faced-text into PKDrawing strokes? :-)

cheers, Daniel.

Answered by danalien in 678921022

hmm,

I have investigated / researched a bit more ... TL:DR ... I guess I will have to go down the "draw my own strokes" ... and create some sort of "Stroke based font file in a PKDrawing file-type format" ... to use for what I want to make.

If you are a bit like me, and would like to understand why? ... please open a document in a vector app (I used Affinity Designer...) and type a text ... and Outline it / "Convert it to Curves" ... and analyze what you get (see attached image).

Take the letter H in my case ... it's a shape ... that has an outline stroke that goes around in the canvas to make up a shape we understand as the letter H ... it's not "just a stroke" from the middle ... as when we write with our pencil on an iPad or for that matter with a pen on a piece of paper ...

After I outlined the text ... I used some help guides to manually draw some strokes with the pen-tool in the middle of the outlined shapes ... and gave these strokes a thickness ... so it looks to the eyes as the font-face letters do. And in the end the blue (bottom) looks like the green (top) ...

And in this case, I've chosen a "simple font-face" ... image if I'd gone with a Times New Roman font-face :-)

Accepted Answer

hmm,

I have investigated / researched a bit more ... TL:DR ... I guess I will have to go down the "draw my own strokes" ... and create some sort of "Stroke based font file in a PKDrawing file-type format" ... to use for what I want to make.

If you are a bit like me, and would like to understand why? ... please open a document in a vector app (I used Affinity Designer...) and type a text ... and Outline it / "Convert it to Curves" ... and analyze what you get (see attached image).

Take the letter H in my case ... it's a shape ... that has an outline stroke that goes around in the canvas to make up a shape we understand as the letter H ... it's not "just a stroke" from the middle ... as when we write with our pencil on an iPad or for that matter with a pen on a piece of paper ...

After I outlined the text ... I used some help guides to manually draw some strokes with the pen-tool in the middle of the outlined shapes ... and gave these strokes a thickness ... so it looks to the eyes as the font-face letters do. And in the end the blue (bottom) looks like the green (top) ...

And in this case, I've chosen a "simple font-face" ... image if I'd gone with a Times New Roman font-face :-)

Is it possible to convert typed text with the font-face (Trace them?) into a PKDrawing to use in a PencilKit app?
 
 
Q