(str, x, y, width, height, options)
| 774 | } |
| 775 | |
| 776 | _textToPathPoints(str, x, y, width, height, options) { |
| 777 | |
| 778 | ({ width, height, options } = this._parseArgs(width, height, options)); |
| 779 | |
| 780 | // lineate and get the points for each line |
| 781 | let cmds = this.textToPaths(str, x, y, width, height, options); |
| 782 | |
| 783 | // divide line-segments with intermediate points |
| 784 | const subdivide = (pts, pt1, pt2, md) => { |
| 785 | if (fn.dist(pt1.x, pt1.y, pt2.x, pt2.y) > md) { |
| 786 | let middle = { x: (pt1.x + pt2.x) / 2, y: (pt1.y + pt2.y) / 2 }; |
| 787 | pts.push(middle); |
| 788 | subdivide(pts, pt1, middle, md); |
| 789 | subdivide(pts, middle, pt2, md); |
| 790 | } |
| 791 | }; |
| 792 | |
| 793 | // a point for each path-command plus line subdivisions |
| 794 | let pts = []; |
| 795 | let { textSize } = this._pInst._renderer.states; |
| 796 | let maxDist = (textSize / this.data.head.unitsPerEm) * 500; |
| 797 | |
| 798 | for (let i = 0; i < cmds.length; i++) { |
| 799 | let { type, data: d } = cmds[i]; |
| 800 | if (type !== 'Z') { |
| 801 | let pt = { x: d[d.length - 2], y: d[d.length - 1] }; |
| 802 | if (type === 'L' && pts.length && !options?.nodivide > 0) { |
| 803 | subdivide(pts, pts[pts.length - 1], pt, maxDist); |
| 804 | } |
| 805 | pts.push(pt); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | return pts; |
| 810 | } |
| 811 | |
| 812 | _parseArgs(width, height, options = {}) { |
| 813 |
nothing calls this directly
no test coverage detected