Serve fonts

This commit is contained in:
Petr Sloup
2016-03-11 09:48:35 +01:00
parent b98b7244f6
commit d742672238
3 changed files with 68 additions and 3 deletions
+15 -1
View File
@@ -7,7 +7,7 @@ var clone = require('clone'),
express = require('express');
module.exports = function(repo, options, id, reportVector) {
module.exports = function(repo, options, id, reportVector, reportFont) {
var app = express().disable('x-powered-by');
var rootPath = path.join(process.cwd(), options.root || '');
@@ -25,6 +25,20 @@ module.exports = function(repo, options, id, reportVector) {
}
});
var findFontReferences = function(obj) {
Object.keys(obj).forEach(function(key) {
var value = obj[key];
if (key == 'text-font') {
if (value && value.length > 0) {
value.forEach(reportFont);
}
} else if (value && typeof value == 'object') {
findFontReferences(value);
}
});
};
styleJSON.layers.forEach(findFontReferences);
var spritePath = path.join(rootPath, styleJSON.sprite);
styleJSON.sprite = 'local://styles/' + id + '/sprite';