Skip to content
Myr

Merge branch 'floatfix' of https://github.com/ybungalobill/stb into working

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents c497f72, b1947dd · Browse files · 1 file+8 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−6 removed

  • other:+8 added−6 removed

1 file+8 added−6 removed

modified:stb_truetype.h+8 added-6 removed
52 unmodified lines
53// Johan Duparc Thomas Fields54// Hou Qiming Derek Vinyard55// Rob Loach Cort Stratton56// Kenney Phillis Jr. Brian Costabile57// Ken Voskuil (kaesve)57// Ken Voskuil (kaesve) Yakov Galka58//59// VERSION HISTORY60//61// 1.24 (2020-02-05) fix warning
4487 unmodified lines
4549 // invert for y-downwards bitmaps4550 scale_y = -scale_y;45514552 {4553 // distance from singular values (in the same units as the pixel grid)4554 const float eps = 1./1024, eps2 = eps*eps;4555 int x,y,i,j;4556 float *precompute;4557 stbtt_vertex *verts;4558 int num_verts = stbtt_GetGlyphShape(info, glyph, &verts);
4 unmodified lines
4563 if (verts[i].type == STBTT_vline) {4564 float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;4565 float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;4566 float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));4565 precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;4567 precompute[i] = (dist < eps) ? 0.0f : 1.0f / dist;4568 } else if (verts[i].type == STBTT_vcurve) {4569 float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;4570 float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;4571 float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;4572 float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;4573 float len2 = bx*bx + by*by;4572 if (len2 != 0.0f)4573 precompute[i] = 1.0f / (bx*bx + by*by);4574 if (len2 >= eps2)4575 precompute[i] = 1.0f / len2;4576 else4577 precompute[i] = 0.0f;4578 } else4579 precompute[i] = 0.0f;
56 unmodified lines
4636 if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula4637 float a = 3*(ax*bx + ay*by);4638 float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);4639 float c = mx*ax+my*ay;4638 if (a == 0.0) { // if a is 0, it's linear4639 if (b != 0.0) {4640 if (STBTT_fabs(a) < eps2) { // if a is 0, it's linear4641 if (STBTT_fabs(b) >= eps2) {4642 res[num++] = -c/b;4643 }4644 } else {4645 float discriminant = b*b - 4*a*c;
370 unmodified lines