@web-padawan/wc-icons-tool 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@web-padawan/wc-icons-tool",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "./bin/wc-icons-tool",
5
5
  "bin": {
6
6
  "wc-icons-tool": "./bin/wc-icons-tool"
@@ -15,11 +15,16 @@
15
15
  "description": "Tool for building Vaadin icons",
16
16
  "files": [
17
17
  "bin",
18
+ "patches",
18
19
  "tasks"
19
20
  ],
21
+ "scripts": {
22
+ "postinstall": "patch-package"
23
+ },
20
24
  "dependencies": {
21
25
  "cheerio": "^1.0.0",
22
26
  "glob": "^13.0.0",
27
+ "patch-package": "^8.0.1",
23
28
  "svgicons2svgfont": "^14.0.2",
24
29
  "svg2ttf": "6.0.3",
25
30
  "ttf2woff": "3.0.0"
@@ -0,0 +1,35 @@
1
+ diff --git a/node_modules/svg2ttf/lib/sfnt.js b/node_modules/svg2ttf/lib/sfnt.js
2
+ index f303f2a..0907cbf 100644
3
+ --- a/node_modules/svg2ttf/lib/sfnt.js
4
+ +++ b/node_modules/svg2ttf/lib/sfnt.js
5
+ @@ -15,13 +15,7 @@ function Font() {
6
+ this.italicAngle = 0;
7
+ this.familyClass = 0; // No Classification
8
+ this.familyName = '';
9
+ -
10
+ - // 0x40 - REGULAR - Characters are in the standard weight/style for the font
11
+ - // 0x80 - USE_TYPO_METRICS - use OS/2.sTypoAscender - OS/2.sTypoDescender + OS/2.sTypoLineGap as the default line spacing
12
+ - // https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fsselection
13
+ - // https://github.com/fontello/svg2ttf/issues/95
14
+ - this.fsSelection = 0x40 | 0x80;
15
+ -
16
+ + this.fsSelection = 0x40; // Characters are in the standard weight/style for the font.
17
+ // Non zero value can cause issues in IE, https://github.com/fontello/svg2ttf/issues/45
18
+ this.fsType = 0;
19
+ this.lowestRecPPEM = 8;
20
+ diff --git a/node_modules/svg2ttf/lib/ttf/tables/os2.js b/node_modules/svg2ttf/lib/ttf/tables/os2.js
21
+ index 197d4cf..8f1feae 100644
22
+ --- a/node_modules/svg2ttf/lib/ttf/tables/os2.js
23
+ +++ b/node_modules/svg2ttf/lib/ttf/tables/os2.js
24
+ @@ -71,10 +71,7 @@ function createOS2Table(font) {
25
+ buf.writeInt16(font.ascent); // sTypoAscender
26
+ buf.writeInt16(font.descent); // sTypoDescender
27
+ buf.writeInt16(font.lineGap); // lineGap
28
+ - // Enlarge win acscent/descent to avoid clipping
29
+ - // WinAscent - WinDecent should at least be equal to TypoAscender - TypoDescender + TypoLineGap:
30
+ - // https://www.high-logic.com/font-editor/fontcreator/tutorials/font-metrics-vertical-line-spacing
31
+ - buf.writeInt16(Math.max(font.yMax, font.ascent + font.lineGap)); // usWinAscent
32
+ + buf.writeInt16(Math.max(font.yMax, font.ascent)); // usWinAscent
33
+ buf.writeInt16(-Math.min(font.yMin, font.descent)); // usWinDescent
34
+ buf.writeInt32(1); // ulCodePageRange1, Latin 1
35
+ buf.writeInt32(0); // ulCodePageRange2
package/tasks/lumo.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import { execSync } from 'node:child_process';
2
2
  import path from 'node:path';
3
- import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
3
+ import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
4
+ import { dirname } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
4
6
  import * as cheerio from 'cheerio';
5
7
 
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+
6
10
  function createCopyright() {
7
11
  return `/**
8
12
  * @license
@@ -15,17 +19,19 @@ export function generateLumoFont() {
15
19
  const FONT = `${process.cwd()}/packages/vaadin-lumo-styles/lumo-icons`;
16
20
 
17
21
  // Create SVG font
18
- const svgIcons2Font = path.normalize('./node_modules/.bin/svgicons2svgfont');
22
+ const svgIcons2Font = path.normalize(
23
+ `${__dirname}/../node_modules/.bin/svgicons2svgfont`
24
+ );
19
25
  execSync(
20
26
  `${svgIcons2Font} --fontname=lumo-icons --height=1000 --ascent=850 --descent=150 --normalize --fixedWidth --verbose -o ${FONT}.svg ${process.cwd()}/packages/vaadin-lumo-styles/icons/svg/*.svg`
21
27
  );
22
28
 
23
29
  // Convert SVG to TTF
24
- const svg2TTF = path.normalize('./node_modules/.bin/svg2ttf');
30
+ const svg2TTF = path.normalize(`${__dirname}/../node_modules/.bin/svg2ttf`);
25
31
  execSync(`${svg2TTF} --ts=1 ${FONT}.svg ${FONT}.ttf`);
26
32
 
27
33
  // Convert TTF to WOFF
28
- const ttf2WOFF = path.normalize('./node_modules/.bin/ttf2woff');
34
+ const ttf2WOFF = path.normalize(`${__dirname}/../node_modules/.bin/ttf2woff`);
29
35
  execSync(`${ttf2WOFF} ${FONT}.ttf ${FONT}.woff`);
30
36
 
31
37
  const content = readFileSync(`${FONT}.svg`, 'utf-8');
@@ -51,7 +57,9 @@ export function generateLumoFont() {
51
57
  const outputCSS = `
52
58
  @font-face {
53
59
  font-family: 'lumo-icons';
54
- src: url(data:application/font-woff;charset=utf-8;base64,${lumoIconsWoff.toString('base64')})
60
+ src: url(data:application/font-woff;charset=utf-8;base64,${lumoIconsWoff.toString(
61
+ 'base64'
62
+ )})
55
63
  format('woff');
56
64
  font-weight: normal;
57
65
  font-style: normal;
@@ -64,11 +72,17 @@ export function generateLumoFont() {
64
72
  `;
65
73
 
66
74
  // Write the output to src/props/icons.css
67
- writeFileSync(`${process.cwd()}/packages/vaadin-lumo-styles/src/props/icons.css`, [createCopyright(), outputCSS.trimStart()].join('\n'));
75
+ writeFileSync(
76
+ `${process.cwd()}/packages/vaadin-lumo-styles/src/props/icons.css`,
77
+ [createCopyright(), outputCSS.trimStart()].join('\n')
78
+ );
68
79
 
69
80
  // Write the list of glyphs for visual tests
70
81
  const list = glyphs.map((g) => g.name);
71
- writeFileSync(`${process.cwd()}/packages/vaadin-lumo-styles/test/glyphs.json`, JSON.stringify(list, null, 2));
82
+ writeFileSync(
83
+ `${process.cwd()}/packages/vaadin-lumo-styles/test/glyphs.json`,
84
+ JSON.stringify(list, null, 2)
85
+ );
72
86
 
73
87
  // Cleanup temporary font files
74
88
  unlinkSync(`${FONT}.svg`);