Download the PHP package log1x/laravel-webfonts without Composer
On this page you can find all versions of the php package log1x/laravel-webfonts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download log1x/laravel-webfonts
More information about log1x/laravel-webfonts
Files in log1x/laravel-webfonts
Package laravel-webfonts
Short Description Download, install, and preload over 1500 Google fonts locally in your Laravel project
License MIT
Informations about the package laravel-webfonts
Laravel Webfonts
Laravel Webfonts allows you to easily download, install, and preload over 1500 Google fonts locally in your Laravel project.

Features
- 🔍️ Search and install over 1500 Google fonts from the public google-webfonts-helper API.
- ⚡️ Automatically generate
@font-faceCSSat-ruleswhen installing fonts using CLI. - 🧑💻 Supports Vite out of the box with zero configuration.
- ⚡️ Provides an easy-to-use
@preloadFontsBlade directive to preload fonts found in the Vite manifest. - 🚀 Automatically injects font preload markup into
wp_headon WordPress sites running Acorn.
Requirements
Installation
Install via Composer:
Usage
If you already have fonts locally installed in your project, skip to Preloading Fonts.
Adding Fonts
Laravel Webfonts provides a very easy way to install new webfonts to your project using command line:
By default, installing a font will trigger the following things to happen:
- Download the font archive to a temporary directory in local storage.
- Extract the font archive.
- Move downloaded fonts to
resources/fonts. - Clean up the temporary directory.
- Generate and prepend
@font-faceat-rules to afontsstylesheet.
The fonts stylesheet will reside at the root of your stylesheet directory located in resources/. If the font stylesheet does not already exist, it will be created using the most common stylesheet extension (css, scss, ...) found among your styles.
By default, the resources/css and resources/styles directories are automatically scanned for existing files to find the appropriate place to write the fonts stylesheet.
The generated @font-face at-rules will look like this:
Adding additional fonts will cause them to be prepended to the existing fonts stylesheet.
Importing Fonts
When fonts are installed for the first time, a fonts stylesheet is created in your project's stylesheet folder. In a vanilla Laravel project, this is typically resources/css/fonts.css.
You must import the generated fonts file into your project's primary stylesheet (e.g. app.css). If you're using Tailwind, it would look something like:
Preloading Fonts
[!NOTE] If you are using WordPress alongside Acorn, you can ignore this section as preloading is automatically handled for you inside of
wp_headif an asset manifest containing valid fonts is detected.
Laravel Webfonts primary functionality while in production is to provide a simple way to preload your locally hosted webfonts.
This is done by reading the compiled woff2 fonts from your Vite manifest and generating the appropriate markup for you to place inside of <head>.
In most cases, you can simply use the @preloadFonts Blade directive to handle building and echoing the font preload HTML markup.
Alternatively to the Blade directive, you can access the PreloadFonts class directly using the Webfonts Facade:
Allowing/excluding certain fonts from being preloaded can be done inside register() of a service provider:
Bug Reports
If you discover a bug in Laravel Webfonts, please open an issue.
Contributing
Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.
License
Laravel Webfonts is provided under the MIT License.