Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(toolbox): fix toolbox text can't apply the specified or global font style #19170

Merged
merged 1 commit into from
Oct 4, 2023
Merged
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: 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 @@
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 Expand Up @@ -63,7 +67,7 @@
setIconStatus(iconName: string, status: DisplayState): void
}

interface ToolboxFeature<Opts extends ToolboxFeatureOption = ToolboxFeatureOption> {

Check warning on line 70 in src/component/toolbox/featureManager.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'Opts' is defined but never used
getIcons?(): Dictionary<string>

onclick(ecModel: GlobalModel, api: ExtensionAPI, type: string, event: ZRElementEvent): void
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.