Fix font compositing (close #32)

This commit is contained in:
Petr Sloup
2016-07-26 18:56:32 +07:00
parent ed0af943da
commit a0fbf7fb79
5 changed files with 54 additions and 36 deletions

View File

@@ -56,12 +56,20 @@ module.exports = function(options, repo, params, id) {
request: function(req, callback) {
var protocol = req.url.split(':')[0];
//console.log('Handling request:', req);
if (protocol == 'sprites' || protocol == 'fonts') {
if (protocol == 'sprites') {
var dir = options.paths[protocol];
var file = unescape(req.url).substring(protocol.length + 3);
fs.readFile(path.join(dir, file), function(err, data) {
callback(err, { data: data });
});
} else if (protocol == 'fonts') {
var parts = req.url.split('/');
var fontstack = unescape(parts[2]);
var range = parts[3].split('.')[0];
utils.getFontsPbf(null, options.paths[protocol], fontstack, range,
function(err, concated) {
callback(err, {data: concated});
});
} else if (protocol == 'mbtiles') {
var parts = req.url.split('/');
var source = map.sources[parts[2]];