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

stb_truetype: stbtt__fill_active_edges_new() dy=nan #1721

Open
MWP opened this issue Nov 20, 2024 · 1 comment
Open

stb_truetype: stbtt__fill_active_edges_new() dy=nan #1721

MWP opened this issue Nov 20, 2024 · 1 comment

Comments

@MWP
Copy link

MWP commented Nov 20, 2024

I won't pretend to know what's going on in this function, but it's creating an ARM FPU fault.

I can trace through the code, and have found the following results in a div by 0.

               // check if final y_crossing is blown up; no test case for this
               if (y_final > y_bottom) {
                  y_final = y_bottom;
                  dy = (y_final - y_crossing ) / (x2 - (x1+1)); // if denom=0, y_final = y_crossing, so y_final <= y_bottom
               }

In this case, y_final=-14 y_crossing=-14 x2=21 and x1=20.

The ARM FPU fault then occurs on:

               step = sign * dy * 1; // dy is dy/dx, change in y for every 1 change in x,

If it matters, the font is: https://www.fontrepo.com/font/4274/painting-with-chocolate

Thanks!

@MWP
Copy link
Author

MWP commented Nov 20, 2024

I've temporarily prevented the fault from happening by:

               // check if final y_crossing is blown up; no test case for this
               if (y_final > y_bottom) {
                  y_final = y_bottom;
                  int div = x2 - (x1+1);
                  if (div == 0) div = 1;
                  dy = (y_final - y_crossing ) / div;
               }

I'm guessing this isn't the correct way to go about fixing this though?

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

1 participant