Skip to content

Commit

Permalink
The most obvious cases of unnecessary white space appearing before an…
Browse files Browse the repository at this point in the history
…d/or after replaced text should now be solved.
  • Loading branch information
sorccu committed May 5, 2009
1 parent 831fd00 commit 9810b4c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions js/cufon.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,21 @@ var Cufon = (function() {
uppercase: 'toUpperCase',
lowercase: 'toLowerCase'
}[style.get('textTransform')] || 'toString']();
}
},

whiteSpace: (function() {
var ignore = {
inline: 1,
'inline-block': 1,
'run-in': 1
};
return function(text, style, node) {
if (ignore[style.get('display')]) return text;
if (!node.previousSibling) text = text.replace(/^\s+/, '');
if (!node.nextSibling) text = text.replace(/\s+$/, '');
return text;
};
})()

};

Expand Down Expand Up @@ -486,7 +500,7 @@ var Cufon = (function() {
engines[options.engine](font, null, style, options, node, el);
continue;
}
var text = node.data;
var text = CSS.whiteSpace(node.data, style, node);
if (text === '') continue;
var processed = process(font, text, style, options, node, el);
if (processed) node.parentNode.replaceChild(processed, node);
Expand Down

0 comments on commit 9810b4c

Please sign in to comment.