Skip to content

Commit

Permalink
Expose getFontDetails API
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushjainrksh committed Jan 16, 2024
1 parent ec60007 commit 46fbf6c
Show file tree
Hide file tree
Showing 15 changed files with 4,629 additions and 6,383 deletions.
29 changes: 29 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": ["./tsconfig.json"]
},
"plugins": [
"react"
],
"rules": {
"react/prop-types": 0,
"indent": ["error", 2],
"no-trailing-spaces": ["error"],
"quotes": ["error", "single"],
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
"semi": ["error", "always"],
"space-infix-ops": "error",
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/strict-boolean-expressions": "off"
}
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.12.1
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,24 @@ You can customize the `<FontPreview />` component by either wrapping it in an el
and customizing the element or by adding styles to the class `font-preview` in your
css file. `font-preview` is the class assigned to the `div` that displays the text
with font-preview.

## APIs
### getFontDetails
This function returns a promise that resolves to an object containing the font details.
Returns an object that contains the following properties:
- fontFamily: The font family name
- fullName: The full name of the font
- version: The version of the font
- manufacturer: The manufacturer of the font
- designer: The designer of the font
- licence: The licence of the font

```javascript
import { getFontDetails } from 'font-preview';

// Accepts font file url
const fontMeta = await getFontDetails(fontUrl);

// Accepts loaded font file buffer
const fontMeta = await getFontDetails(fontBuffer);
```
Loading

0 comments on commit 46fbf6c

Please sign in to comment.