@@ -8,44 +8,7 @@ var handleLineDefaults = require('../scatter/line_defaults');
8
8
var handleTextDefaults = require ( '../scatter/text_defaults' ) ;
9
9
var handleFillColorDefaults = require ( '../scatter/fillcolor_defaults' ) ;
10
10
var attributes = require ( './attributes' ) ;
11
-
12
- // Must use one of the following fonts as the family, else default to 'Open Sans Regular'
13
- // See https://github.com/openmaptiles/fonts/blob/gh-pages/fontstacks.json
14
- var supportedFonts = [
15
- 'Metropolis Black Italic' ,
16
- 'Metropolis Black' ,
17
- 'Metropolis Bold Italic' ,
18
- 'Metropolis Bold' ,
19
- 'Metropolis Extra Bold Italic' ,
20
- 'Metropolis Extra Bold' ,
21
- 'Metropolis Extra Light Italic' ,
22
- 'Metropolis Extra Light' ,
23
- 'Metropolis Light Italic' ,
24
- 'Metropolis Light' ,
25
- 'Metropolis Medium Italic' ,
26
- 'Metropolis Medium' ,
27
- 'Metropolis Regular Italic' ,
28
- 'Metropolis Regular' ,
29
- 'Metropolis Semi Bold Italic' ,
30
- 'Metropolis Semi Bold' ,
31
- 'Metropolis Thin Italic' ,
32
- 'Metropolis Thin' ,
33
- 'Open Sans Bold Italic' ,
34
- 'Open Sans Bold' ,
35
- 'Open Sans Extra Bold Italic' ,
36
- 'Open Sans Extra Bold' ,
37
- 'Open Sans Italic' ,
38
- 'Open Sans Light Italic' ,
39
- 'Open Sans Light' ,
40
- 'Open Sans Regular' ,
41
- 'Open Sans Semibold Italic' ,
42
- 'Open Sans Semibold' ,
43
- 'Klokantech Noto Sans Bold' ,
44
- 'Klokantech Noto Sans CJK Bold' ,
45
- 'Klokantech Noto Sans CJK Regular' ,
46
- 'Klokantech Noto Sans Italic' ,
47
- 'Klokantech Noto Sans Regular'
48
- ] ;
11
+ var isSupportedFont = require ( './constants' ) . isSupportedFont ;
49
12
50
13
module . exports = function supplyDefaults ( traceIn , traceOut , defaultColor , layout ) {
51
14
function coerce ( attr , dflt ) {
@@ -104,12 +67,14 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
104
67
var clusterEnabled = coerce ( 'cluster.enabled' , clusterEnabledDflt ) ;
105
68
106
69
if ( clusterEnabled || subTypes . hasText ( traceOut ) ) {
70
+ var layoutFontFamily = layout . font . family ;
71
+
107
72
handleTextDefaults ( traceIn , traceOut , layout , coerce ,
108
73
{
109
74
noSelect : true ,
110
75
noFontVariant : true ,
111
76
font : {
112
- family : supportedFonts . indexOf ( layout . font . family ) !== - 1 ? layout . font . family : 'Open Sans Regular' ,
77
+ family : isSupportedFont ( layoutFontFamily ) ? layoutFontFamily : 'Open Sans Regular' ,
113
78
weight : layout . font . weight ,
114
79
style : layout . font . style ,
115
80
size : layout . font . size ,
0 commit comments