Custom fonts (the Google Fonts plugin)
Custom fonts (the Google Fonts plugin)
The builder ships a custom Google Fonts picker so page authors can install and use any Google Font without touching CSS. This article covers setup and use. For the broader styling system see Styling and branding.
Set up the API key
The picker calls the Google Fonts Developer API from the builder, so it needs your own Google Fonts API key.
- Create a Google Fonts Developer API key in your Google Cloud project. Restrict it to the Google Fonts API and to your org and Site domains.
- Enter it in the
Portal__c custom setting field Google_Fonts_API_Key__c (Setup, Custom Settings, Portal).
- Reopen the builder.
If the key is missing, the picker shows an error when it opens, so a blank key surfaces immediately rather than failing silently.
How to use it
- Open a page in the builder.
- Click Install Fonts (the
A/font icon button) in the top options panel. The Fonts dialog opens.
- The dialog has two sections:
- All fonts: the full Google Fonts catalogue, searchable by name, filterable by category, paginated. Each row shows a live preview of the font.
- Installed fonts: the fonts you have added to this page, with per weight and per style (italic) variant checkboxes, a toggle all, and a remove button.
- Click a font to install it. It moves to the Installed list and becomes available immediately.
- Select any element on the canvas, open the style (typography) panel, and pick your installed font from the font family dropdown. Installed fonts are appended to the built in font list there.
- Save the page. The chosen fonts are baked into the published page (see persistence below), so they load on the live portal.
How fonts are applied
Two things happen when a font is installed:
- Canvas preview. The plugin injects a Google Fonts
<link> stylesheet (the css2 endpoint, display=swap, with a preconnect) into the builder canvas so the font renders live while you design. These preview links are replaced cleanly as you change fonts.
- Style panel. The installed fonts are added to the typography
font-family dropdown, each with a proper CSS value such as "Roboto", sans-serif, so selecting one writes a valid font family onto the element.
How fonts persist and load at runtime
- In the builder model. The installed font list is stored on the page's editor model and saved with the page, so reopening the page restores the picker state.
- In the published page. On save, the font
<link> tags are added to the published page ahead of the page markup. So the published Template_html.b3p already contains everything needed to load the fonts.
- At runtime. The portal does not run the picker. It simply renders the saved HTML, and because the font stylesheet links are already embedded, the browser loads the fonts directly from Google. There is no runtime call to the Google Fonts API and the API key is not needed on the live portal.
AI copilot integration
The AI page builder can list, install and remove fonts, so it can install or swap fonts as part of generating or editing a page. See The AI page builder.
Notes and limits
- The catalogue is fetched once per builder session and cached in
localStorage; reopen the builder to pick up newly published Google Fonts.
- The API key is used only in the builder, an internal admin tool, and is not needed on the live portal. Keep the builder pages off guest profiles. See the Security hardening checklist.
- Fonts are per page. Installing a font on one page does not install it on another; use a dynamic sub template for shared chrome if you want one place to manage shared fonts. See Static and dynamic pages.