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

Bug in shaping logic #1

Open
ghost opened this issue Apr 28, 2021 · 2 comments
Open

Bug in shaping logic #1

ghost opened this issue Apr 28, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 28, 2021

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:

image

Is this a known issue? I assume the bug stems from LayoutEngine's failure to properly break the text into multiple runs.

@chfoo
Copy link
Owner

chfoo commented Apr 28, 2021

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.

@mgood7123
Copy link

I ended up not using this project anywhere so there are likely more bugs that I haven't encountered.

:(

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