svg2font-cli 1.0.1 → 1.0.2
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.
- package/lib/cli.js +37 -37
- package/lib/index.js +36 -36
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -170,7 +170,7 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
170
170
|
display: none;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
/*
|
|
173
|
+
/* Page layout */
|
|
174
174
|
.main {
|
|
175
175
|
padding: 30px 100px;
|
|
176
176
|
width: 960px;
|
|
@@ -235,14 +235,14 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
.icon_lists .svg-icon {
|
|
238
|
-
/*
|
|
238
|
+
/* Change icon size by setting font-size */
|
|
239
239
|
width: 1em;
|
|
240
|
-
/*
|
|
240
|
+
/* Vertical alignment when icon is adjacent to text */
|
|
241
241
|
vertical-align: -0.15em;
|
|
242
|
-
/*
|
|
242
|
+
/* Change SVG color/fill by setting color */
|
|
243
243
|
fill: currentColor;
|
|
244
|
-
/* path
|
|
245
|
-
normalize.css
|
|
244
|
+
/* Hide path and stroke overflow outside viewBox in IE
|
|
245
|
+
This is also included in normalize.css */
|
|
246
246
|
overflow: hidden;
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -497,7 +497,7 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
497
497
|
text-decoration: underline;
|
|
498
498
|
}
|
|
499
499
|
|
|
500
|
-
/*
|
|
500
|
+
/* Code highlighting */
|
|
501
501
|
/* PrismJS 1.15.0
|
|
502
502
|
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
|
|
503
503
|
/**
|
|
@@ -729,19 +729,19 @@ ${unicodeIcons}
|
|
|
729
729
|
|
|
730
730
|
</ul>
|
|
731
731
|
<div class="article markdown">
|
|
732
|
-
<h2 id="unicode-">Unicode
|
|
732
|
+
<h2 id="unicode-">Unicode Reference</h2>
|
|
733
733
|
<hr>
|
|
734
734
|
|
|
735
|
-
<p>Unicode
|
|
735
|
+
<p>Unicode is the most basic way to use fonts on the web. Features:</p>
|
|
736
736
|
<ul>
|
|
737
|
-
<li
|
|
738
|
-
<li
|
|
737
|
+
<li>Supports dynamic adjustment of icon size, color, etc. like regular fonts.</li>
|
|
738
|
+
<li>Does not support multi-color by default. Multi-color icons will be automatically converted to single color.</li>
|
|
739
739
|
</ul>
|
|
740
740
|
<blockquote>
|
|
741
|
-
<p>Note: Multi-color icons are supported via SVG symbol method or color font
|
|
741
|
+
<p>Note: Multi-color icons are supported via the SVG symbol method or color font mode.</p>
|
|
742
742
|
</blockquote>
|
|
743
|
-
<p>
|
|
744
|
-
<h3 id="-font-face"
|
|
743
|
+
<p>Usage steps:</p>
|
|
744
|
+
<h3 id="-font-face">Step 1: Copy the generated <code>@font-face</code> code</h3>
|
|
745
745
|
<pre><code class="language-css"
|
|
746
746
|
>@font-face {
|
|
747
747
|
font-family: '${fontName}';
|
|
@@ -750,7 +750,7 @@ ${unicodeIcons}
|
|
|
750
750
|
url('${fileBase}.ttf${versionSuffix}') format('truetype');
|
|
751
751
|
}
|
|
752
752
|
</code></pre>
|
|
753
|
-
<h3 id="-iconfont-"
|
|
753
|
+
<h3 id="-iconfont-">Step 2: Define the iconfont styles</h3>
|
|
754
754
|
<pre><code class="language-css"
|
|
755
755
|
>.iconfont {
|
|
756
756
|
font-family: "${fontName}" !important;
|
|
@@ -760,7 +760,7 @@ ${unicodeIcons}
|
|
|
760
760
|
-moz-osx-font-smoothing: grayscale;
|
|
761
761
|
}
|
|
762
762
|
</code></pre>
|
|
763
|
-
<h3 id="-"
|
|
763
|
+
<h3 id="-">Step 3: Select an icon and use its character code on the page</h3>
|
|
764
764
|
<pre>
|
|
765
765
|
<code class="language-html"
|
|
766
766
|
><span class="iconfont">&#x33;</span>
|
|
@@ -776,20 +776,20 @@ ${fontClassIcons}
|
|
|
776
776
|
|
|
777
777
|
</ul>
|
|
778
778
|
<div class="article markdown">
|
|
779
|
-
<h2 id="font-class-">
|
|
779
|
+
<h2 id="font-class-">Font Class Reference</h2>
|
|
780
780
|
<hr>
|
|
781
781
|
|
|
782
|
-
<p>
|
|
783
|
-
<p
|
|
782
|
+
<p>Font class is a variant of Unicode usage that addresses the issue of Unicode being unintuitive and unclear in meaning.</p>
|
|
783
|
+
<p>Compared to Unicode usage, it has the following advantages:</p>
|
|
784
784
|
<ul>
|
|
785
|
-
<li
|
|
786
|
-
<li
|
|
785
|
+
<li>Compared to Unicode, it is semantically clear and more intuitive to write. You can easily tell what icon this is.</li>
|
|
786
|
+
<li>Because icons are defined using classes, when you need to replace an icon, you only need to modify the Unicode reference in the class.</li>
|
|
787
787
|
</ul>
|
|
788
|
-
<p
|
|
789
|
-
<h3 id="-fontclass-"
|
|
788
|
+
<p>Usage steps:</p>
|
|
789
|
+
<h3 id="-fontclass-">Step 1: Include the generated fontclass CSS file in your project:</h3>
|
|
790
790
|
<pre><code class="language-html"><link rel="stylesheet" href="./${fileBase}.css">
|
|
791
791
|
</code></pre>
|
|
792
|
-
<h3 id="-"
|
|
792
|
+
<h3 id="-">Step 2: Select an icon and use its class name on the page:</h3>
|
|
793
793
|
<pre><code class="language-html"><span class="iconfont icon-xxx"></span>
|
|
794
794
|
</code></pre>
|
|
795
795
|
<blockquote>
|
|
@@ -803,22 +803,22 @@ ${symbolIcons}
|
|
|
803
803
|
|
|
804
804
|
</ul>
|
|
805
805
|
<div class="article markdown">
|
|
806
|
-
<h2 id="symbol-">Symbol
|
|
806
|
+
<h2 id="symbol-">Symbol Reference</h2>
|
|
807
807
|
<hr>
|
|
808
808
|
|
|
809
|
-
<p
|
|
810
|
-
|
|
809
|
+
<p>This is a new way to use icons and represents the future mainstream approach, which is currently the recommended method by the platform. For more information, refer to this <a href="">article</a>.
|
|
810
|
+
This approach creates an SVG sprite collection. Compared to the other two methods, it has the following features:</p>
|
|
811
811
|
<ul>
|
|
812
|
-
<li
|
|
813
|
-
<li
|
|
814
|
-
<li
|
|
815
|
-
<li
|
|
812
|
+
<li>Supports multi-color icons, no longer limited to single colors.</li>
|
|
813
|
+
<li>Through some techniques, supports font-like styling via <code>font-size</code> and <code>color</code>.</li>
|
|
814
|
+
<li>Lower browser compatibility, supports IE9+ and modern browsers.</li>
|
|
815
|
+
<li>Browser SVG rendering performance is generally lower than PNG.</li>
|
|
816
816
|
</ul>
|
|
817
|
-
<p
|
|
818
|
-
<h3 id="-symbol-"
|
|
817
|
+
<p>Usage steps:</p>
|
|
818
|
+
<h3 id="-symbol-">Step 1: Include the generated symbol JavaScript file in your project:</h3>
|
|
819
819
|
<pre><code class="language-html"><script src="./${fileBase}.js"></script>
|
|
820
820
|
</code></pre>
|
|
821
|
-
<h3 id="-css-"
|
|
821
|
+
<h3 id="-css-">Step 2: Add the general CSS code (include once):</h3>
|
|
822
822
|
<pre><code class="language-html"><style>
|
|
823
823
|
.icon {
|
|
824
824
|
width: 1em;
|
|
@@ -829,7 +829,7 @@ ${symbolIcons}
|
|
|
829
829
|
}
|
|
830
830
|
</style>
|
|
831
831
|
</code></pre>
|
|
832
|
-
<h3 id="-"
|
|
832
|
+
<h3 id="-">Step 3: Select an icon and use it on the page:</h3>
|
|
833
833
|
<pre><code class="language-html"><svg class="icon" aria-hidden="true">
|
|
834
834
|
<use xlink:href="#icon-xxx"></use>
|
|
835
835
|
</svg>
|
|
@@ -3342,7 +3342,7 @@ const ttfToEot = (arr) => {
|
|
|
3342
3342
|
if (haveOS2 && haveName && haveHead) break;
|
|
3343
3343
|
}
|
|
3344
3344
|
if (!(haveOS2 && haveName && haveHead)) {
|
|
3345
|
-
throw new Error("Required
|
|
3345
|
+
throw new Error("Required font table sections not found (missing one or more: OS/2, name, head)");
|
|
3346
3346
|
}
|
|
3347
3347
|
const eot = Buffer.concat([
|
|
3348
3348
|
out,
|
|
@@ -3497,7 +3497,7 @@ const generateIconfont = async (options) => {
|
|
|
3497
3497
|
const runCli = async () => {
|
|
3498
3498
|
const program = new commander.Command().name("svg2font").description("Convert SVG icons into a downloadable iconfont zip (similar to iconfont.cn).").option(
|
|
3499
3499
|
"-i, --input <path>",
|
|
3500
|
-
"Directory or glob
|
|
3500
|
+
"Directory or glob pattern for SVG files",
|
|
3501
3501
|
DEFAULT_CLI_OPTIONS.input
|
|
3502
3502
|
).option(
|
|
3503
3503
|
"-o, --output <dir>",
|
package/lib/index.js
CHANGED
|
@@ -152,7 +152,7 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
152
152
|
display: none;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
/*
|
|
155
|
+
/* Page layout */
|
|
156
156
|
.main {
|
|
157
157
|
padding: 30px 100px;
|
|
158
158
|
width: 960px;
|
|
@@ -217,14 +217,14 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
.icon_lists .svg-icon {
|
|
220
|
-
/*
|
|
220
|
+
/* Change icon size by setting font-size */
|
|
221
221
|
width: 1em;
|
|
222
|
-
/*
|
|
222
|
+
/* Vertical alignment when icon is adjacent to text */
|
|
223
223
|
vertical-align: -0.15em;
|
|
224
|
-
/*
|
|
224
|
+
/* Change SVG color/fill by setting color */
|
|
225
225
|
fill: currentColor;
|
|
226
|
-
/* path
|
|
227
|
-
normalize.css
|
|
226
|
+
/* Hide path and stroke overflow outside viewBox in IE
|
|
227
|
+
This is also included in normalize.css */
|
|
228
228
|
overflow: hidden;
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -479,7 +479,7 @@ const buildDemoCss = () => `/* Basic utility classes */
|
|
|
479
479
|
text-decoration: underline;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
/*
|
|
482
|
+
/* Code highlighting */
|
|
483
483
|
/* PrismJS 1.15.0
|
|
484
484
|
https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */
|
|
485
485
|
/**
|
|
@@ -711,19 +711,19 @@ ${unicodeIcons}
|
|
|
711
711
|
|
|
712
712
|
</ul>
|
|
713
713
|
<div class="article markdown">
|
|
714
|
-
<h2 id="unicode-">Unicode
|
|
714
|
+
<h2 id="unicode-">Unicode Reference</h2>
|
|
715
715
|
<hr>
|
|
716
716
|
|
|
717
|
-
<p>Unicode
|
|
717
|
+
<p>Unicode is the most basic way to use fonts on the web. Features:</p>
|
|
718
718
|
<ul>
|
|
719
|
-
<li
|
|
720
|
-
<li
|
|
719
|
+
<li>Supports dynamic adjustment of icon size, color, etc. like regular fonts.</li>
|
|
720
|
+
<li>Does not support multi-color by default. Multi-color icons will be automatically converted to single color.</li>
|
|
721
721
|
</ul>
|
|
722
722
|
<blockquote>
|
|
723
|
-
<p>Note: Multi-color icons are supported via SVG symbol method or color font
|
|
723
|
+
<p>Note: Multi-color icons are supported via the SVG symbol method or color font mode.</p>
|
|
724
724
|
</blockquote>
|
|
725
|
-
<p>
|
|
726
|
-
<h3 id="-font-face"
|
|
725
|
+
<p>Usage steps:</p>
|
|
726
|
+
<h3 id="-font-face">Step 1: Copy the generated <code>@font-face</code> code</h3>
|
|
727
727
|
<pre><code class="language-css"
|
|
728
728
|
>@font-face {
|
|
729
729
|
font-family: '${fontName}';
|
|
@@ -732,7 +732,7 @@ ${unicodeIcons}
|
|
|
732
732
|
url('${fileBase}.ttf${versionSuffix}') format('truetype');
|
|
733
733
|
}
|
|
734
734
|
</code></pre>
|
|
735
|
-
<h3 id="-iconfont-"
|
|
735
|
+
<h3 id="-iconfont-">Step 2: Define the iconfont styles</h3>
|
|
736
736
|
<pre><code class="language-css"
|
|
737
737
|
>.iconfont {
|
|
738
738
|
font-family: "${fontName}" !important;
|
|
@@ -742,7 +742,7 @@ ${unicodeIcons}
|
|
|
742
742
|
-moz-osx-font-smoothing: grayscale;
|
|
743
743
|
}
|
|
744
744
|
</code></pre>
|
|
745
|
-
<h3 id="-"
|
|
745
|
+
<h3 id="-">Step 3: Select an icon and use its character code on the page</h3>
|
|
746
746
|
<pre>
|
|
747
747
|
<code class="language-html"
|
|
748
748
|
><span class="iconfont">&#x33;</span>
|
|
@@ -758,20 +758,20 @@ ${fontClassIcons}
|
|
|
758
758
|
|
|
759
759
|
</ul>
|
|
760
760
|
<div class="article markdown">
|
|
761
|
-
<h2 id="font-class-">
|
|
761
|
+
<h2 id="font-class-">Font Class Reference</h2>
|
|
762
762
|
<hr>
|
|
763
763
|
|
|
764
|
-
<p>
|
|
765
|
-
<p
|
|
764
|
+
<p>Font class is a variant of Unicode usage that addresses the issue of Unicode being unintuitive and unclear in meaning.</p>
|
|
765
|
+
<p>Compared to Unicode usage, it has the following advantages:</p>
|
|
766
766
|
<ul>
|
|
767
|
-
<li
|
|
768
|
-
<li
|
|
767
|
+
<li>Compared to Unicode, it is semantically clear and more intuitive to write. You can easily tell what icon this is.</li>
|
|
768
|
+
<li>Because icons are defined using classes, when you need to replace an icon, you only need to modify the Unicode reference in the class.</li>
|
|
769
769
|
</ul>
|
|
770
|
-
<p
|
|
771
|
-
<h3 id="-fontclass-"
|
|
770
|
+
<p>Usage steps:</p>
|
|
771
|
+
<h3 id="-fontclass-">Step 1: Include the generated fontclass CSS file in your project:</h3>
|
|
772
772
|
<pre><code class="language-html"><link rel="stylesheet" href="./${fileBase}.css">
|
|
773
773
|
</code></pre>
|
|
774
|
-
<h3 id="-"
|
|
774
|
+
<h3 id="-">Step 2: Select an icon and use its class name on the page:</h3>
|
|
775
775
|
<pre><code class="language-html"><span class="iconfont icon-xxx"></span>
|
|
776
776
|
</code></pre>
|
|
777
777
|
<blockquote>
|
|
@@ -785,22 +785,22 @@ ${symbolIcons}
|
|
|
785
785
|
|
|
786
786
|
</ul>
|
|
787
787
|
<div class="article markdown">
|
|
788
|
-
<h2 id="symbol-">Symbol
|
|
788
|
+
<h2 id="symbol-">Symbol Reference</h2>
|
|
789
789
|
<hr>
|
|
790
790
|
|
|
791
|
-
<p
|
|
792
|
-
|
|
791
|
+
<p>This is a new way to use icons and represents the future mainstream approach, which is currently the recommended method by the platform. For more information, refer to this <a href="">article</a>.
|
|
792
|
+
This approach creates an SVG sprite collection. Compared to the other two methods, it has the following features:</p>
|
|
793
793
|
<ul>
|
|
794
|
-
<li
|
|
795
|
-
<li
|
|
796
|
-
<li
|
|
797
|
-
<li
|
|
794
|
+
<li>Supports multi-color icons, no longer limited to single colors.</li>
|
|
795
|
+
<li>Through some techniques, supports font-like styling via <code>font-size</code> and <code>color</code>.</li>
|
|
796
|
+
<li>Lower browser compatibility, supports IE9+ and modern browsers.</li>
|
|
797
|
+
<li>Browser SVG rendering performance is generally lower than PNG.</li>
|
|
798
798
|
</ul>
|
|
799
|
-
<p
|
|
800
|
-
<h3 id="-symbol-"
|
|
799
|
+
<p>Usage steps:</p>
|
|
800
|
+
<h3 id="-symbol-">Step 1: Include the generated symbol JavaScript file in your project:</h3>
|
|
801
801
|
<pre><code class="language-html"><script src="./${fileBase}.js"></script>
|
|
802
802
|
</code></pre>
|
|
803
|
-
<h3 id="-css-"
|
|
803
|
+
<h3 id="-css-">Step 2: Add the general CSS code (include once):</h3>
|
|
804
804
|
<pre><code class="language-html"><style>
|
|
805
805
|
.icon {
|
|
806
806
|
width: 1em;
|
|
@@ -811,7 +811,7 @@ ${symbolIcons}
|
|
|
811
811
|
}
|
|
812
812
|
</style>
|
|
813
813
|
</code></pre>
|
|
814
|
-
<h3 id="-"
|
|
814
|
+
<h3 id="-">Step 3: Select an icon and use it on the page:</h3>
|
|
815
815
|
<pre><code class="language-html"><svg class="icon" aria-hidden="true">
|
|
816
816
|
<use xlink:href="#icon-xxx"></use>
|
|
817
817
|
</svg>
|
|
@@ -3285,7 +3285,7 @@ const ttfToEot = (arr) => {
|
|
|
3285
3285
|
if (haveOS2 && haveName && haveHead) break;
|
|
3286
3286
|
}
|
|
3287
3287
|
if (!(haveOS2 && haveName && haveHead)) {
|
|
3288
|
-
throw new Error("Required
|
|
3288
|
+
throw new Error("Required font table sections not found (missing one or more: OS/2, name, head)");
|
|
3289
3289
|
}
|
|
3290
3290
|
const eot = Buffer.concat([
|
|
3291
3291
|
out,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg2font-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI and Node API to convert SVG icon sets into complete iconfont bundles (SVG/TTF/WOFF/WOFF2/EOT) with CSS, demos, and sprites - zero native dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svg",
|