Skip to content

Commit

Permalink
Merge pull request #19170 from apache/fix/toolbox/font
Browse files Browse the repository at this point in the history
fix(toolbox): fix toolbox text can't apply the specified or global font style
  • Loading branch information
Ovilia authored Oct 4, 2023
2 parents d08664f + 0508353 commit 4a3d090
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 22 deletions.
10 changes: 9 additions & 1 deletion src/component/toolbox/ToolboxView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { getUID } from '../../util/component';
import Displayable from 'zrender/src/graphic/Displayable';
import ZRText from 'zrender/src/graphic/Text';
import { getFont } from '../../label/labelStyle';

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

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

// Text position calculation
// TODO: extract `textStyle` from `iconStyle` and use `createTextStyle`
const textContent = new ZRText({
style: {
text: titlesMap[iconName],
align: iconStyleEmphasisModel.get('textAlign'),
borderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
padding: iconStyleEmphasisModel.get('textPadding'),
fill: null
fill: null,
font: getFont({
fontStyle: iconStyleEmphasisModel.get('textFontStyle'),
fontFamily: iconStyleEmphasisModel.get('textFontFamily'),
fontSize: iconStyleEmphasisModel.get('textFontSize'),
fontWeight: iconStyleEmphasisModel.get('textFontWeight')
}, ecModel)
},
ignore: true
});
Expand Down
4 changes: 4 additions & 0 deletions src/component/toolbox/featureManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type IconStyle = ItemStyleOption & {
textAlign?: LabelOption['align']
textBorderRadius?: LabelOption['borderRadius']
textPadding?: LabelOption['padding']
textFontFamily?: LabelOption['fontFamily']
textFontSize?: LabelOption['fontSize']
textFontWeight?: LabelOption['fontWeight']
textFontStyle?: LabelOption['fontStyle']
};
export interface ToolboxFeatureOption {

Expand Down
122 changes: 101 additions & 21 deletions test/toolbox-textStyle.html

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

0 comments on commit 4a3d090

Please sign in to comment.