mrjs icon indicating copy to clipboard operation
mrjs copied to clipboard

Text length calculation seems wrong

Open lobau opened this issue 1 year ago • 3 comments

I feel like this problem keeps popping. If you look at this screenshot, I would expect all 3 lines to be stacked on top of each other, without line breaks in the middle:

image

https://docs.mrjs.io/doc/mr-a/#example

I believe the line break is because we miscalculate the width of the text.

lobau avatar Mar 08 '24 03:03 lobau

I did some poking around and found that the width calculated is correct but for some reason, the last word gets sent to a new line. Sample image below. An easy fix is to just give the textObjs a bigger maxWidth but this makes the bounding box clip with the right side of the text. I'm not too sure how this may interact with different CSS properties. Screenshot 2024-03-13 132927 Here is the clipping example: mrjsTextSimpleFix

bkcastro avatar Mar 13 '24 20:03 bkcastro

good find @bkcastro ! in regards to the bounding box, that gets setup at init for the text entity when it gets connected to the physics system (new entity to here which calls here)-- let me know if you're planning to take on a fix for this and if have any questions as you dig through that ~

hanbollar avatar Mar 14 '24 17:03 hanbollar

@hanbollar Yeah I plan on fixing the text issue later today just have some school work to get done first. Thanks for clearing things up.

bkcastro avatar Mar 14 '24 19:03 bkcastro