File tree Expand file tree Collapse file tree 6 files changed +6654
-6
lines changed Expand file tree Collapse file tree 6 files changed +6654
-6
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ const App = () => (
26
26
{
27
27
font: ' Roboto' ,
28
28
weights: [400 ],
29
+ subsets: [' cyrillic-ext' , ' greek' ],
29
30
},
30
31
{
31
32
font: ' Roboto Mono' ,
32
33
weights: [400 , 700 ],
34
+ subsets: [' cyrillic-ext' , ' greek' ],
33
35
},
34
36
]} / >
35
37
@@ -48,6 +50,7 @@ The Component takes one prop: `fonts`. It should be an array of objects describi
48
50
{
49
51
font: ' Roboto Mono' , // The name of the font on Google Fonts.
50
52
weights: [400 , 700 ], // An array of weights you want to load.
53
+ [' cyrillic-ext' , ' greek' ], // An array of subsets you want to load.
51
54
},
52
55
// ...
53
56
// You can include as many of these objects as you want.
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import * as React from 'react';
2
2
3
3
export interface Font {
4
4
font : string ;
5
- weights ?: number [ ] ;
5
+ weights ?: string [ ] ;
6
+ subsets ?: string [ ] ;
6
7
}
7
8
8
9
export interface GoogleFontLoaderProps {
Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ var GoogleFontLoader = function (_React$PureComponent) {
43
43
var families = fonts . reduce ( function ( acc , font ) {
44
44
var family = font . font . replace ( / + / g, '+' ) ;
45
45
var weights = ( font . weights || [ ] ) . join ( ',' ) ;
46
+ var subsets = ( font . subsets || [ ] ) . join ( ',' ) ;
46
47
47
- acc . push ( family + ( weights && ':' + weights ) ) ;
48
+ acc . push ( family + ( weights && ':' + weights ) + ( subsets && '&subset=' + subsets ) ) ;
48
49
49
50
return acc ;
50
51
} , [ ] ) . join ( '|' ) ;
@@ -93,7 +94,8 @@ var GoogleFontLoader = function (_React$PureComponent) {
93
94
GoogleFontLoader . propTypes = {
94
95
fonts : _propTypes2 . default . arrayOf ( _propTypes2 . default . shape ( {
95
96
font : _propTypes2 . default . string . isRequired ,
96
- weights : _propTypes2 . default . arrayOf ( _propTypes2 . default . number )
97
+ weights : _propTypes2 . default . arrayOf ( _propTypes2 . default . string ) ,
98
+ subsets : _propTypes2 . default . arrayOf ( _propTypes2 . default . string )
97
99
} ) ) . isRequired
98
100
} ;
99
101
You can’t perform that action at this time.
0 commit comments