Skip to content

Commit 46fbf6c

Browse files
committed
Expose getFontDetails API
1 parent ec60007 commit 46fbf6c

File tree

15 files changed

+4629
-6383
lines changed

15 files changed

+4629
-6383
lines changed

.eslintrc.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"standard-with-typescript",
8+
"plugin:react/recommended"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": "latest",
12+
"sourceType": "module",
13+
"project": ["./tsconfig.json"]
14+
},
15+
"plugins": [
16+
"react"
17+
],
18+
"rules": {
19+
"react/prop-types": 0,
20+
"indent": ["error", 2],
21+
"no-trailing-spaces": ["error"],
22+
"quotes": ["error", "single"],
23+
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
24+
"semi": ["error", "always"],
25+
"space-infix-ops": "error",
26+
"@typescript-eslint/semi": ["error", "always"],
27+
"@typescript-eslint/strict-boolean-expressions": "off"
28+
}
29+
}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.12.1

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,24 @@ You can customize the `<FontPreview />` component by either wrapping it in an el
3737
and customizing the element or by adding styles to the class `font-preview` in your
3838
css file. `font-preview` is the class assigned to the `div` that displays the text
3939
with font-preview.
40+
41+
## APIs
42+
### getFontDetails
43+
This function returns a promise that resolves to an object containing the font details.
44+
Returns an object that contains the following properties:
45+
- fontFamily: The font family name
46+
- fullName: The full name of the font
47+
- version: The version of the font
48+
- manufacturer: The manufacturer of the font
49+
- designer: The designer of the font
50+
- licence: The licence of the font
51+
52+
```javascript
53+
import { getFontDetails } from 'font-preview';
54+
55+
// Accepts font file url
56+
const fontMeta = await getFontDetails(fontUrl);
57+
58+
// Accepts loaded font file buffer
59+
const fontMeta = await getFontDetails(fontBuffer);
60+
```

0 commit comments

Comments
 (0)