Skip to content

Commit 4a3d090

Browse files
authored
Merge pull request #19170 from apache/fix/toolbox/font
fix(toolbox): fix toolbox text can't apply the specified or global font style
2 parents d08664f + 0508353 commit 4a3d090

File tree

3 files changed

+114
-22
lines changed

3 files changed

+114
-22
lines changed

src/component/toolbox/ToolboxView.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
import { getUID } from '../../util/component';
4040
import Displayable from 'zrender/src/graphic/Displayable';
4141
import ZRText from 'zrender/src/graphic/Text';
42+
import { getFont } from '../../label/labelStyle';
4243

4344
type IconPath = ToolboxFeatureModel['iconPaths'][string];
4445

@@ -217,13 +218,20 @@ class ToolboxView extends ComponentView {
217218
pathEmphasisState.style = iconStyleEmphasisModel.getItemStyle();
218219

219220
// Text position calculation
221+
// TODO: extract `textStyle` from `iconStyle` and use `createTextStyle`
220222
const textContent = new ZRText({
221223
style: {
222224
text: titlesMap[iconName],
223225
align: iconStyleEmphasisModel.get('textAlign'),
224226
borderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
225227
padding: iconStyleEmphasisModel.get('textPadding'),
226-
fill: null
228+
fill: null,
229+
font: getFont({
230+
fontStyle: iconStyleEmphasisModel.get('textFontStyle'),
231+
fontFamily: iconStyleEmphasisModel.get('textFontFamily'),
232+
fontSize: iconStyleEmphasisModel.get('textFontSize'),
233+
fontWeight: iconStyleEmphasisModel.get('textFontWeight')
234+
}, ecModel)
227235
},
228236
ignore: true
229237
});

src/component/toolbox/featureManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ type IconStyle = ItemStyleOption & {
3333
textAlign?: LabelOption['align']
3434
textBorderRadius?: LabelOption['borderRadius']
3535
textPadding?: LabelOption['padding']
36+
textFontFamily?: LabelOption['fontFamily']
37+
textFontSize?: LabelOption['fontSize']
38+
textFontWeight?: LabelOption['fontWeight']
39+
textFontStyle?: LabelOption['fontStyle']
3640
};
3741
export interface ToolboxFeatureOption {
3842

test/toolbox-textStyle.html

Lines changed: 101 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)