@hibi_10000/grunt-webfont 2.0.1
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/License.md +24 -0
- package/Readme.md +695 -0
- package/bin/eotlitetool.py +474 -0
- package/bin/fontforge/generate.py +133 -0
- package/dist/engines/fontforge.js +84 -0
- package/dist/engines/fontforge.js.map +1 -0
- package/dist/engines/node.js +164 -0
- package/dist/engines/node.js.map +1 -0
- package/dist/package.js +105 -0
- package/dist/package.js.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/util/util.js +105 -0
- package/dist/util/util.js.map +1 -0
- package/dist/webfont.d.ts +8 -0
- package/dist/webfont.js +609 -0
- package/dist/webfont.js.map +1 -0
- package/package.json +86 -0
- package/tasks/engines/fontforge.ts +124 -0
- package/tasks/engines/node.ts +213 -0
- package/tasks/engines/nodedeps.d.ts +22 -0
- package/tasks/types.ts +169 -0
- package/tasks/util/util.ts +119 -0
- package/tasks/webfont.ts +833 -0
- package/templates/bem.css +56 -0
- package/templates/bem.json +4 -0
- package/templates/bootstrap.css +114 -0
- package/templates/bootstrap.json +4 -0
- package/templates/demo.html +97 -0
- package/tsconfig.json +31 -0
package/tasks/types.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
log: {
|
|
3
|
+
error: (...args: any[]) => void,
|
|
4
|
+
warn: (...args: any[]) => void,
|
|
5
|
+
info: (...args: any[]) => void,
|
|
6
|
+
verbose: (...args: any[]) => void,
|
|
7
|
+
},
|
|
8
|
+
fail: {
|
|
9
|
+
fatal: (...args: any[]) => void,
|
|
10
|
+
warn?: (...args: any[]) => void,
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CustomOutput {
|
|
15
|
+
template: string,
|
|
16
|
+
dest: string,
|
|
17
|
+
syntax?: string,
|
|
18
|
+
context?: Partial<Context>,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TemplateOptions {
|
|
22
|
+
baseClass?: string,
|
|
23
|
+
classPrefix?: string,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface Configs {
|
|
27
|
+
[key: string]: Config,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Config {
|
|
31
|
+
src: string,
|
|
32
|
+
dest?: string,
|
|
33
|
+
destCss?: string,
|
|
34
|
+
destScss?: string,
|
|
35
|
+
destSass?: string,
|
|
36
|
+
destLess?: string,
|
|
37
|
+
destStyl?: string,
|
|
38
|
+
options?: Options,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface Options {
|
|
42
|
+
font?: string,
|
|
43
|
+
destCss?: string,
|
|
44
|
+
destScss?: string,
|
|
45
|
+
destSass?: string,
|
|
46
|
+
destLess?: string,
|
|
47
|
+
destStyl?: string,
|
|
48
|
+
dest?: string,
|
|
49
|
+
relativeFontPath?: string,
|
|
50
|
+
fontPathVariables?: boolean,
|
|
51
|
+
hashes?: boolean,
|
|
52
|
+
ligatures?: boolean,
|
|
53
|
+
template?: string,
|
|
54
|
+
syntax?: string,
|
|
55
|
+
templateOptions?: TemplateOptions,
|
|
56
|
+
stylesheets?: string[],
|
|
57
|
+
stylesheet?: string,
|
|
58
|
+
htmlDemo?: boolean,
|
|
59
|
+
htmlDemoTemplate?: string,
|
|
60
|
+
htmlDemoFilename?: string,
|
|
61
|
+
styles?: string, //"foo,bar"
|
|
62
|
+
types?: string, //"foo,bar"
|
|
63
|
+
order?: string, //"foo,bar"
|
|
64
|
+
embed?: boolean | string, //"foo,bar"
|
|
65
|
+
rename?: (path: string, suffix?: string) => string,
|
|
66
|
+
engine?: 'fontforge' | 'node',
|
|
67
|
+
autoHint?: boolean,
|
|
68
|
+
codepoints?: { [key: string]: number },
|
|
69
|
+
codepointsFile?: string, // | fs.PathLike,
|
|
70
|
+
startCodepoint?: number,
|
|
71
|
+
ie7?: boolean,
|
|
72
|
+
normalize?: boolean,
|
|
73
|
+
optimize?: boolean,
|
|
74
|
+
round?: number,
|
|
75
|
+
fontHeight?: number,
|
|
76
|
+
descent?: number,
|
|
77
|
+
version?: string | boolean,
|
|
78
|
+
cache?: string,
|
|
79
|
+
callback?: (filename: string, types: string[], glyphs: string[], hash: string) => void,
|
|
80
|
+
customOutputs?: CustomOutput[],
|
|
81
|
+
execMaxBuffer?: number,
|
|
82
|
+
|
|
83
|
+
destHtml?: string,
|
|
84
|
+
fontFilename?: string,
|
|
85
|
+
fontFamilyName?: string,
|
|
86
|
+
skip?: boolean,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface OptionsInternal extends TemplateOptions {
|
|
90
|
+
logger: Logger,
|
|
91
|
+
fontBaseName: string,
|
|
92
|
+
destCss: string,
|
|
93
|
+
destScss: string,
|
|
94
|
+
destSass: string,
|
|
95
|
+
destLess: string,
|
|
96
|
+
destStyl: string,
|
|
97
|
+
dest: string,
|
|
98
|
+
relativeFontPath: string,
|
|
99
|
+
fontPathVariables: boolean,
|
|
100
|
+
addHashes: boolean,
|
|
101
|
+
addLigatures: boolean,
|
|
102
|
+
template: string,
|
|
103
|
+
syntax: string,
|
|
104
|
+
templateOptions: TemplateOptions,
|
|
105
|
+
stylesheets: string[],
|
|
106
|
+
htmlDemo: boolean,
|
|
107
|
+
htmlDemoTemplate: string,
|
|
108
|
+
htmlDemoFilename: string,
|
|
109
|
+
styles: string[] | string,
|
|
110
|
+
types: string[],
|
|
111
|
+
order: string[],
|
|
112
|
+
embed: string[],
|
|
113
|
+
rename: (path: string, suffix?: string) => string,
|
|
114
|
+
engine: 'fontforge' | 'node',
|
|
115
|
+
autoHint: boolean,
|
|
116
|
+
codepoints: { [key: string]: number },
|
|
117
|
+
codepointsFile: string, // | fs.PathLike,
|
|
118
|
+
startCodepoint: number,
|
|
119
|
+
ie7: boolean,
|
|
120
|
+
normalize: boolean,
|
|
121
|
+
optimize: boolean,
|
|
122
|
+
round: number,
|
|
123
|
+
fontHeight: number,
|
|
124
|
+
descent: number,
|
|
125
|
+
version: string | boolean,
|
|
126
|
+
cache: string,
|
|
127
|
+
callback: (filename: string, types: string[], glyphs: string[], hash: string) => void,
|
|
128
|
+
customOutputs: CustomOutput[],
|
|
129
|
+
execMaxBuffer: number,
|
|
130
|
+
|
|
131
|
+
fontName?: string,
|
|
132
|
+
destCssPaths?: {
|
|
133
|
+
css: string,
|
|
134
|
+
scss: string,
|
|
135
|
+
sass: string,
|
|
136
|
+
less: string,
|
|
137
|
+
styl: string,
|
|
138
|
+
},
|
|
139
|
+
destHtml?: string,
|
|
140
|
+
fontfaceStyles?: boolean,
|
|
141
|
+
baseStyles?: boolean,
|
|
142
|
+
extraStyles?: boolean,
|
|
143
|
+
files?: string[],
|
|
144
|
+
glyphs?: string[],
|
|
145
|
+
hash?: string,
|
|
146
|
+
fontFilename?: string,
|
|
147
|
+
fontFamilyName?: string,
|
|
148
|
+
fontSrc1?: string,
|
|
149
|
+
fontSrc2?: string,
|
|
150
|
+
fontRawSrcs?: string[][],
|
|
151
|
+
cssTemplate?: {
|
|
152
|
+
filename: string,
|
|
153
|
+
template: string, //html code
|
|
154
|
+
},
|
|
155
|
+
fontPathVariable?: string,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface Context extends OptionsInternal {
|
|
159
|
+
testHeading?: string,
|
|
160
|
+
stylesheet?: string,
|
|
161
|
+
iconsStyles?: true,
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface ReadableStreamWithMetadata extends NodeJS.ReadableStream {
|
|
165
|
+
metadata?: {
|
|
166
|
+
unicode: string[],
|
|
167
|
+
name: string,
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* grunt-webfont: common stuff
|
|
3
|
+
*
|
|
4
|
+
* @author Artem Sapegin (http://sapegin.me), Hibi_10000
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { globSync } from 'glob';
|
|
9
|
+
import { consola } from 'consola';
|
|
10
|
+
|
|
11
|
+
import type { Logger, OptionsInternal } from '../types.ts';
|
|
12
|
+
|
|
13
|
+
export const consolaLogger: Logger = {
|
|
14
|
+
log: {
|
|
15
|
+
error: consola.error.raw,
|
|
16
|
+
warn: consola.warn.raw,
|
|
17
|
+
info: consola.info.raw,
|
|
18
|
+
verbose: consola.verbose.raw,
|
|
19
|
+
},
|
|
20
|
+
fail: {
|
|
21
|
+
fatal: (...args) => {
|
|
22
|
+
consola.fatal.raw(...args);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Unicode Private Use Area start.
|
|
30
|
+
* http://en.wikipedia.org/wiki/Private_Use_(Unicode)
|
|
31
|
+
*/
|
|
32
|
+
export const UNICODE_PUA_START = 0xF101;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @font-face’s src values generation rules.
|
|
36
|
+
*/
|
|
37
|
+
export const fontsSrcsMap = {
|
|
38
|
+
eot: {
|
|
39
|
+
0: {
|
|
40
|
+
ext: '.eot',
|
|
41
|
+
},
|
|
42
|
+
1: {
|
|
43
|
+
ext: '.eot?#iefix',
|
|
44
|
+
format: 'embedded-opentype',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
woff: {
|
|
48
|
+
0: false as false,
|
|
49
|
+
1: {
|
|
50
|
+
ext: '.woff',
|
|
51
|
+
format: 'woff',
|
|
52
|
+
embeddable: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
woff2: {
|
|
56
|
+
0: false as false,
|
|
57
|
+
1: {
|
|
58
|
+
ext: '.woff2',
|
|
59
|
+
format: 'woff2',
|
|
60
|
+
embeddable: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
ttf: {
|
|
64
|
+
0: false as false,
|
|
65
|
+
1: {
|
|
66
|
+
ext: '.ttf',
|
|
67
|
+
format: 'truetype',
|
|
68
|
+
embeddable: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
svg: {
|
|
72
|
+
0: false as false,
|
|
73
|
+
1: {
|
|
74
|
+
ext: '.svg#{fontBaseName}',
|
|
75
|
+
format: 'svg',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* CSS fileaname prefixes: _icons.scss.
|
|
82
|
+
*/
|
|
83
|
+
export const cssFilePrefixes = {
|
|
84
|
+
_default: '',
|
|
85
|
+
sass: '_',
|
|
86
|
+
scss: '_'
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @font-face’s src parts seperators.
|
|
91
|
+
*/
|
|
92
|
+
export const fontSrcSeparators = {
|
|
93
|
+
_default: ',\n\t\t',
|
|
94
|
+
styl: ', '
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* List of available font formats.
|
|
99
|
+
*/
|
|
100
|
+
export const fontFormats = 'eot,woff2,woff,ttf,svg';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns list of all generated font files.
|
|
104
|
+
*
|
|
105
|
+
* @param o Options.
|
|
106
|
+
*/
|
|
107
|
+
export const generatedFontFiles = (o: OptionsInternal): string[] => {
|
|
108
|
+
return globSync(path.posix.join(o.dest, `${o.fontFilename}*.{${o.types}}`));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns path to font of specified format.
|
|
113
|
+
*
|
|
114
|
+
* @param o Options.
|
|
115
|
+
* @param type Font type (see `wf.fontFormats`).
|
|
116
|
+
*/
|
|
117
|
+
export const getFontPath = (o: OptionsInternal, type: string): string => {
|
|
118
|
+
return path.join(o.dest, `${o.fontFilename}.${type}`);
|
|
119
|
+
};
|