A simple and flexible Node.js library for fetching and applying custom font styles from FontGen API.
npm install @saxx/font-stylerFont Styler is a simple and flexible Node.js library that allows you to fetch and apply custom font styles to text using the FontGen API. This library is perfect for creating stylized text for applications, websites, or any project requiring custom fonts.
- Fetch a list of available fonts.
- Apply custom font styles to text dynamically.
- Easy-to-use API with detailed error handling.
- Lightweight and efficient.
- Total Downloads: !npm
- Weekly Downloads: !npm
To install the library, use npm:
``bash`
npm install @saxx/font-styler@latest
Here’s a quick example of how to use Font Styler:
`javascript`
const { fontStyle, applyFont, fontStyler, getFontStyle, allFont, listFont, getAllFonts, fetchFonts } = require('@saxx/font-styler');
`javascript
const { fontStyle, applyFont, fontStyler, getFontStyle, allFont, listFont, getAllFonts, fetchFonts } = require('@saxx/font-styler');
fontStyle('hello', 'monospace').then(result => {
console.log("Styled Text:", result);
}).catch(err => {
console.error("Error:", err);
});
`
`javascript
const { fontStyle, applyFont, fontStyler, getFontStyle, allFont, listFont, getAllFonts, fetchFonts } = require('@saxx/font-styler');
allFont().then(result => {
console.log("Available Fonts:", result);
}).catch(err => {
console.log("Error:", err);
});
`
Applies a custom font style to the given text.
- Parameters:
- text (string): The text to style.font
- (string): The name of the font to apply.
- Returns: A styled version of the text as a string.
- Throws: An error if the font is not found or if there is an issue with the API.
---
Fetches a list of all available fonts.
- Returns: An objects with font_name: "Sample Text"`.
- Throws: An error if there is an issue with the API.
---
The library provides meaningful error messages for issues such as:
- Font not found.
- Network errors while accessing the API.
Font Styler depends on the following package:
- axios for making HTTP requests.
Contributions are welcome! If you have any ideas, improvements, or bug fixes, feel free to submit a pull request or open an issue on GitHub.
This project is licensed under the ISC License. See the LICENSE file for more details.
- Mesbah Saxx
GitHub Profile
---
- Repository: Font Styler GitHub
- Issues: Submit Issues
- Homepage: Font Styler Homepage