text to path maker
this is a pure flutter and dart package that allows you to convert text–both characters and icons–into paths. it can generate svg path strings and flutter path objects too.
additionally, this package offers a bunch of methods you can use to animate those paths.
at the core of this package is a .ttf file parser, written in pure dart. you can, if you want to, use it to read the font tables present in your truetype font file.
getting started
you must always start by calling the parsettfasset()
method available in the pmfontreader
class to parse your font asset. currently, only .ttf files are supported.
once the font has been parsed, you’ll have access to a pmfont
object. you can call its generatepathforcharacter()
method to convert any character into a path
object. note that this method expects you to pass the character code of the character.
next, you’ll want to use the pmtransform.moveandscale()
method to position and scale the path. this is usually necessary because, by default, the paths can be quite large.
at this point, you can render the path
object onto any canvas
object. if you want to animate the path, however, you must call the pmpieces.breakintopieces()
method. this method splits the path into tiny paths, depending on the precision
you specify. these tiny paths, when rendered sequentially, will create the illusion of the character being drawn.
there’s also a utility pmpainter
class, which extends the custompainter
class. you can use this to quickly render your animation using a custompaint
widget.
refer to the example code to learn more.
Comments are closed.