Merge remote-tracking branch 'klokantech/master' into public_url
# Conflicts: # src/main.js # src/server.js
This commit is contained in:
21
src/utils.js
21
src/utils.js
@@ -93,7 +93,20 @@ var getFontPbf = function(allowedFonts, fontPath, name, range, fallbacks) {
|
||||
if (err) {
|
||||
console.error('ERROR: Font not found:', name);
|
||||
if (fallbacks && Object.keys(fallbacks).length) {
|
||||
var fallbackName = Object.keys(fallbacks)[0];
|
||||
var fallbackName;
|
||||
|
||||
var fontStyle = name.split(' ').pop();
|
||||
if (['Regular', 'Bold', 'Italic'].indexOf(fontStyle) < 0) {
|
||||
fontStyle = 'Regular';
|
||||
}
|
||||
fallbackName = 'Noto Sans ' + fontStyle;
|
||||
if (!fallbacks[fallbackName]) {
|
||||
fallbackName = 'Open Sans ' + fontStyle;
|
||||
if (!fallbacks[fallbackName]) {
|
||||
fallbackName = Object.keys(fallbacks)[0];
|
||||
}
|
||||
}
|
||||
|
||||
console.error('ERROR: Trying to use', fallbackName, 'as a fallback');
|
||||
delete fallbacks[fallbackName];
|
||||
getFontPbf(null, fontPath, fallbackName, range, fallbacks).then(resolve, reject);
|
||||
@@ -119,9 +132,7 @@ module.exports.getFontsPbf = function(allowedFonts, fontPath, names, range, fall
|
||||
);
|
||||
});
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
Promise.all(queue).then(function(values) {
|
||||
return resolve(glyphCompose.combine(values));
|
||||
}, reject);
|
||||
return Promise.all(queue).then(function(values) {
|
||||
return glyphCompose.combine(values);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user