1.0.0 • Published 3 months ago

@imjano/iconifont v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

Iconifont

This Node.js package allows you to transform all SVG files in a directory into four font files: SVG, TTF, WOFF, and WOFF2. Additionally, it generates a CSS stylesheet to facilitate their usage in web projects.

Installation

To install this package, you can use npm:

npm install --save-dev @imjano/iconifont

Usage

Here's an example of how to use this package in a TypeScript project:

import generateIconifont, { IGenerateIconifontArgs } from '@imjano/iconifont'

async function generateFonts() {
	const options: GenerateIconifontArgs = {
		svgDirectory: './my_svg_directory',
		outputFontDirectory: './fonts',
		outputCSSDirectory: './css',
		fontName: 'myIconFont',
		classSuffix: 'icon',
		classAffix: 'font',
		classNotation: 'camelCase',
		baseUnicode: 'E001',
	}

	try {
		await generateIconifont(options)
		console.log('Fonts and stylesheet generated successfully!')
	} catch (error) {
		console.error('An error occurred while generating fonts:', error)
	}
}
ParameterDescription
svgDirectoryThe path to the directory containing the SVG files to be used for generating the fonts.
outputFontDirectoryThe path to the directory where the font files (SVG, TTF, WOFF, WOFF2) will be generated.
outputCSSDirectoryThe path to the directory where the CSS stylesheet will be generated.
fontNameThe name to be used for the generated font.
classSuffixThe suffix to be appended to the classes of the icons in the CSS stylesheet.
classAffixThe affix to be appended to the font name in the CSS stylesheet.
classNotationThe notation to be used for naming the classes of the icons in the CSS stylesheet.
baseUnicodeThe base Unicode value to be used for assigning Unicode codes to the icons in the stylesheet. It's recommended to use E001 as it falls within the "Private Use Area" of Unicode, ensuring no conflicts with standard characters.