Skip to content

Commit e30a0ae

Browse files
committed
Define CharacterStyle#getFontStyle()
And use it in PointText.
1 parent cc26fdc commit e30a0ae

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/style/CharacterStyle.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend(/** @lends Character
4343
font: 'sans-serif'
4444
}),
4545
_owner: TextItem,
46-
_style: 'style',
46+
_style: 'style'
4747

4848
/**
4949
* CharacterStyle objects don't need to be created directly. Just pass an
@@ -74,5 +74,9 @@ var CharacterStyle = this.CharacterStyle = PathStyle.extend(/** @lends Character
7474
// Override leading to return fontSize * 1.2 by default, when undefined
7575
var leading = this.base();
7676
return leading != null ? leading : this.getFontSize() * 1.2;
77+
},
78+
79+
getFontStyle: function() {
80+
return this._fontSize + 'px ' + this._font;
7781
}
7882
});

src/text/PointText.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
7272
if (!this._content)
7373
return;
7474
this._setStyles(ctx);
75-
ctx.font = this.getFontSize() + 'px ' + this.getFont();
75+
ctx.font = style.getFontStyle();
7676
ctx.textAlign = this.getJustification();
7777
var leading = this.getLeading();
7878
for (var i = 0, l = this._lines.length; i < l; i++) {
@@ -97,7 +97,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
9797
x = 0;
9898
// Measure the real width of the text. Unfortunately, there is no
9999
// sane way to measure text height with canvas
100-
context.font = this.getFontSize() + 'px ' + this.getFont();
100+
context.font = this._style.getFontStyle();
101101
var width = 0;
102102
for (var i = 0, l = this._lines.length; i < l; i++)
103103
width = Math.max(width, context.measureText(

0 commit comments

Comments
 (0)