Skip to content

Commit

Permalink
add 'text-letter-spacing'
Browse files Browse the repository at this point in the history
Unit is em
  • Loading branch information
ansis committed May 29, 2014
1 parent ab04258 commit 6d16a6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/text/shaping.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
shape: shape
};

function shape(text, name, stacks, maxWidth, lineHeight, alignment) {
function shape(text, name, stacks, maxWidth, lineHeight, alignment, spacing) {
var glyphs = stacks[name].glyphs;
var glyph;

Expand All @@ -27,7 +27,7 @@ function shape(text, name, stacks, maxWidth, lineHeight, alignment) {
y: y
});

x += glyph.advance;
x += glyph.advance + spacing;
}

shaping = linewrap(shaping, glyphs, lineHeight, maxWidth, alignment);
Expand Down
3 changes: 2 additions & 1 deletion js/worker/workertile.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,12 @@ WorkerTile.prototype.parseTextBucket = function(tile, features, bucket, info, la
var oneEm = 24;
var lineHeight = (bucket.info['text-line-height'] || 1.2) * oneEm;
var maxWidth = (bucket.info['text-max-width'] || 15) * oneEm;
var spacing = (bucket.info['text-letter-spacing'] || 0) * oneEm;

bucket.start();
for (var k = 0; k < text_features.length; k++) {
var feature = features[text_features[k]];
var shaping = Shaping.shape(feature.name, fontstack, stacks, maxWidth, lineHeight, alignment);
var shaping = Shaping.shape(feature.name, fontstack, stacks, maxWidth, lineHeight, alignment, spacing);
if (!shaping) continue;
var lines = feature.loadGeometry();
bucket.addFeature(lines, stacks, shaping);
Expand Down

0 comments on commit 6d16a6c

Please sign in to comment.