-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Closes #12278 - added filtering #12279
base: main
Are you sure you want to change the base?
Closes #12278 - added filtering #12279
Conversation
Thank you for the pull request, @MNPCMW6444! Welcome to the Cesium community! In order for us to review your PR, please complete the following steps:
Review Pull Request Guidelines to make sure your PR gets accepted quickly. |
Thanks for the PR @MNPCMW6444! I can confirm we have a CLA on file for you. |
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.
Could you please add a unit test to verify this fix?
@@ -118,8 +118,74 @@ function addGlyphToTextureAtlas(textureAtlas, id, canvas, glyphTextureInfo) { | |||
|
|||
const splitter = new GraphemeSplitter(); | |||
|
|||
// Filter to remove unsupported control characters like RLM (\u200f) |
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 explain a bit about how this list was determined? Would it make sense to test for a unicode range instead of listing each character individually?
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.
see my comment please
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.
Any thoughts on using the unicode ranges to make this more concise? I think the following regex matches of these values:
/[\u0000-\u001F\u202a-\u206f\u200b-\u200f]/
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.
got it
let text = label._renderedText; | ||
|
||
// Filter out unsupported control characters | ||
text = filterUnsupportedCharacters(text); |
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.
Regex operations can be performance intensive. Is there a way we can ensure the operation runs only once for each label text string, as apposed to every time the glyphs need to be rebound?
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.
I can implement this with a simple .replace(char, '') instead of a RegExp, will it be acceptable?
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.
I think using a regex is a good idea, but we should just make sure it only has to happen one time.
Consider moving the filterUnsupportedCharacters
to the set
function of text
in Label.js
. We already have a bit of logic there to filter and modify the string before assigning it to _renderedText
.
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.
got it
Co-authored-by: Gabby Getz <gabby@cesium.com>
@ggetz Thanks for your CR! |
Hi @MNPCMW6444,
We want to make sure there is some kind of repeatable test in place so we can 1) ensure the code is correct, and 2) keep this bug from happening again if the code ever changes. Most of the time, we use unit tests to validate functionality like this (rather than Sandcastle, as you mentioned) as we can run it as part of our CI process. See the Testing Guide for more information, but for this particular case, I think we want to:
What do you think? Could you give it a try? |
so i will make the regex simpler with a unicode range and apply it in Label.js, anc create a unit test |
Description
Issue number and link
#12278
issue #12278
Testing plan
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change