* Returns a flat array of path commands that describe the outlines of a string of text. * * Each command is represented as an array of the form `[type, ...coords]`, where: * - `type` is one of `'M'`, `'L'`, `'Q'`, `'C'`, or `'Z'`, * - `coords` are the numeric values needed for that comma
(str, x, y, width, height, options)
| 191 | * } |
| 192 | */ |
| 193 | textToPaths(str, x, y, width, height, options) { |
| 194 | |
| 195 | ({ width, height, options } = this._parseArgs(width, height, options)); |
| 196 | |
| 197 | if (!this.data) { |
| 198 | throw Error('No font data available for "' + this.name |
| 199 | + '"\nTry downloading a local copy of the font file'); |
| 200 | } |
| 201 | |
| 202 | // lineate and get glyphs/paths for each line |
| 203 | let lines = this._lineateAndPathify(str, x, y, width, height, options); |
| 204 | |
| 205 | // flatten into a single array containing all the glyphs |
| 206 | let glyphs = lines.map(o => o.glyphs).flat(); |
| 207 | |
| 208 | // flatten into a single array with all the path commands |
| 209 | return glyphs.map(g => g.path.commands).flat(); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Returns an array of points outlining a string of text written using the |
no test coverage detected