Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/model/mixin/textStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {getFont} from '../../label/labelStyle';
import Model from '../Model';
import { LabelOption, ColorString } from '../../util/types';
import ZRText, {TextStyleProps} from 'zrender/src/graphic/Text';
import { retrieve2 } from 'zrender/src/core/util';

const PATH_COLOR = ['textStyle', 'color'] as const;

Expand All @@ -31,9 +32,9 @@ type LabelRectRelatedOption = Pick<LabelOption,
| 'width' | 'height' | 'overflow'
> & LabelFontOption;

const fontParams = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily'] as const;
const textStyleParams = [
'fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'padding',
'lineHeight', 'rich', 'width', 'height', 'overflow'
'padding', 'lineHeight', 'rich', 'width', 'height', 'overflow'
] as const;

// TODO Performance improvement?
Expand Down Expand Up @@ -70,6 +71,11 @@ class TextStyleMixin {
verticalAlign: this.getShallow('verticalAlign')
|| this.getShallow('baseline')
};
const globalTextStyle = this.ecModel && this.ecModel.option.textStyle;
for (let i = 0; i < fontParams.length; i++) {
const key = fontParams[i];
(style as any)[key] = retrieve2(this.getShallow(key), globalTextStyle && globalTextStyle[key]);
}
for (let i = 0; i < textStyleParams.length; i++) {
(style as any)[textStyleParams[i]] = this.getShallow(textStyleParams[i]);
}
Expand Down
97 changes: 97 additions & 0 deletions test/ut/spec/model/textStyle.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.