@pantoken/icon-font 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +11 -7
  2. package/package.json +2 -1
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ import svg2ttf from "svg2ttf";
6
6
  import ttf2woff2 from "ttf2woff2";
7
7
  import ClipperLib from "clipper-lib";
8
8
  import { pointsOnPath } from "points-on-path";
9
+ import svgpath from "svgpath";
9
10
  //#region src/outline.ts
10
11
  /**
11
12
  * Turn an icon SVG into a single **filled** glyph path (what a font glyph needs). Fill-based icons
@@ -113,13 +114,16 @@ function svgToGlyphPath(svg) {
113
114
  height
114
115
  };
115
116
  const offset = new ClipperLib.ClipperOffset(2, .25);
116
- for (const sub of subpaths) for (const poly of pointsOnPath(sub.d, .2, .2)) {
117
- if (poly.length < 2) continue;
118
- const path = poly.map(([x, y]) => ({
119
- X: Math.round(x * SCALE),
120
- Y: Math.round(y * SCALE)
121
- }));
122
- offset.AddPath(path, ClipperLib.JoinType.jtRound, sub.closed ? ClipperLib.EndType.etClosedLine : ClipperLib.EndType.etOpenRound);
117
+ for (const sub of subpaths) {
118
+ const flattened = svgpath(sub.d).unarc().abs().round(3).toString();
119
+ for (const poly of pointsOnPath(flattened, .2, .2)) {
120
+ if (poly.length < 2) continue;
121
+ const path = poly.map(([x, y]) => ({
122
+ X: Math.round(x * SCALE),
123
+ Y: Math.round(y * SCALE)
124
+ }));
125
+ offset.AddPath(path, ClipperLib.JoinType.jtRound, sub.closed ? ClipperLib.EndType.etClosedLine : ClipperLib.EndType.etOpenRound);
126
+ }
123
127
  }
124
128
  const solution = new ClipperLib.Paths();
125
129
  offset.Execute(solution, strokeWidth / 2 * SCALE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pantoken/icon-font",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Build an installable Instructure icon font (WOFF2 + TTF) with CSS and codepoints — stroke glyphs outlined to fills.",
5
5
  "homepage": "https://pantoken.iywahl.com",
6
6
  "bugs": "https://github.com/thedannywahl/pantoken/issues",
@@ -36,6 +36,7 @@
36
36
  "points-on-path": "catalog:",
37
37
  "svg2ttf": "catalog:",
38
38
  "svgicons2svgfont": "catalog:",
39
+ "svgpath": "catalog:",
39
40
  "ttf2woff2": "catalog:"
40
41
  },
41
42
  "devDependencies": {