ernestdefoe / google-fonts
Use any Google Font on your Flarum 2 forum â pick a body font and a heading font from the full Google Fonts library, applied site-wide.
Package info
github.com/ernestdefoe/google-fonts
Type:flarum-extension
pkg:composer/ernestdefoe/google-fonts
Requires
- flarum/core: ^2.0
README
Use any Google Font on your Flarum 2 forum â or upload and self-host your own. Pick a body font and a heading font, applied site-wide, with a live preview right in the admin panel.
Features
- ð Searchable picker for a curated list of popular Google Fonts, in the admin settings â and you can type/paste any Google Font family name, even ones not in the list.
- âŽïļ Upload your own font (self-hosting): upload one
.woff2per weight and the forum serves the font itself, with no call to Google. This works everywhere â including regions where Google Fonts is blocked, such as mainland China â and avoids the GDPR concern of fetching fonts from Google on every page view. - âïļ Separate body and heading fonts, so you can pair (e.g.) Inter body text with Playfair Display headings.
- ð Live preview of each font directly in the admin panel.
- ⥠Server-side injection into the page
<head>â no flash of unstyled text, no client round-trip. The Google stylesheet is loaded non-render-blocking, so even on the Google path an unreachable Google never stalls page paint; visitors simply keep the system-font fallback. - ðŠķ No configuration files, no API key required.
Installation
composer require ernestdefoe/google-fonts
Then enable Google Fonts in your admin panel.
Usage
- Go to Admin â Google Fonts.
- Set a Body font and (optionally) a Heading font.
- Start typing to search, or paste an exact family name from fonts.google.com.
- Click Save. The fonts apply to your forum immediately.
Leave a field blank to fall back to your theme's default font.
Self-hosting a font (works where Google is blocked)
- Under a font, click Upload your own font.
- Give the font a name (this is just the family label used internally).
- For each weight you want (Regular, Bold, âĶ), pick the weight and upload a
.woff2file. A variable.woff2covers every weight in a single file; a static file gets browser-synthesized bold for weights you don't upload. - Uploads save immediately â no Save click needed for the files.
Only .woff2 is accepted (it's the smallest, universally-supported web font
format). If you have a .ttf/.otf, convert it once with any free online
woff2 converter. To go back to a Google font, click Use a Google font
instead (this removes the uploaded files).
Updating
composer update ernestdefoe/google-fonts php flarum cache:clear