@xlfont/load 1.0.13 → 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/CHANGELOG.md ADDED
@@ -0,0 +1,119 @@
1
+ # Change Logs
2
+
3
+ ## v2.0.1
4
+
5
+ - publish module with files under `dist` in root too.
6
+
7
+
8
+ ## v2.0.0
9
+
10
+ - remove deprecated `xfl.js` and `xfl.min.js`
11
+ - further minimize generated js file with mangling and compression
12
+ - update `main`, add `browser` field in `package.json`.
13
+ - upgrade modules
14
+ - patch test code to make it work with upgraded modules
15
+ - fix bug: opentype-url doesn't work
16
+ - use Object URL for worker loading so we don't have to specify its path by ourselves
17
+
18
+
19
+ ## v1.1.1
20
+
21
+ - correctly support web worker by accepting options for worker and dependency url
22
+
23
+
24
+ ## v1.1.0
25
+
26
+ - support merging font locally by opentype.js
27
+ - support web worker ( TBD )
28
+ - suppoty `style` and `weight` information
29
+ - wait explicitly until fonts loaded according to document.fonts in `xfl.update`
30
+ - accept `use-worker` as an option, but still dont enable it
31
+ - normalize font name if it's derived from url
32
+ - load xlfont with woff instead of ttf.
33
+ - support `hasChar(c)`
34
+ - support `getPath(opt)` as xlfont method, which check chars for availability before rendering.
35
+ - let misschar also keep tracks of supported char (by setting it to false)
36
+
37
+
38
+ ## v1.0.13
39
+
40
+ - null check sub.font[0] before using it
41
+ - support string param in `load` api
42
+ - point entry point from `xfl.js` to `index.js`
43
+
44
+
45
+ ## v1.0.12
46
+
47
+ - add back proxise since we can't actually remove it for now
48
+
49
+
50
+ ## v1.0.11
51
+
52
+ - remove dependency to proxise by inlining `once` function
53
+ - rename `xfl.js` while keeping `index.js`, which will be removed in future minor update
54
+ - rename `xfont` to `xlfont` to reflect package name.
55
+
56
+
57
+ ## v1.0.10
58
+
59
+ - escape space in class name
60
+ - quote name in font family name that didn't quote in the last version
61
+
62
+
63
+ ## v1.0.9
64
+
65
+ - escape space in font name
66
+ - quote name and url in font family styles
67
+ - call update for non-xl fonts
68
+ - fix incorrectly assignment in xfl.update
69
+
70
+
71
+ ## v1.0.8
72
+
73
+ - fix bug: `-a` option doesn't work in `xfl-meta`
74
+
75
+
76
+ ## v1.0.7
77
+
78
+ - fix incorrect versioning issue
79
+
80
+
81
+ ## v1.0.5 / v1.0.6
82
+
83
+ - skip notdef by reference instead of by name. This fixed `Taipei Sans TC Beta` generation issue.
84
+
85
+
86
+ ## v1.0.4
87
+
88
+ - handle newlines in metadata
89
+
90
+
91
+ ## v1.0.3
92
+
93
+ - support subsetting only single font in xfl command
94
+ - better formatting of xfl-meta output
95
+
96
+
97
+ ## v1.0.2
98
+
99
+ - add `xfl-meta` command
100
+ - add missing dependency in `build.js`
101
+ - update `package.json` for some dependencies that should be for production
102
+
103
+
104
+ ## v1.0.1
105
+
106
+ - remove npm-shrinkwrap.json
107
+
108
+
109
+ ## v1.0.0
110
+
111
+ - completely rewrite xfl.ls
112
+ - support font merging based on opentype.js
113
+ - non-xl-font aware
114
+ - better support for concurrent fetching
115
+ - support promise in all api
116
+ - use SIL-Open Licensed fonts only for demonstration
117
+ - remove fontmin / gulp-rename dependency
118
+ - add `woff` format output
119
+ - use `@plotdb/opentype.js` for bug fixing
package/README.md CHANGED
@@ -15,7 +15,7 @@ This is a javascript project based on nodeJS / npm. After installing node / npm,
15
15
  npm install --save @xlfont/load
16
16
 
17
17
 
18
- ## xl-font subsetting generator
18
+ ## xlfont subsetting generator
19
19
 
20
20
  use `npx xfl` to subset fonts with `xfl`:
21
21
 
@@ -54,11 +54,11 @@ Generally speaking, the steps of font subsetting by `xfl` are as following:
54
54
  - dump unicode / subset mapping to `charmap.txt`. also keep the original font as `all.ttf`.
55
55
 
56
56
 
57
- ## xl-font subset loader
57
+ ## xlfont subset loader
58
58
 
59
59
  include the locally installed dist files or from cdn:
60
60
 
61
- <script src="path-to/xfl.js"></script>
61
+ <script src="path-to/xfl-js"></script>
62
62
 
63
63
 
64
64
  Then, load desired font:
@@ -74,25 +74,60 @@ Sync font based on given text:
74
74
  });
75
75
 
76
76
 
77
+ ## xfl API
77
78
 
