-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add overridable TextMetrics.isBreakingSpace for better CJK plugin support #7023
Add overridable TextMetrics.isBreakingSpace for better CJK plugin support #7023
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #7023 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 671 671
=========================================
Hits 671 671 Continue to review full report at Codecov.
|
packages/text/src/TextMetrics.ts
Outdated
* @return {boolean} True if whitespace, False otherwise. | ||
*/ | ||
private static isBreakingSpace(char: string): boolean | ||
private static isBreakingSpace(char: string, _nextChar?: string): boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this public?
const reg = /[あいうえお]/; | ||
|
||
// override breakingSpace | ||
TextMetrics.isBreakingSpace = function (char, nextChar) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this test is over, can you reset isBreakingSpace to the default. Otherwise it may have unintended side effects for other tests.
@bigtimebuddy thank you for the review. I have updated the code 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code works for me! Thanks for the test too. I'll defer to @themoonrat to evaluate the utility of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 1 minor jsdoc issue, otherwise lgtm. Non breaking change that allows greater plugin customising
Thank you @huang-yuwei! |
Description of change
As the discussion with @themoonrat in #6975, suggest allowing the
isBreakingSpace
to be able to receive thenextChar
for solving the CJK issues in adding additions.For example, the example plugin(https://codepen.io/huang-yuwei/pen/GRqbEmm) shows how we can solve the #6975 and #4447 via an adding addition.
However, I am not 100% sure whether the CJK related issues should be solved directly in PIXI.js itself.
Therefore, suggest applying the additional parameters for other developers can change via other plugins.
Pre-Merge Checklist
npm run lint
)npm run test
)