Highlighted

3 Different Ways to Embed Custom Fonts in AEM Sites | AEM Community Blog Seeding

kautuk_sahni

Community Manager

23-09-2020

BlogImage.jpg

3 Different Ways to Embed Custom Fonts in AEM Sites by Sourced Code

Abstract

In this article, we will go through three different ways how you can embed custom fonts in an AEM site.

Embed Custom Font using Google Fonts, CDN
Embed Custom Font using Adobe Fonts, CDN
Embed Font via AEM Client Library Static Asset
1. Embed Custom Font using Google Fonts, CDN
Embed a custom font is by using Google Fonts. Google Fonts can be quickly installed into your project by using the @import CSS rule. Utilising the out of the box setup, you are prescribed to Google Font’s CDN. The lifecycle management of the fonts embedded onto your AEM site will be dependant on Google Font’s CDN servers.

There are hundreds of free font’s offered by Google. Simply visit the Google Font’s website to request for which fonts you wish to use on your website. Next obtain the @import CSS configuration that is offered by the webpage.

Embedding font via @import URL:2. Embed Custom Font using Adobe Fonts, CDN Embed a custom font is by using the Adobe Fonts, where fonts can be quickly installed into your project by using the @import CSS rule. After logging into Adobe Font’s, you can create a new project where you can select different fonts from Adobe Font’s collection to be used in your website. Retrieve the “embed code” CDN path from your Adobe Font’s project, and you are well on your way. Adobe Font's Projects Console, with Embed Code Next obtain the @import CSS configuration that is offered by the webpage. Embedding font via @import URL:3. Embed Font via AEM Client Library Static Asset The most common way to embed a custom font for an AEM project is to store web-safe font files directly into a client library. The fonts are then referenced by the CSS stylesheet, where the font file paths are the proxied client libraries URI. Using the CSS rule, @font-face, we are able to configure custom fonts for an AEM project. clientlib-site resources/font folder screenshot For how to Serve Static Assets in AEM as Client Library Resources, click here. Embedding font via @font-face URL:
AEM AEMEBlogSeeding Experience Manager