Skip to content

Commit

Permalink
Fix Text decoration accepted values
Browse files Browse the repository at this point in the history
Before this fix, Small-caps was the accepted value.
After the fix only the following values are accepted:
underline, overline, line-through, blink. In case no value is specified,
the default(none) is used.

Fixes gliffy#90.
  • Loading branch information
Josephblt committed Feb 2, 2023
1 parent eaab317 commit 5792546
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions canvas2svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,14 @@
* @private
*/
ctx.prototype.__parseFont = function () {
var regex = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i;
var regex = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(underline|overline|line-through|blink))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i;
var fontPart = regex.exec( this.font );
var data = {
style : fontPart[1] || 'normal',
size : fontPart[4] || '10px',
family : fontPart[6] || 'sans-serif',
weight: fontPart[3] || 'normal',
decoration : fontPart[2] || 'normal',
decoration : fontPart[2] || 'none',
href : null
};

Expand Down

0 comments on commit 5792546

Please sign in to comment.