@@ -16,6 +16,25 @@ const subsets = { /* eslint-disable quote-props */
1616 'pl_PL' : 'latin-ext' ,
1717}
1818
19+ // See https://github.com/system-fonts/modern-font-stacks
20+ const MODERN_FONTS = {
21+ 'system-ui' : 'system-ui, sans-serif' ,
22+ 'transitional' : "Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif" ,
23+ 'old-style' : "'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif" ,
24+ 'humanist' : "Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif" ,
25+ 'geometric-humanist' : "Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif" ,
26+ 'classical-humanist' : "Optima, Candara, 'Noto Sans', source-sans-pro, sans-serif" ,
27+ 'neo-grotesque' : "Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif" ,
28+ 'monospace-slab-serif' : "'Nimbus Mono PS', 'Courier New', monospace" ,
29+ 'monospace-code' : "ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace" ,
30+ 'industrial' : "Bahnschrift, 'DIN Alternate', 'Franklin Gothic Medium', 'Nimbus Sans Narrow', sans-serif-condensed, sans-serif" ,
31+ 'rounded-sans' : "ui-rounded, 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, Manjari, 'Arial Rounded MT', 'Arial Rounded MT Bold', Calibri, source-sans-pro, sans-serif" ,
32+ 'slab-serif' : "Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', serif" ,
33+ 'antique' : "Superclarendon, 'Bookman Old Style', 'URW Bookman', 'URW Bookman L', 'Georgia Pro', Georgia, serif" ,
34+ 'didone' : "Didot, 'Bodoni MT', 'Noto Serif Display', 'URW Palladio L', P052, Sylfaen, serif" ,
35+ 'handwritten' : "'Segoe Print', 'Bradley Hand', Chilanka, TSCu_Comic, casual, cursive" ,
36+ }
37+
1938export const getGoogleFontURL = fontName => {
2039 const family = fontName . replace ( / / g, '+' )
2140 const subset = subsets [ locale ] ? `&subset=${ subsets } ` : ''
@@ -94,37 +113,9 @@ export const getFontFamily = fontName => {
94113 return fontName
95114 }
96115
97- // Modern font stacks. See https://github.com/system-fonts/modern-font-stacks
98- if ( fontName . match ( / ^ s y s t e m - u i $ / i ) ) {
99- return 'system-ui, sans-serif'
100- } else if ( fontName . match ( / ^ t r a n s i t i o n a l $ / i ) ) {
101- return "Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif"
102- } else if ( fontName . match ( / ^ o l d - s t y l e $ / i ) ) {
103- return "'Iowan Old Style', 'Palatino Linotype', 'URW Palladio L', P052, serif"
104- } else if ( fontName . match ( / ^ h u m a n i s t $ / i ) ) {
105- return "Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"
106- } else if ( fontName . match ( / ^ g e o m e t r i c - h u m a n i s t $ / i ) ) {
107- return "Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif"
108- } else if ( fontName . match ( / ^ c l a s s i c a l - h u m a n i s t $ / i ) ) {
109- return "Optima, Candara, 'Noto Sans', source-sans-pro, sans-serif"
110- } else if ( fontName . match ( / ^ n e o - g r o t e s q u e $ / i ) ) {
111- return "Inter, Roboto, 'Helvetica Neue', 'Arial Nova', 'Nimbus Sans', Arial, sans-serif"
112- } else if ( fontName . match ( / ^ m o n o s p a c e - s l a b - s e r i f $ / i ) ) {
113- return "'Nimbus Mono PS', 'Courier New', monospace"
114- } else if ( fontName . match ( / ^ m o n o s p a c e - c o d e $ / i ) ) {
115- return "ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace"
116- } else if ( fontName . match ( / ^ i n d u s t r i a l $ / i ) ) {
117- return "Bahnschrift, 'DIN Alternate', 'Franklin Gothic Medium', 'Nimbus Sans Narrow', sans-serif-condensed, sans-serif"
118- } else if ( fontName . match ( / ^ r o u n d e d - s a n s $ / i ) ) {
119- return "ui-rounded, 'Hiragino Maru Gothic ProN', Quicksand, Comfortaa, Manjari, 'Arial Rounded MT', 'Arial Rounded MT Bold', Calibri, source-sans-pro, sans-serif"
120- } else if ( fontName . match ( / ^ s l a b - s e r i f $ / i ) ) {
121- return "Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', 'Sitka Small', serif"
122- } else if ( fontName . match ( / ^ a n t i q u e $ / i ) ) {
123- return "Superclarendon, 'Bookman Old Style', 'URW Bookman', 'URW Bookman L', 'Georgia Pro', Georgia, serif"
124- } else if ( fontName . match ( / ^ d i d o n e $ / i ) ) {
125- return "Didot, 'Bodoni MT', 'Noto Serif Display', 'URW Palladio L', P052, Sylfaen, serif"
126- } else if ( fontName . match ( / ^ h a n d w r i t t e n $ / i ) ) {
127- return "'Segoe Print', 'Bradley Hand', Chilanka, TSCu_Comic, casual, cursive"
116+ // Modern font stacks.
117+ if ( fontName . toLowerCase ( ) in MODERN_FONTS ) {
118+ return MODERN_FONTS [ fontName . toLowerCase ( ) ]
128119 }
129120
130121 // Google Font.
0 commit comments