textStyle.js 866 字节
Newer Older
P
pah100 已提交
1
define(function (require) {
P
pah100 已提交
2

P
pah100 已提交
3 4
    var textContain = require('zrender/contain/text');

P
pah100 已提交
5 6 7 8 9 10 11 12 13
    return {
        getFont: function () {
            return [
                this.get('fontStyle'),
                this.get('fontWeight'),
                (this.get('fontSize') || 12) + 'px',
                this.get('fontFamily') || 'sans-serif'
            ].join(' ');
        },
P
pah100 已提交
14

P
pah100 已提交
15 16
        getTextRect: function (text) {
            var textStyle = this.get('textStyle') || {};
P
pah100 已提交
17
            return textContain.getBoundingRect(
P
pah100 已提交
18 19 20 21 22
                text,
                this.getFont(),
                textStyle.align,
                textStyle.baseline
            );
P
pah100 已提交
23 24 25 26 27 28
        },

        ellipsis: function (text, containerWidth, options) {
            return textContain.ellipsis(
                text, this.getFont(), containerWidth, options
            );
P
pah100 已提交
29 30
        }
    };
L
lang 已提交
31
});