Skip to content

Custom Fonts Plugin

View 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

bash
composer require dmf/plugin-custom-fonts
bin/console plugin:install --activate DmfCustomFonts
bin/console cache:clear

Features

  • Two Font Slots: Normal Font (body text) and Headline Font (headings)
  • Custom Font Files: Support for .woff and .woff2 formats
  • 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

OptionTypeDefaultDescription
includeAsFileBooleanfalseInclude CSS as separate file (default: inline)
normalFontNameText-Name of the font for body text
normalFontFilesTextarea-Font files with weight (format: filename.woff2 400)
headlineFontNameText-Name of the font for headings
headlineFontFilesTextarea-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 300

Without weight specification, 400 (normal) is used.


Usage

Upload Custom Fonts

  1. Upload your font files (.woff, .woff2) to the folder:

    public/bundles/dmfcustomfonts/fonts/
  2. Open the plugin configuration in Admin

  3. Enter the font name (e.g., MyCustomFont)

  4. List the font files with weights:

    MyCustomFont-Regular.woff2 400
    MyCustomFont-Bold.woff2 700
  5. Save the configuration

Pre-installed Google Fonts

The plugin includes 16 pre-installed Google Fonts that can be used directly:

FontWeightsStyle
Open Sans400, 700Sans-Serif
Bodoni Moda400, 700Serif
Figtree400, 700Sans-Serif
Fira Sans400, 700Sans-Serif
Lato400, 700Sans-Serif
Noto Sans400, 700Sans-Serif
Nunito400, 700Sans-Serif
Playfair400, 700Serif
Poppins400, 700Sans-Serif
PT Sans400, 700Sans-Serif
Roboto400, 700Sans-Serif
Roboto Condensed400, 700Sans-Serif
Source Sans 3400, 700Sans-Serif
Source Serif 4400, 700Serif
Space Grotesk400, 700Sans-Serif
Work Sans400, 700Sans-Serif

Console Commands

dmf:fonts:generate

Manually regenerate the font CSS file.

bash
bin/console dmf:fonts:generate

This 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:

css
@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

  1. Check if font files are in the correct folder
  2. Run bin/console assets:install
  3. Clear cache: bin/console cache:clear
  4. Regenerate CSS: bin/console dmf:fonts:generate

CSS not loading

Ensure the file path is correct:

public/bundles/dmfcustomfonts/fonts/[your-font-file].woff2