You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am studying the old rasterization code of stb_truetype.h by copying the code.
Because it's not used any longer, It doesn't need to be improved. But I want to know my point is correct.
While I was experimenting with it, I found that there was a problematic point:
stbtt__active_edge*z=stbtt__new_active(&hh, e, off_x, scan_y, userdata);
if (z!=NULL) {
// find insertion point
if (active==NULL)
active=z;
elseif (z->x<active->x) {
// insert at front
z->next=active;
active=z;
} else {
// find thing to insert AFTER
stbtt__active_edge*p=active;
while (p->next&&p->next->x<z->x)
p=p->next;
// at this point, p->next->x is NOT < z->x
z->next=p->next;
p->next=z;
}
}
}
++e;
}
I guess the Sean's intention was not inserting an edge to the linked list of active edges when it reaches the end of stbtt__edge array by putting the sentinel's y coordinate like this:
So, the y coordinate of the sentinel coudl be less than scan_y if the variable vsubsample is large enough.
So I guess it will be safer to directly check whether it reaches the end of the stbtt_edge array like this:
// init code
stbtt_edge* sentinel = e + n;
...
while (e != sentinel && e->y0 <= scan_y)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am studying the old rasterization code of stb_truetype.h by copying the code.
Because it's not used any longer, It doesn't need to be improved. But I want to know my point is correct.
While I was experimenting with it, I found that there was a problematic point:
stb/stb_truetype.h
Lines 2983 to 3006 in f4a71b1
I guess the Sean's intention was not inserting an edge to the linked list of active edges when it reaches the end of
stbtt__edge
array by putting the sentinel's y coordinate like this:stb/stb_truetype.h
Lines 2939 to 2940 in f4a71b1
However, the scan_y variable is updated like this:
stb/stb_truetype.h
Lines 2943 to 2945 in f4a71b1
So, the y coordinate of the sentinel coudl be less than
scan_y
if the variablevsubsample
is large enough.So I guess it will be safer to directly check whether it reaches the end of the
stbtt_edge
array like this:Beta Was this translation helpful? Give feedback.
All reactions