Jet
BuyFollow on X
  • Home
  • Satisfied Requirements
  • License
  • Architecture
    • Overview
    • Internal Dependency Graph
    • External Dependencies
    • Conventions
  • Recipes
    • Get Started
    • Add a Page
    • Customise Fonts
    • Customise Icons
    • Customise Languages
    • Customise Themes
    • Add an Environment Variable
  • Classes
    • Jet Mat Paginator Intl
    • Transloco HTTP Loader
  • Components
    • App Component
    • Footer Component
    • Home Page Component
    • Message Page Component
    • Not Found Page Component
    • Page Component
    • Profile Page Component
    • Reset Password Page Component
    • Settings Page Component
    • Sign In Page Component
    • Sign Out Page Component
    • Sign Up Page Component
    • Update Password Page Component
  • Constants
    • Color Scheme Options
    • Default Color Scheme Option
    • Default Language Option
    • Default Settings
    • Language Options
    • Navigation Menu Items
  • Directives
    • Analytics Directive
  • Enums
    • Bucket
    • LocalStorage Key
    • Query Param
    • SessionStorage Key
    • Table
  • Guards
    • Is Authenticated
    • Is Not Authenticated
  • Interfaces
    • Color Scheme Option
    • Language Option
    • Navigation Menu Item
    • Profile
    • Progress Bar Configuration
    • Settings
  • Services
    • Alert Service
    • Analytics Service
    • Logger Service
    • Profile Service
    • Progress Bar Service
    • Service Worker Service
    • Settings Service
    • Storage Service
    • Supabase Service
    • Toolbar Title Service
    • User Service
  • Types
    • Available Color Scheme
    • Available Font
    • Available Language
    • Available OAuth Provider
Powered by GitBook
On this page

Was this helpful?

  1. Recipes

Customise Fonts

PreviousAdd a PageNextCustomise Icons

Last updated 8 months ago

Was this helpful?

On , choose all the fonts you'd like to add. Ideally, each font should support 300, 400 and 500 font weights to support the various . Angular for performance.

If you'd like to use your proprietary fonts, add them to the public folder and index.html and/or add the to styles.scss. Ensure the CSP (Content Security Policy) rules in index.html are updated accordingly.

Let's use .

Step 1: Get the embed code for the three weights of all fonts and add it in the head element in index.html. Google Fonts can generate a combined link element for all your fonts or you can add one for each font.

index.html
<link
  href="https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:wght@300;400;500&display=swap"
  rel="stylesheet"
/>

Step 2: Use the font-family values shown above to create variables for each font in styles.scss. Be careful of the enclosing quotes.

styles.scss
$ibm-plex-serif-typography: mat.define-typography-config(
  $font-family: '"IBM Plex Serif", serif',
);

Step 3: If updating the default font, replace the typography property in the $default-theme variable and include the typography-hierarchy mixin for this font in the body element.

styles.scss
$default-theme: mat.define-light-theme(
  (
    color: (
      primary: mat.define-palette(mat.$brown-palette, 500),
      accent: mat.define-palette(mat.$amber-palette, 500),
    ),
    typography: $ibm-plex-serif-typography,
  )
);

body {
  @include mat.typography-hierarchy($ibm-plex-serif-typography);
}
available-font.type.ts
export type AvailableFont = 'ibm-plex-serif' | 'noto-sans-arabic';

Step 5: Update the Default Font constant.

default-font.constant.ts
export const DEFAULT_FONT: AvailableFont = 'ibm-plex-serif';

Step 6: Update the Language Options constant.

language-options.constant.ts
export const LANGUAGE_OPTIONS: LanguageOption[] = [
  {
    directionality: 'ltr',
    font: 'ibm-plex-serif',
    icon: 'translate',
    nameKey: 'english',
    value: 'en',
  },
  {
    directionality: 'rtl',
    font: 'noto-sans-arabic',
    icon: 'translate',
    nameKey: 'arabic',
    value: 'ar',
  },
];

Done!

Step 4: Update the type.

Available Font
Google Fonts
font weights used in Angular Material components
inlines fonts loaded via Google Fonts
@font-face
IBM Plex Serif
Choosing a font on Google Fonts
Jet in custom font
Choosing a font on Google Fonts
Jet in custom font