How to use a custom font in XWiki?
Last modified by Nikita Petrenko on 2024/12/27
Use remote fonts
For instance, Google Fonts:
- Go into Browse Fonts - Google Fonts page
- Select any desired font style (you can observe it in live editor)
- Copy and save the name of the font temporarily (here, we'll use "Lumanosimo")
- Go into CSS API - Google Fonts page
- Modify the code below (replace "Lumanosimo" with the name of your desired font)<link rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Lumanosimo">
<style>
body {
font-family: 'Lumanosimo', serif;
font-size: 20px;
}
</style> - Next, apply to your XWiki: navigate to Administer Wiki → Look & Feel → Presentation → HTTP Meta Info. Place the above code into the end of the field (do not overwrite the existing lines).
- Finally, go to Administer Wiki → Look & Feel → Themes → Customize, from Color Theme section → click on Typography and fill these 2 fields @font-family-base and @font-family-sans-serif with the name "Lumanosimo" observe the changes in the preview window (it'll refresh automatically)
- Save changes
Upload locally custom FFT file
Using XWiki folder
We'll use the same Google Fonts "Lumanosimo":
- Download this font or desired one from Browse Fonts - Google Fonts page
- Unzip it in XWiki folder /webapps/xwiki/WEB-INF/fonts. After this, restart is mandatory
- Repeat step #7 from the previous section and save the changes.
Using System folder
- Unzip the downloaded font in OS system folder: for Windows users C:\Windows\Fonts and for Linux users /usr/local/share/fonts After this, restarting the OS is mandatory. Instead of restarting, you can use Logout/Sing out option.
- Repeat step #7 from the previous section and save the changes.
The below image shows the font changes in XWiki.