cobbletext
                                
                                 cobbletext copied to clipboard
                                
                                    cobbletext copied to clipboard
                            
                            
                            
                        Bug in shaping logic
Hi there, there seems to be a bug when shaping text runs. The shaper assumes that a run was successfully shaped when harfbuzz returns a minimum amount of valid glyphs (see here). For certain texts, this is valid logic. However there are situations where this fails. Take for example the following text (font used is Segoe UI Emoji):
š šš
(as C-string: "š\r\nšš")
This results in Adobe NotDef being used for all runs. I suppose this is because the LayoutEngine splits up the text before shaping it (see here). It fails to apply line breaks to the text, which results in a single run. When harfbuzz shapes this run, it outputs the following code points:
[0] 11680 [1] 1 [2] 0 [3] 11680 [4] 11680
Because 4 out of 5 glyphs are valid, the "notDef" threshold becomes 4/5=0.2. This is lower than the acceptable threshold, thus Adobe NotDef is used for the entire run. This example can be verified using the Cobbletext online example:

Is this a known issue? I assume the bug stems from LayoutEngine's failure to properly break the text into multiple runs.
Hello, thanks for taking a look! When writing the notdef threshold algorithm, I knew it was a too simple heuristic and doesn't perform well in some cases. But the line break missing is unexpected and is a bug.
I ended up not using this project anywhere so there are likely more bugs that I haven't encountered.
I ended up not using this project anywhere so there are likely more bugs that I haven't encountered.
:(