@@ -8,44 +8,7 @@ var handleLineDefaults = require('../scatter/line_defaults');
88var handleTextDefaults = require ( '../scatter/text_defaults' ) ;
99var handleFillColorDefaults = require ( '../scatter/fillcolor_defaults' ) ;
1010var 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 ;
4912
5013module . exports = function supplyDefaults ( traceIn , traceOut , defaultColor , layout ) {
5114 function coerce ( attr , dflt ) {
@@ -104,12 +67,14 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
10467 var clusterEnabled = coerce ( 'cluster.enabled' , clusterEnabledDflt ) ;
10568
10669 if ( clusterEnabled || subTypes . hasText ( traceOut ) ) {
70+ var layoutFontFamily = layout . font . family ;
71+
10772 handleTextDefaults ( traceIn , traceOut , layout , coerce ,
10873 {
10974 noSelect : true ,
11075 noFontVariant : true ,
11176 font : {
112- family : supportedFonts . indexOf ( layout . font . family ) !== - 1 ? layout . font . family : 'Open Sans Regular' ,
77+ family : isSupportedFont ( layoutFontFamily ) ? layoutFontFamily : 'Open Sans Regular' ,
11378 weight : layout . font . weight ,
11479 style : layout . font . style ,
11580 size : layout . font . size ,
0 commit comments