Skip to content

Commit 5ae1534

Browse files
committed
Fix word spacing
We were mutating a cached position object. Fixes foliojs#687.
1 parent e4bb772 commit 5ae1534

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: lib/mixins/text.coffee

+5-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ module.exports =
252252
positions.push positionsWord...
253253

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

0 commit comments

Comments
 (0)