Font Face Styles
Table of Contents
Function name: getFontFaceStyles()
If you use the Porsche Design System components we inject a link to a stylesheet with all font-face definitions into the
head of your application as soon as our core is loaded. These definitions have to be downloaded from our CDN which makes
them a blocking resource. This can lead (for the first time) to a decent rendering glitch of your texts. To improve
rendering it is recommended to deliver critical CSS inline.
Therefore, we provide a ready to use partial in all @porsche-design-system/components-{js|angular|react|vue}
packages
which needs to be injected into the <head>
of your index.html
. The partial directly returns the <style>
tag with
all relevant font-face definitions.
An in-depth optimization guide can be found at
Vanilla Js Optimization .
Supported options#
prev next
Option Description Type Defaultcdn
Decides from which CDN the resources are loaded.'auto' | 'cn'
'auto'
format
Defines the output format of the partial. By default, it returns a html string. For jsx
it return a jsx element. For sha256
it returns a SHA-256 hash of the innerHTML to use in a Content Security Policy (CSP) .'html' | 'jsx' | 'sha256'
'html'
When using jsx
in the format
option, it is necessary to have react/jsx-runtime
as a dependency in the project
included.
Examples#
Project integration differs based on the project setup.
The following showcases the most common ways.
prev nextVanilla JS Angular React Vue Next <!-- index.html -->
< head >
</ head >
<!-- package.json (tested on macOS, the script may need to be adjusted depending on the operating system used) -->
<!-- make sure to adjust the path to the index.html file -->
"scripts" : {
"prestart" : "yarn replace" ,
"replace" : "placeholder='<!--PLACEHOLDER_FONT_FACE_STYLES-->' && partial=$placeholder$(node -e 'console.log(require(\"@porsche-design-system/components-js/partials\").getFontFaceStyles())') && regex=$placeholder'.*' && sed -i '' -E -e \"s^$regex^$partial^\" index.html"
<!-- Alternative: Force using China CDN -->
"replace" : "placeholder='<!--PLACEHOLDER_FONT_FACE_STYLES-->' && partial=$placeholder$(node -e 'console.log(require(\"@porsche-design-system/components-js/partials\").getFontFaceStyles({ cdn: \"cn\" }))') && regex=$placeholder'.*' && sed -i '' -E -e \"s^$regex^$partial^\" index.html"
}
Output
The result of this partial looks like this:<style data-pds-font-face-styles>
@ font -face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-arabic-bold. 1796 b 39 .woff 2 ') format('woff 2 ');unicode-range:U+ 0600 - 0671 ,U+ 06 A 1 ,U+ 06 A 4 ,U+ 06 BA,U+ 06 CC,U+ 06 D 5 ,U+ 06 F 8 ,U+ 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-arabic-regular. 413 b 375 .woff 2 ') format('woff 2 ');unicode-range:U+ 0600 - 0671 ,U+ 06 A 1 ,U+ 06 A 4 ,U+ 06 BA,U+ 06 CC,U+ 06 D 5 ,U+ 06 F 8 ,U+ 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-cyril-bold. 4 cb 90 bb.woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-cyril-regular.b 845952 .woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-cyril-semi-bold. 378 f 7 d 5 .woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-greek-bold.d 2546 b 1 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-greek-regular. 0 b 3 d 9 b 3 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-greek-semi-bold.f 3 a 9 ae 0 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-latin-bold. 0 fbdc 6 d.woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-latin-regular.b 8 f 1 c 20 .woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-latin-semi-bold.b 5 f 6 fca.woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-pashto-bold.f 30 f 194 .woff 2 ') format('woff 2 ');unicode-range:U+ 067 C,U+ 067 E,U+ 0681 ,U+ 0682 ,U+ 0685 ,U+ 0686 ,U+ 0689 ,U+ 067 C,U+ 0693 ,U+ 0696 ,U+ 0698 ,U+ 069 A,U+ 06 A 9 ,U+ 06 AB,U+ 06 AF,U+ 06 BC,U+ 06 CD,U+ 06 D 0 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-pashto-regular. 3989814 .woff 2 ') format('woff 2 ');unicode-range:U+ 067 C,U+ 067 E,U+ 0681 ,U+ 0682 ,U+ 0685 ,U+ 0686 ,U+ 0689 ,U+ 067 C,U+ 0693 ,U+ 0696 ,U+ 0698 ,U+ 069 A,U+ 06 A 9 ,U+ 06 AB,U+ 06 AF,U+ 06 BC,U+ 06 CD,U+ 06 D 0 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-thai-bold.b 9 e 9 f 23 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-thai-regular.ac 04 c 30 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-thai-semi-bold. 8 d 53572 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-urdu-bold. 49 a 86 a 4 .woff 2 ') format('woff 2 ');unicode-range:U+ 0679 ,U+ 0688 ,U+ 0691 ,U+ 06 BE,U+ 06 C 0 - 06 C 3 ,U+ 06 D 2 - 06 D 5 ,U+ 06 F 0 - 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.com/porsche-design-system/fonts/porsche-next-urdu-regular.ad 23819 .woff 2 ') format('woff 2 ');unicode-range:U+ 0679 ,U+ 0688 ,U+ 0691 ,U+ 06 BE,U+ 06 C 0 - 06 C 3 ,U+ 06 D 2 - 06 D 5 ,U+ 06 F 0 - 06 F 9 ;font-display:swap}
</style>
// Alternative : Force using China CDN
<style data-pds-font-face-styles>
@ font -face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-arabic-bold. 1796 b 39 .woff 2 ') format('woff 2 ');unicode-range:U+ 0600 - 0671 ,U+ 06 A 1 ,U+ 06 A 4 ,U+ 06 BA,U+ 06 CC,U+ 06 D 5 ,U+ 06 F 8 ,U+ 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-arabic-regular. 413 b 375 .woff 2 ') format('woff 2 ');unicode-range:U+ 0600 - 0671 ,U+ 06 A 1 ,U+ 06 A 4 ,U+ 06 BA,U+ 06 CC,U+ 06 D 5 ,U+ 06 F 8 ,U+ 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-cyril-bold. 4 cb 90 bb.woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-cyril-regular.b 845952 .woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-cyril-semi-bold. 378 f 7 d 5 .woff 2 ') format('woff 2 ');unicode-range:U+ 0400 - 04 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-greek-bold.d 2546 b 1 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-greek-regular. 0 b 3 d 9 b 3 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-greek-semi-bold.f 3 a 9 ae 0 .woff 2 ') format('woff 2 ');unicode-range:U+ 0370 - 03 FF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-latin-bold. 0 fbdc 6 d.woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-latin-regular.b 8 f 1 c 20 .woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-latin-semi-bold.b 5 f 6 fca.woff 2 ') format('woff 2 ');unicode-range:U+ 0020 - 007 F,U+ 0080 - 00 FF,U+ 0100 - 017 F,U+ 0180 - 024 F,U+ 0250 - 02 AF,U+ 02 B 0 - 02 FF,U+ 0300 - 036 F,U+ 1 E 00 - 1 EFF,U+ 2000 - 206 F,U+ 2070 - 209 F,U+ 20 A 0 - 20 CF,U+ 2100 - 214 F,U+ 2150 - 218 F,U+ 2190 - 21 FF,U+ 2200 - 22 FF,U+ 25 A 0 - 25 FF,U+ 2600 - 26 FF,U+FB 00 -FB 4 F,U+FE 70 -FEFF;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-pashto-bold.f 30 f 194 .woff 2 ') format('woff 2 ');unicode-range:U+ 067 C,U+ 067 E,U+ 0681 ,U+ 0682 ,U+ 0685 ,U+ 0686 ,U+ 0689 ,U+ 067 C,U+ 0693 ,U+ 0696 ,U+ 0698 ,U+ 069 A,U+ 06 A 9 ,U+ 06 AB,U+ 06 AF,U+ 06 BC,U+ 06 CD,U+ 06 D 0 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-pashto-regular. 3989814 .woff 2 ') format('woff 2 ');unicode-range:U+ 067 C,U+ 067 E,U+ 0681 ,U+ 0682 ,U+ 0685 ,U+ 0686 ,U+ 0689 ,U+ 067 C,U+ 0693 ,U+ 0696 ,U+ 0698 ,U+ 069 A,U+ 06 A 9 ,U+ 06 AB,U+ 06 AF,U+ 06 BC,U+ 06 CD,U+ 06 D 0 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-thai-bold.b 9 e 9 f 23 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-thai-regular.ac 04 c 30 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 600 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-thai-semi-bold. 8 d 53572 .woff 2 ') format('woff 2 ');unicode-range:U+ 0 E 00 - 0 E 7 F;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 700 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-urdu-bold. 49 a 86 a 4 .woff 2 ') format('woff 2 ');unicode-range:U+ 0679 ,U+ 0688 ,U+ 0691 ,U+ 06 BE,U+ 06 C 0 - 06 C 3 ,U+ 06 D 2 - 06 D 5 ,U+ 06 F 0 - 06 F 9 ;font-display:swap}@font-face{font-family:Porsche Next;font-style:normal;font-weight: 400 ;src:url('https://cdn.ui.porsche.cn/porsche-design-system/fonts/porsche-next-urdu-regular.ad 23819 .woff 2 ') format('woff 2 ');unicode-range:U+ 0679 ,U+ 0688 ,U+ 0691 ,U+ 06 BE,U+ 06 C 0 - 06 C 3 ,U+ 06 D 2 - 06 D 5 ,U+ 06 F 0 - 06 F 9 ;font-display:swap}
</style>