Skip to content

Commit

Permalink
Fix word spacing
Browse files Browse the repository at this point in the history
We were mutating a cached position object. Fixes foliojs#687.
  • Loading branch information
devongovett committed Jul 2, 2017
1 parent e4bb772 commit 5ae1534
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mixins/text.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ module.exports =
positions.push positionsWord...

# add the word spacing to the end of the word
positions[positions.length - 1].xAdvance += wordSpacing
# clone object because of cache
space = {}
space[key] = val for key, val of positions[positions.length - 1]
space.xAdvance += wordSpacing
positions[positions.length - 1] = space
else
[encoded, positions] = @_font.encode(text, options.features)

Expand Down

0 comments on commit 5ae1534

Please sign in to comment.