Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@unocss/preset-web-fonts
Advanced tools
@unocss/preset-web-fonts is a preset for UnoCSS that allows you to easily integrate web fonts into your project. It simplifies the process of adding and managing web fonts by providing a set of utilities and configurations.
Basic Font Integration
This feature allows you to easily integrate basic web fonts into your project. You can specify different font families for sans, serif, and mono text.
import { defineConfig } from 'unocss';
import { presetWebFonts } from '@unocss/preset-web-fonts';
export default defineConfig({
presets: [
presetWebFonts({
fonts: {
sans: 'Roboto',
serif: 'Merriweather',
mono: 'Source Code Pro',
},
}),
],
});
Custom Font Weights and Styles
This feature allows you to specify custom font weights and styles, including italic variants, for your web fonts.
import { defineConfig } from 'unocss';
import { presetWebFonts } from '@unocss/preset-web-fonts';
export default defineConfig({
presets: [
presetWebFonts({
fonts: {
sans: [
{
name: 'Roboto',
weights: ['400', '700'],
italic: true,
},
],
},
}),
],
});
Google Fonts Integration
This feature allows you to easily integrate Google Fonts into your project by specifying the provider as 'google'.
import { defineConfig } from 'unocss';
import { presetWebFonts } from '@unocss/preset-web-fonts';
export default defineConfig({
presets: [
presetWebFonts({
provider: 'google',
fonts: {
sans: 'Roboto',
serif: 'Merriweather',
mono: 'Source Code Pro',
},
}),
],
});
The 'typeface' package allows you to self-host fonts by providing a collection of npm packages for popular fonts. Unlike @unocss/preset-web-fonts, which focuses on configuration and integration, 'typeface' provides the actual font files for self-hosting.
The 'webfontloader' package, developed by Google and Typekit, provides a more advanced and flexible way to load web fonts. It offers more control over font loading behavior compared to @unocss/preset-web-fonts, which focuses on ease of use and configuration.
Web fonts support for UnoCSS.
Please refer to the documentation.
MIT License © 2022-PRESENT Anthony Fu
FAQs
Web Fonts support for Uno CSS
We found that @unocss/preset-web-fonts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.