fontaine 0.0.2 → 0.1.0

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/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
 
8
8
  > Automatic font fallback based on font metrics
9
9
 
10
- - [✨  Changelog](https://github.com/danielroe/nuxt-font-metrics/blob/main/CHANGELOG.md)
11
- - [▶️  Online playground](https://stackblitz.com/github/danielroe/nuxt-font-metrics/tree/main/playground)
10
+ - [✨  Changelog](https://github.com/danielroe/fontaine/blob/main/CHANGELOG.md)
11
+ - [▶️  Online playground](https://stackblitz.com/github/danielroe/fontaine/tree/main/playground)
12
12
 
13
13
  ## Features
14
14
 
@@ -71,6 +71,9 @@ export default {
71
71
  }
72
72
  ```
73
73
 
74
+ > **Note**
75
+ > If you are using Nuxt, check out [nuxt-font-metrics](https://github.com/danielroe/nuxt-font-metrics) which uses `fontaine` under the hood.
76
+
74
77
  ## How it works
75
78
 
76
79
  `fontaine` will scan your `@font-face` rules and generate fallback rules with the correct metrics. For example:
@@ -83,7 +86,7 @@ export default {
83
86
  format('woff');
84
87
  font-weight: 700;
85
88
  }
86
- /* This will be generated. */
89
+ /* This additional font-face declaration will be added to your CSS. */
87
90
  @font-face {
88
91
  font-family: 'Roboto override';
89
92
  src: local('BlinkMacSystemFont'), local('Segoe UI'), local('Roboto'), local(
package/dist/index.cjs CHANGED
@@ -104,7 +104,7 @@ const FontaineTransform = unplugin.createUnplugin(
104
104
  const cssContext = options.css = options.css || {};
105
105
  cssContext.value = "";
106
106
  return {
107
- name: "nuxt-font-metrics-transform",
107
+ name: "fontaine-transform",
108
108
  enforce: "pre",
109
109
  transformInclude(id) {
110
110
  const { pathname } = ufo.parseURL(id);
@@ -170,3 +170,7 @@ const FONT_FAMILY_RE = magicRegexp.createRegExp(
170
170
  );
171
171
 
172
172
  exports.FontaineTransform = FontaineTransform;
173
+ exports.generateFontFace = generateFontFace;
174
+ exports.generateOverrideName = generateOverrideName;
175
+ exports.getMetricsForFamily = getMetricsForFamily;
176
+ exports.readMetrics = readMetrics;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as unplugin from 'unplugin';
2
+ import { Font } from '@capsizecss/unpack';
2
3
 
3
4
  interface FontaineTransformOptions {
4
5
  css?: {
@@ -10,4 +11,37 @@ interface FontaineTransformOptions {
10
11
  }
11
12
  declare const FontaineTransform: unplugin.UnpluginInstance<FontaineTransformOptions>;
12
13
 
13
- export { FontaineTransform };
14
+ declare const generateOverrideName: (name: string) => string;
15
+ interface GenerateOptions {
16
+ name: string;
17
+ fallbacks: string[];
18
+ [key: string]: any;
19
+ }
20
+ declare const generateFontFace: (metrics: Font, options: GenerateOptions) => string;
21
+
22
+ declare function getMetricsForFamily(family: string): Promise<{
23
+ familyName: string;
24
+ fullName: string;
25
+ postscriptName: string;
26
+ subfamilyName: string;
27
+ capHeight: number;
28
+ ascent: number;
29
+ descent: number;
30
+ lineGap: number;
31
+ unitsPerEm: number;
32
+ xHeight: number;
33
+ } | null>;
34
+ declare function readMetrics(_source: URL | string): Promise<{
35
+ familyName: string;
36
+ fullName: string;
37
+ postscriptName: string;
38
+ subfamilyName: string;
39
+ capHeight: number;
40
+ ascent: number;
41
+ descent: number;
42
+ lineGap: number;
43
+ unitsPerEm: number;
44
+ xHeight: number;
45
+ } | null>;
46
+
47
+ export { FontaineTransform, generateFontFace, generateOverrideName, getMetricsForFamily, readMetrics };
package/dist/index.mjs CHANGED
@@ -96,7 +96,7 @@ const FontaineTransform = createUnplugin(
96
96
  const cssContext = options.css = options.css || {};
97
97
  cssContext.value = "";
98
98
  return {
99
- name: "nuxt-font-metrics-transform",
99
+ name: "fontaine-transform",
100
100
  enforce: "pre",
101
101
  transformInclude(id) {
102
102
  const { pathname } = parseURL(id);
@@ -161,4 +161,4 @@ const FONT_FAMILY_RE = createRegExp(
161
161
  ["g"]
162
162
  );
163
163
 
164
- export { FontaineTransform };
164
+ export { FontaineTransform, generateFontFace, generateOverrideName, getMetricsForFamily, readMetrics };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fontaine",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "Automatic font fallback based on font metrics",
5
5
  "repository": "danielroe/fontaine",
6
6
  "keywords": [
@@ -83,5 +83,5 @@
83
83
  "resolutions": {
84
84
  "fontaine": "link:."
85
85
  },
86
- "packageManager": "pnpm@7.5.1"
86
+ "packageManager": "pnpm@7.12.2"
87
87
  }