Repository navigation
Conversation
`getTextRect` reads `fontStyle`, `fontWeight`, `fontSize` and `fontFamily` from the model only. `createTextStyle` falls back to the global `textStyle` for these keys. `getTextRect` measures such a label in the default font. Each font key now falls back to `ecModel.option.textStyle`, as in `createTextStyle`. zrender still builds the font string from the separate keys, so a `fontSize` with a unit such as `'25px'` keeps working.
|
Thanks for your contribution! Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brief Information
This pull request is in the type of:
What does this PR do?
Makes
getTextRectfall back to the globaltextStylefont, as text rendering does.Fixed issues
#21873
Details
Before: What was the problem?
getTextRectinsrc/model/mixin/textStyle.tsreadsfontStyle,fontWeight,fontSizeandfontFamilywithgetShallowonly.createTextStylefalls back to the globaltextStylefor these keys.getTextRectmeasures a label drawn in a global font with the default font.With
grid.containLabel: true,legacyContainLabel.tsmeasures axis labels withgetTextRect. The reserved space then does not match the drawn labels. Thetreemapbreadcrumb and thevisualMaphandle label measure text the same way.A local
fontSizealso drops the globalfontFamily. WithaxisLabel.fontSize: 10and a globalfontFamily: 'monospace',getTextRectmeasures the label as10px sans-serif.After: How does it behave after the fixing?
Each of the four font keys falls back to
ecModel.option.textStyle, the sourcecreateTextStylereads. zrender still builds the font string from the separate keys, so afontSizewith a unit such as'25px'keeps working.On Windows, the default global
fontFamilyis'Microsoft YaHei'.getTextRectnow measures default labels in that font there, matching the drawn text.Added
test/ut/spec/model/textStyle.test.ts. Two of its four cases fail without the change intextStyle.ts.Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
test/ut/spec/model/textStyle.test.tsMerging options
Other information
getFontappendspxto anyfontSize. It turns'25px'into'25pxpx', sogetTextRectdoes not reuse it.