Sketch-Highlighter icon indicating copy to clipboard operation
Sketch-Highlighter copied to clipboard

Wrapping highlight bug

Open Bodysoulspirit opened this issue 8 years ago • 8 comments

See attached file ans screenshot. The highlight shape wraps itself to a next line.

highlithwrapbug

HighlightWrapBug.zip

Bodysoulspirit avatar Jul 04 '17 16:07 Bodysoulspirit

Really missing this in Sketch ;(

Bodysoulspirit avatar Jan 02 '18 06:01 Bodysoulspirit

Does it still behave this exact way in the current version of Sketch?

matt-curtis avatar Jan 02 '18 13:01 matt-curtis

Unfortunately yes, just checked (font is Avenir for example) :

sketch 48 2

Bodysoulspirit avatar Jan 03 '18 07:01 Bodysoulspirit

So... I've looked into this, and I'm mostly just confused. The APIs to get line rectangle information reports that the second line in your example is 'Sketc' instead of 'Sketch' which throws things off. I was thinking that this might have something to do with maybe me giving the incorrect text container width when asking for the lines (the APIs return the line geometry based on the text container width passed in) causing the text to wrap earlier, but I checked and Sketch gives the same width (the width of the text layer) so I'm kind of puzzled. I was going to try adding a pixel or two to the width to fix this, but it's imprecise and might not work for all the cases where this happens... outside of that, I'm not really sure how to fix this.

matt-curtis avatar Jan 03 '18 15:01 matt-curtis

Thanks @matt-curtis for looking into it !
I tried to isolate a pattern and it seems it is somehow related to the fixed/auto text container modes.

• Text containers in fixed mode seem to work pretty well if I'm right.

• Auto mode containers not. Nor when the text is initially typed in auto mode (you cannot really create a text container in auto mode if I'm right, it starts in fixed mode that you can set to auto before typing), nor when changing it from fixed to auto. As soon as you convert to auto it cuts some words or parts, as you said, putting the "h" and the next line for example. In some cases converting the fixed container text to auto and break the line manually works, but mostly not (as soon as you modify the text or size it breaks, perhaps it works as long as the new auto width container is the same or less as the fixed one).

So the only way I can somehow use it with auto mode typing is to type my text in auto mode, break my lines manually like I want, then convert the container to fixed, but I HAVE TO CHANGE THE FIXED CONTAINER MANUALLY FIRST before hitting the plugin, otherwise it does not work ... Simply putting it in auto mode does not work.

Joining the sketch test file

Thanks

mode changes tests

Mode + Changes Tests.zip

Bodysoulspirit avatar Jan 06 '18 10:01 Bodysoulspirit

First off - that's some fantastic detective work you did, thanks!

What I find interesting is that in your tests, highlight works properly in Fixed mode. In my own texts, highlighting doesn't work properly in either mode, both have the same issue.

matt-curtis avatar Jan 19 '18 02:01 matt-curtis

No highlight at all in Sketch 50.2 :( Crycrycy ;)

Bodysoulspirit avatar Sep 21 '18 14:09 Bodysoulspirit

You may want to give the version I built using the new JS API a try. No guarantees it'll work :)

matt-curtis avatar Sep 23 '18 22:09 matt-curtis