@cantoo/fontkit 2.0.8 → 2.0.9

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 (42) hide show
  1. package/dist/browser-module.d.ts +27 -16
  2. package/dist/browser-module.mjs +20 -0
  3. package/dist/browser-module.mjs.map +1 -1
  4. package/dist/browser.cjs +20 -0
  5. package/dist/browser.cjs.map +1 -1
  6. package/dist/browser.d.ts +27 -16
  7. package/dist/fontkit.umd.d.ts +27 -16
  8. package/dist/fontkit.umd.js +21 -0
  9. package/dist/fontkit.umd.js.map +2 -2
  10. package/dist/fontkit.umd.min.js +11 -0
  11. package/dist/fontkit.umd.min.js.map +7 -0
  12. package/dist/index.d.ts +27 -16
  13. package/dist/main.cjs +22 -0
  14. package/dist/main.cjs.map +1 -1
  15. package/dist/main.d.ts +27 -16
  16. package/dist/module.d.ts +27 -16
  17. package/dist/module.mjs +22 -0
  18. package/dist/module.mjs.map +1 -1
  19. package/dist/unicode-properties/index.cjs +270 -0
  20. package/dist/unicode-properties/index.cjs.map +7 -0
  21. package/dist/unicode-properties/index.d.ts +37 -0
  22. package/dist/unicode-properties/index.mjs +246 -0
  23. package/dist/unicode-properties/index.mjs.map +7 -0
  24. package/dist/unicode-properties/index.umd.js +640 -0
  25. package/dist/unicode-properties/index.umd.js.map +7 -0
  26. package/dist/unicode-trie/builder.cjs +821 -0
  27. package/dist/unicode-trie/builder.cjs.map +7 -0
  28. package/dist/unicode-trie/builder.d.ts +19 -0
  29. package/dist/unicode-trie/builder.mjs +799 -0
  30. package/dist/unicode-trie/builder.mjs.map +7 -0
  31. package/dist/unicode-trie/index.cjs +125 -0
  32. package/dist/unicode-trie/index.cjs.map +7 -0
  33. package/dist/unicode-trie/index.d.ts +19 -0
  34. package/dist/unicode-trie/index.mjs +103 -0
  35. package/dist/unicode-trie/index.mjs.map +7 -0
  36. package/dist/unicode-trie/index.umd.js +498 -0
  37. package/dist/unicode-trie/index.umd.js.map +7 -0
  38. package/package.json +14 -13
  39. package/src/base.js +33 -0
  40. package/src/index.js +2 -1
  41. package/src/node.js +7 -1
  42. package/types/index.d.ts +27 -16
@@ -138,16 +138,15 @@ export interface VariationAxisInfo {
138
138
  max: number;
139
139
  }
140
140
 
141
- /** Font subset writer. */
141
+ /** Font subset writer (sync encode only in @cantoo/fontkit). */
142
142
  export interface Subset {
143
143
  includeGlyph(glyph: Glyph | number): number;
144
- encodeStream(): unknown;
145
- encode(cb?: (err: Error | null, data?: Uint8Array) => void): Promise<Uint8Array> | void;
144
+ /** Encode the subset as a font buffer (synchronous). */
145
+ encode(): Uint8Array;
146
146
  }
147
147
 
148
148
  /**
149
- * An opened font (or a font selected from a collection).
150
- * Matches the public surface of TTFFont / WOFF / WOFF2 / etc.
149
+ * An opened single font face (TTF / OTF / WOFF / WOFF2).
151
150
  */
152
151
  export interface Font {
153
152
  type: string;
@@ -193,14 +192,20 @@ export interface Font {
193
192
  getGlyph(glyph: number, characters?: number[]): Glyph | null;
194
193
  createSubset(): Subset;
195
194
  getVariation(variation: string | Record<string, number> | number[]): Font;
196
- getFont?(
197
- postscriptName: string | Uint8Array | Record<string, number>
198
- ): Font | null | undefined;
195
+ }
196
+
197
+ /**
198
+ * A TrueType Collection (TTC) or Mac DFont container.
199
+ */
200
+ export interface FontCollection {
201
+ type: 'TTC' | 'DFont' | string;
202
+ readonly fonts: Font[];
203
+ getFont(postscriptName: string | Uint8Array): Font | null;
199
204
  }
200
205
 
201
206
  /** Constructible font format registered with registerFormat(). */
202
207
  export interface FontFormat {
203
- new (stream: unknown, variationCoords?: number[] | null): Font;
208
+ new (stream: unknown, variationCoords?: number[] | null): Font | FontCollection;
204
209
  probe(buffer: ArrayBufferView): boolean;
205
210
  }
206
211
 
@@ -208,23 +213,29 @@ export declare let logErrors: boolean;
208
213
  export declare let defaultLanguage: string;
209
214
 
210
215
  export declare function registerFormat(format: FontFormat): void;
216
+ export declare function setDefaultLanguage(lang?: string): void;
217
+
218
+ /** Open a font or collection from a buffer (no face selected). */
219
+ export declare function create(buffer: ArrayBufferView): Font | FontCollection;
220
+ /** Open a buffer and select a face by PostScript name. */
211
221
  export declare function create(
212
222
  buffer: ArrayBufferView,
213
- postscriptName?: string | Uint8Array
214
- ): Font | null | undefined;
215
- export declare function setDefaultLanguage(lang?: string): void;
223
+ postscriptName: string | Uint8Array
224
+ ): Font | null;
216
225
 
217
226
  /** Node-only: open a font file asynchronously. */
227
+ export declare function open(filename: string | import('fs').PathLike): Promise<Font | FontCollection>;
218
228
  export declare function open(
219
229
  filename: string | import('fs').PathLike,
220
- postscriptName?: string | Uint8Array
221
- ): Promise<Font | null | undefined>;
230
+ postscriptName: string | Uint8Array
231
+ ): Promise<Font | null>;
222
232
 
223
233
  /** Node-only: open a font file synchronously. */
234
+ export declare function openSync(filename: string | import('fs').PathLike): Font | FontCollection;
224
235
  export declare function openSync(
225
236
  filename: string | import('fs').PathLike,
226
- postscriptName?: string | Uint8Array
227
- ): Font | null | undefined;
237
+ postscriptName: string | Uint8Array
238
+ ): Font | null;
228
239
 
229
240
  declare const fontkit: {
230
241
  logErrors: boolean;
@@ -33,6 +33,24 @@ var defaultLanguage = "en";
33
33
  function setDefaultLanguage(lang = "en") {
34
34
  defaultLanguage = lang;
35
35
  }
36
+ var fontkit = {
37
+ get logErrors() {
38
+ return logErrors;
39
+ },
40
+ set logErrors(value) {
41
+ logErrors = value;
42
+ },
43
+ get defaultLanguage() {
44
+ return defaultLanguage;
45
+ },
46
+ set defaultLanguage(value) {
47
+ defaultLanguage = value;
48
+ },
49
+ registerFormat,
50
+ create,
51
+ setDefaultLanguage
52
+ };
53
+ var base_default = fontkit;
36
54
 
37
55
  // src/decorators.js
38
56
  function cache(target, key, descriptor) {
@@ -16956,8 +16974,10 @@ registerFormat(WOFFFont);
16956
16974
  registerFormat(WOFF2Font);
16957
16975
  registerFormat(TrueTypeCollection);
16958
16976
  registerFormat(DFont);
16977
+ var src_default = base_default;
16959
16978
  export {
16960
16979
  create,
16980
+ src_default as default,
16961
16981
  defaultLanguage,
16962
16982
  logErrors,
16963
16983
  registerFormat,