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

Util function getCaretAtPoint can't get the uniform text caret vertical position for number/character and Chinese text. #294

Open
HawtinZeng opened this issue Dec 24, 2023 · 5 comments

Comments

@HawtinZeng
Copy link
Contributor

https://stackblitz.com/edit/vitejs-vite-xq3mug?file=package.json,src%2Fmain.js, click this link, and click the text in the scene, you will find get different vertical position for number/character and Chinese text. The compareing screentshot as below:
number or character: image
Chinese text: image

@HawtinZeng
Copy link
Contributor Author

when i test selection in troika examples, there is differenct height between number/charcter and Chinese text, can u give me some suggestions to solve this problem, I wanna take part in your project.
image

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Dec 24, 2023

Currently i don't use the y value returned by getCaretAtPoint, instead , I align the origin of a plane mesh to the origin of Text, solve this problem, but it seems not perfect.
image

@HawtinZeng
Copy link
Contributor Author

Hi, @lojjic , I have complated a demo for in-place text editing, link, I wanna to contribute it to your repo, how do u think? And where I should put this text editing example in?

@lojjic
Copy link
Collaborator

lojjic commented Jan 2, 2024

Thanks for the report!

The caretTop and caretHeight are calculated here -- the difference is due to the Latin and Chinese font files containing different ascender/descender metrics. I'm open to changing how those values are chosen, if you know of a good reliable method that would make them match.

As for your example, I think keeping it external is best, it can stay on Stackblitz and maybe we can add a link to it in the documentation.

@HawtinZeng
Copy link
Contributor Author

HawtinZeng commented Jan 3, 2024

I will append the demo link into the doc soon, and by the way, do u know how to calculate the font length before text.sync, i want to draw some lines and dots based on text length before drawing troika text😂😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants