Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@fontsource/roboto
Advanced tools
@fontsource/roboto is an npm package that allows you to self-host the Roboto font in your web projects. It provides a convenient way to include the Roboto font family in your application without relying on external CDNs. This package supports various font weights and styles, making it versatile for different design needs.
Basic Usage
This code imports the default Roboto font into your project. It includes the regular weight and normal style.
import '@fontsource/roboto';
Specific Font Weight
This code imports the Roboto font with a weight of 500. You can specify different weights by changing the number in the import path.
import '@fontsource/roboto/500.css';
Specific Font Style
This code imports the italic style of the Roboto font. You can combine this with different weights as needed.
import '@fontsource/roboto/italic.css';
Advanced Usage with CSS
This code imports the Roboto font with a weight of 500 and italic style. This is useful for more advanced typography needs.
import '@fontsource/roboto/500-italic.css';
The typeface-roboto package is another option for self-hosting the Roboto font. It offers similar functionality to @fontsource/roboto but is part of the older 'typeface' package series. It may not be as actively maintained as @fontsource/roboto.
The fontsource-open-sans package allows you to self-host the Open Sans font, which is another popular sans-serif typeface. It offers similar features to @fontsource/roboto, including support for various weights and styles.
The fontsource-lato package provides the Lato font family for self-hosting. Like @fontsource/roboto, it supports multiple weights and styles, making it a versatile choice for web typography.
The CSS and web font files to easily self-host the “Roboto” font. Please visit the main Fontsource website to view more details on this package.
Fontsource offers multiple methods to import the CSS, including using a bundler like Vite or using SASS. You can find full documentation here.
npm install @fontsource/roboto
Within your app entry file or site component, import it in.
import "@fontsource/roboto"; // Defaults to weight 400
import "@fontsource/roboto/400.css"; // Specify weight
import "@fontsource/roboto/400-italic.css"; // Specify weight and style
Supported variables:
[100,300,400,500,700,900]
[italic,normal]
[cyrillic,cyrillic-ext,greek,greek-ext,latin,latin-ext,vietnamese]
Note:
italic
may not be supported by all fonts. To learn more about what weights and styles are supported, please visit the Fontsource website.
Finally, you can reference the font name in a CSS stylesheet, CSS Module, or CSS-in-JS.
body {
font-family: "Roboto";
}
Always make sure to read the license for each font you use. Most of the fonts in the collection use the SIL Open Font License, v1.1. Some fonts use the Apache 2 license. The Ubuntu fonts use the Ubuntu Font License v1.0.
Copyright 2011 Google Inc. All Rights Reserved. Apache-2.0
Font version (provided by source): v30
.
If you have any suggestions or ideas to improve the performance of font loading or expand the existing library, feel free to star and contribute to this repository. You can share your suggestions or ideas by creating an issue.
FAQs
Self-host the Roboto font in a neatly bundled NPM package.
We found that @fontsource/roboto 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.