Custom Fonts Plugin
The DmfCustomFonts plugin enables the use of custom fonts in your Shopware 6 shop. You can upload your own font files or choose from 16 pre-installed Google Fonts.
On this page:
Requirements
- Shopware 6.7.0 or higher
- PHP 8.2 or higher
Installation
composer require dmf/plugin-custom-fonts
bin/console plugin:install --activate DmfCustomFonts
bin/console cache:clearFeatures
- Two Font Slots: Normal Font (body text) and Headline Font (headings)
- Custom Font Files: Support for
.woffand.woff2formats - Font-Weight Support: Define different font weights per font
- Automatic CSS Generation: CSS is automatically created and included
- 16 Google Fonts: Pre-installed selection of popular fonts
- Inline or File: CSS can be included inline or as a separate file
Configuration
Path: Settings → System → Plugins → Custom Fonts → Configuration
| Option | Type | Default | Description |
|---|---|---|---|
includeAsFile | Boolean | false | Include CSS as separate file (default: inline) |
normalFontName | Text | - | Name of the font for body text |
normalFontFiles | Textarea | - | Font files with weight (format: filename.woff2 400) |
headlineFontName | Text | - | Name of the font for headings |
headlineFontFiles | Textarea | - | Headline font files with weight |
Font File Format
Enter one font file per line with optional font-weight:
OpenSans-Regular.woff2 400
OpenSans-Bold.woff2 700
OpenSans-Light.woff2 300Without weight specification, 400 (normal) is used.
Usage
Upload Custom Fonts
Upload your font files (
.woff,.woff2) to the folder:public/bundles/dmfcustomfonts/fonts/Open the plugin configuration in Admin
Enter the font name (e.g.,
MyCustomFont)List the font files with weights:
MyCustomFont-Regular.woff2 400 MyCustomFont-Bold.woff2 700Save the configuration
Pre-installed Google Fonts
The plugin includes 16 pre-installed Google Fonts that can be used directly:
| Font | Weights | Style |
|---|---|---|
| Open Sans | 400, 700 | Sans-Serif |
| Bodoni Moda | 400, 700 | Serif |
| Figtree | 400, 700 | Sans-Serif |
| Fira Sans | 400, 700 | Sans-Serif |
| Lato | 400, 700 | Sans-Serif |
| Noto Sans | 400, 700 | Sans-Serif |
| Nunito | 400, 700 | Sans-Serif |
| Playfair | 400, 700 | Serif |
| Poppins | 400, 700 | Sans-Serif |
| PT Sans | 400, 700 | Sans-Serif |
| Roboto | 400, 700 | Sans-Serif |
| Roboto Condensed | 400, 700 | Sans-Serif |
| Source Sans 3 | 400, 700 | Sans-Serif |
| Source Serif 4 | 400, 700 | Serif |
| Space Grotesk | 400, 700 | Sans-Serif |
| Work Sans | 400, 700 | Sans-Serif |
Console Commands
dmf:fonts:generate
Manually regenerate the font CSS file.
bin/console dmf:fonts:generateThis command runs automatically on:
- Plugin activation
- Plugin update
- Configuration change
Technical Details
CSS Generation
The plugin automatically generates @font-face rules based on your configuration:
@font-face {
font-family: 'MyCustomFont';
src: url('/bundles/dmfcustomfonts/fonts/MyCustomFont-Regular.woff2') format('woff2');
font-weight: 400;
font-display: swap;
}Event Listener
The plugin responds to SystemConfigMultipleChangedEvent and automatically regenerates CSS on configuration changes.
Troubleshooting
Font not displaying
- Check if font files are in the correct folder
- Run
bin/console assets:install - Clear cache:
bin/console cache:clear - Regenerate CSS:
bin/console dmf:fonts:generate
CSS not loading
Ensure the file path is correct:
public/bundles/dmfcustomfonts/fonts/[your-font-file].woff2