diff --git a/docs/2-advanced/14-fonts.md b/docs/2-advanced/14-fonts.md index a2d698700e5d..c20da8d4e687 100644 --- a/docs/2-advanced/14-fonts.md +++ b/docs/2-advanced/14-fonts.md @@ -1,31 +1,75 @@ -# Custom Fonts +# Fonts -During boot, the UI5 Web Components framework loads the necessary fonts to achieve the desired design of its components. +This article explains how fonts are handled in UI5 Web Components and the options available for customization. -**Important:** These fonts are fetched via network requests. +## Default Font Loading -## Customizing Fonts +During boot, the UI5 Web Components framework automatically loads the necessary fonts to achieve the SAP Fiori design. The fonts are fetched from a CDN (`cdn.jsdelivr.net`) via network requests. + +This default behavior requires no configuration - fonts are loaded automatically when you use UI5 Web Components. + + +## Custom (Manual) Font Loading There are several reasons why you might need to customize fonts: -- To specify different paths for fonts (e.g., due to restrictions on public internet access). -- To include additional declarations within `@font-face`. -- To download additional fonts, such as `72-Light`. -- To prevent the default fonts from being fetched. +- To specify different paths for fonts (e.g., due to restrictions on public internet access) +- To include additional declarations within `@font-face` (e.g., `font-display`) +- To download additional fonts, such as `72-Light` +- To prevent the default fonts from being fetched + + +### 1. Disable Default Fonts + +You can disable the default fonts by either creating a `style` tag with `data-ui5-font-face` attribute, or via the `defaultFontLoading` configuration option. + +- via ` +``` + +- via `defaultFontLoading` in your HTML + + +```html + +``` + +- via `setDefaultFontLoading` JS API -To achieve this, you can prevent the fetching of default fonts by configuring `setDefaultFontLoading (@ui5/webcomponents-base/dist/config/Fonts.js)` to `false`: ```ts -import { getDefaultFontLoading, setDefaultFontLoading } from "@ui5/webcomponents-base/dist/config/Fonts.js"; +import { setDefaultFontLoading } from "@ui5/webcomponents-base/dist/config/Fonts.js"; setDefaultFontLoading(false); ``` -Then, specify the custom font you intend to use. When the UI5 Web Components framework initializes, it will refrain from fetching default fonts and instead use the ones you have provided. +When the UI5 Web Components framework initializes, it will refrain from fetching default fonts and instead use the ones you have provided. + + +### 2. Provide Custom Font Definitions + +After disabling the default fonts, specify the custom fonts you intend to use. -To use the `72-Light` font in your application and specify the `font-display` setting, you should define the font in your application's styles. +For example, to use the `72-Light` font with a custom `font-display` setting: ```html -