78
- Font object API:
79
+ - `load(opt)`: load specified font. cache used fonts to save bandwidth and memory.
80
+ - `opt` can either be:
81
+ - a string to the specified font, or object as option
82
+ - an object passed directly to `xlfont` constructor.
83
+ - return a promise resolving to a `xlfont` object.
84
+ - `update()`: refresh necessary CSS in document to reflect font status changes.
85
+
86
+
87
+ ## xlfont Constructor
88
+
89
+ Besides loading from `xfl.load`, you can also manually construct a `xlfont` object. `xlfont` is the interface to accessing specific font ( including normal font or subsetted xlfont ), with constructor options as below:
90
+
91
+ - `path`: path to font.
92
+ - `ext`: optional. font file extension ( `ttf`, `woff`, etc )
93
+ - if omitted, calculated from `path`.
94
+ - if not available ( either in `ext` or `path` ), default to `woff` and consider this font as a xlfont.
95
+ - `name`: font name. if omitted, use normalized `path` as font name.
96
+ - `isXl`: true if this is a xlfont. if omitted, decided by `ext`.
97
+ - `doMerge`: should subsetted merged by frontend JS before using to enhacen UX. default false
98
+ - `useWorker`: use web worker for font merging. default false. When specified, can be an object with following:
99
+ - `opentype-url`: required `opentype.js` url.
100
+ - context of worker is in Object URL, so relative URL is not support.
101
+ - use `document.location` to prevent from hardcoding domain.
102
+ - `style`: font style ( e.g., `normal`, `italic` ). default `normal`.
103
+ - `weight`: font weight ( e.g., `400`, `500`, etc ). default `400`.
104
+
105
+
106
+ ## xlfont Object API
79
107
 
80
108
  - `init()`: init this font object. `xfl.load` will do this job for you.
81
109
  - `sync(text)`: load fonts based on given text.
82
110
  - `getotf()`: return a promise, resolved to `opentype.Font` from `opentype.js`.
83
111
  - `opentype.js` is required for this method
84
112
  - `fetchAll()` will be called by this method.
113
+ - `getPath(opt)`: return a promise resolving to opentype.js' `Path` object based on opt with following fields:
114
+ - `text`: text to render. default ''
115
+ - `x`: x offset of the rendered text. default 0
116
+ - `y`: y offset of the rendered text. default 0
117
+ - `fontSize`: size of the rendered text. default 48
118
+ - `hasChar(c)`: return if code point of the given character `c` is available in this font.
119
+ - return true / false: available or not available
120
+ - return undefined: not sure before synced
85
121
  - `fetchAll()`: by default `xfl` use CSS to load fonts. `fecthAll()` fetch all subset fonts with JS again.
86
122
  - `name`: font name which can be used in CSS `font-family` property.
87
123
  - `className`: a CSS class name which its `font-family` is assigned to this font.
88
124
 
89
125
 
90
- ## availabel xl-fonts
126
+ ## availabel xlfonts
91
127
 
92
- While this is a tool for composing and using xl-font, we also prepare a set of xl-fonts so you can use them directly with `xfl.js`. All fonts are released under `SIL-Open Font License 1.1` or similar open licenses. Checkout the following repo for more information:
93
-
94
- https://github.com/xlfont/cjk/
128
+ While this is a tool for composing and using xlfont, we also prepare a set of xlfonts so you can use them directly with `xfl.js`. All fonts are released under `SIL-Open Font License 1.1` or similar open licenses. Checkout repo list of the Github organization of `@xlfont` for more information:
95
129
 
130
+ https://github.com/xlfont/
96
131
 
97
132
 
98
133
  ## Todo
@@ -115,9 +150,10 @@ While this is a tool for composing and using xl-font, we also prepare a set of x
115
150
  - parsed from content of `https://www.ling.upenn.edu/courses/Spring_2003/ling538/UnicodeRanges.html`
116
151
  - content of the above link is from `http://www.unicode.org/charts/`
117
152
 
153
+
118
154
  ## Font Subsetting Consideration
119
155
 
120
- According to *[SIL's OFL FAQ](https://scripts.sil.org/cms/scripts/page.php?item_id=OFL-FAQ_web#b4b7db21)* and *[Web Fonts and Reserved Font Names](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL_web_fonts_and_RFNs#33301a9c)*, Subsetting a font is considered *modification* of that font. This is permitted by *Open Font License (OFL)*, but OFL requires that modified versions must not use RFNs (Reserved Font Names) without separate permission.
156
+ According to [*SIL's OFL FAQ*](https://scripts.sil.org/cms/scripts/page.php?item_id=OFL-FAQ_web#b4b7db21) and [*Web Fonts and Reserved Font Names*](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL_web_fonts_and_RFNs#33301a9c), Subsetting a font is considered *modification* of that font. This is permitted by *Open Font License (OFL)*, but OFL requires that modified versions must not use RFNs (Reserved Font Names) without separate permission.
121
157
 
122
158
  However, once FE (Functional Equivalence) is preserved, then it's very likely that the original author would feel that the optimized font is a good and reasonable equivalent, and that the main purposes of the RFN mechanism - avoids collisions, protects authors. minimizes support, encourages derivatives - continue to be met.
123
159
 
package/bin/build.js CHANGED
@@ -7,7 +7,7 @@
7
7
  opentype = require('@plotdb/opentype.js');
8
8
  yargs = require('yargs');
9
9
  path = require('path');
10
- colors = require('colors');
10
+ colors = require('@plotdb/colors');
11
11
  progress = require('progress');
12
12
  ttf2woff2 = require('ttf2woff2');
13
13
  ttf2woff = require('ttf2woff');
package/bin/meta.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var fs, path, colors, yargs, opentype, lib, allRanges, argv, file, all, multiline;
4
4
  fs = require('fs');
5
5
  path = require('path');
6
- colors = require('colors');
6
+ colors = require('@plotdb/colors');
7
7
  yargs = require('yargs');
8
8
  opentype = require('@plotdb/opentype.js');
9
9
  lib = path.dirname(fs.realpathSync(__filename));