elements icon indicating copy to clipboard operation
elements copied to clipboard

artist_port text editor issue with 'f' character

Open johannphilippe opened this issue 4 years ago • 11 comments

Funny bug this time :smile: Artist port branch, in the text_and_icons example : write a 'f' in a text editor, all fine. write a second one, it disappears. write a third one, it re appears write a fourth one, it disappears ... etc It seems to be only with the 'f' character

johannphilippe avatar Dec 14 '21 21:12 johannphilippe

I also noticed that input_box text can overflow a little bit if the elements size is limited to some sizes. It did overflow for a x limit of 30, and it doesn't for a x limit of 40 (with view_limits).

johannphilippe avatar Dec 18 '21 13:12 johannphilippe

I don't have time to investigate right now, but if you can dig deeper (e.g. set up break points and see where it leads to), that would be great!

PS> All the more reason to delegate this task to another (preferably native) library.

djowel avatar Dec 19 '21 02:12 djowel

The overflow seems to happen on master branch as well. It seems to only reproduce when the input_box is inside a limit with view_limits.max.x < 40. I tried to investigate, but couldn't find the real reason for this. Actually, it is not a big deal,, since a input_box with a width < 40 is quite small (should be quite rare to use this elements with a small size like this). So it doesn't seem to be a "bug" to me, but rather a widget design property.

About the 'f' character, I'm still trying to figure out

johannphilippe avatar Dec 19 '21 20:12 johannphilippe

As a reminder, "f" characters are only displayed if impair number of f are typed. The issue seems related to the text_layout::impl class. In the constructor, the 'f' character generates the same line breaks than another character. But in the flow method, it seems to be different.

F characters :

//First f typed
Break line type in constructor at index 0 : 0 
breakline in flow loop at index 0 :  0 
breakline in flow loop at index 0 :  0
// second f typed 
Break line type in constructor at index 0 : 3 
Break line type in constructor at index 1 : 0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 0 :  3 
// third f typed
Break line type in constructor at index 0 : 3 
Break line type in constructor at index 1 : 3 
Break line type in constructor at index 2 : 0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  0 

Not F characters :

// First character (anything but f) typed
Break line type in constructor at index 0 : 0 
breakline in flow loop at index 0 :  0 
breakline in flow loop at index 0 :  0 
// Second character (anything but f) typed
Break line type in constructor at index 0 : 3 
Break line type in constructor at index 1 : 0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  0 
// Third character (anything but f) typed
Break line type in constructor at index 0 : 3 
Break line type in constructor at index 1 : 3 
Break line type in constructor at index 2 : 0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  3 
breakline in flow loop at index 2 :  0 
breakline in flow loop at index 0 :  3 
breakline in flow loop at index 1 :  3 
breakline in flow loop at index 2 :  0 

It appears that the flow loop doesn't go to the last index when user typed a sequence of 'f'. Also we can see that the line break types aren't the same :

  • sequence of no_break then a indeterminate for other characters than f
  • alternance of no_break and indeterminate for 'f' character when there is a pair number of 'f'. Sequence of no_break when impair number of f.
  • This leads to the new_line lambda not being called when there is a pair number of 'f' typed.

johannphilippe avatar Dec 19 '21 21:12 johannphilippe

Nice hunting! I suspected something like this. I thought it might have something to do with F-ligatures: https://creativepro.com/typetalk-the-ins-and-outs-of-f-ligatures/

djowel avatar Dec 20 '21 00:12 djowel

The overflow seems to happen on master branch as well. It seems to only reproduce when the input_box is inside a limit with view_limits.max.x < 40. I tried to investigate, but couldn't find the real reason for this. Actually, it is not a big deal,, since a input_box with a width < 40 is quite small (should be quite rare to use this elements with a small size like this). So it doesn't seem to be a "bug" to me, but rather a widget design property.

It's good if I can resolve this issue, though, for correctness.

djowel avatar Dec 20 '21 01:12 djowel

Same bug for succession of 'f' and 'i' chars. So that may indeed be related to ligatures !

johannphilippe avatar Dec 23 '21 00:12 johannphilippe

Same bug for succession of 'f' and 'i' chars. So that may indeed be related to ligatures !

Indeed!

djowel avatar Dec 23 '21 00:12 djowel

BTW, do you mind filing another issue for the overflow issue?

djowel avatar Dec 23 '21 00:12 djowel

Nice hunting! I suspected something like this. I thought it might have something to do with F-ligatures: https://creativepro.com/typetalk-the-ins-and-outs-of-f-ligatures/

   void hb_buffer::shape(hb_font const& font)
   {
       hb_feature_t userfeatures[1];
       userfeatures[0].tag = HB_TAG('l','i','g','a');
       userfeatures[0].value = 0;
       userfeatures[0].start = HB_FEATURE_GLOBAL_START;
       userfeatures[0].end = HB_FEATURE_GLOBAL_END;
      hb_shape(font.get(), _buffer.get(), userfeatures, 1);
   }

Confirmed it has to do with ligatures.

johannphilippe avatar Jan 06 '22 17:01 johannphilippe

So, the error occurs with OpenSans and DejaVu fonts, but not with Roboto it seems. Edit : Roboto has issues as well, but not for 'ff'. The disappearances happens with 'fi' and 'fl'

johannphilippe avatar Jan 06 '22 17:01 johannphilippe