forked from Green-Sky/tomato
Squashed 'external/stb/stb/' changes from f4a71b13373..f7f20f39fe4
f7f20f39fe4 update README 8503b888748 Merge branch 'resize_latest' of https://github.com/jeffrbig2/stb into working 6e9f34d5429 Merge branch 'master' into working 2a584248766 2.09 resize - fix defines for GCC arm 32 013ac3beddf stb_image: fix gcc bounds-check warning (believed erroneous) 449758bd74c update stb_image_resize2.h 43201e7788f image resize 2.07 ae721c50eaf Merge pull request #1609 from jeffrbig2/fix_coeffs 2fb057af65b remove test 1828f357dc8 Fix bug in coeff generation on more than 3x downsamples with width and height scale equal b7cf1246284 stb_image: fix VC6 c59da6729e0 Mark row0 as unused 7f7e3469cf2 clean up comments 7a075fe7c79 Fix 2 pixel to 1 pixel with wrap Fix output buffer for output callback 177b6c6d9d5 Merge branch 'patch-1' of https://github.com/mundusnine/stb into working 2a74e27bdc4 Merge branch 'floatfix' of https://github.com/ybungalobill/stb into working c497f727861 Merge branch 'dev' into working aac5e88febc Add contributor 84fa046c7c9 Fix custom types having a string_len of 0(always) b1947dd6cfb pre-C99; decrease epsilon d84b174fd35 add self d7a44685a82 use STBTT_fabs 7e2ade58ea2 stb_truetype -- fix floating point comparison against zero by using a correct epsilon git-subtree-dir: external/stb/stb git-subtree-split: f7f20f39fe4f206c6f19e26ebfef7b261ee59ee4
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
// Hou Qiming Derek Vinyard
|
||||
// Rob Loach Cort Stratton
|
||||
// Kenney Phillis Jr. Brian Costabile
|
||||
// Ken Voskuil (kaesve)
|
||||
// Ken Voskuil (kaesve) Yakov Galka
|
||||
//
|
||||
// VERSION HISTORY
|
||||
//
|
||||
@@ -4604,6 +4604,8 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
||||
scale_y = -scale_y;
|
||||
|
||||
{
|
||||
// distance from singular values (in the same units as the pixel grid)
|
||||
const float eps = 1./1024, eps2 = eps*eps;
|
||||
int x,y,i,j;
|
||||
float *precompute;
|
||||
stbtt_vertex *verts;
|
||||
@@ -4616,15 +4618,15 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
||||
float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
|
||||
float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;
|
||||
float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
|
||||
precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;
|
||||
precompute[i] = (dist < eps) ? 0.0f : 1.0f / dist;
|
||||
} else if (verts[i].type == STBTT_vcurve) {
|
||||
float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;
|
||||
float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;
|
||||
float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;
|
||||
float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
|
||||
float len2 = bx*bx + by*by;
|
||||
if (len2 != 0.0f)
|
||||
precompute[i] = 1.0f / (bx*bx + by*by);
|
||||
if (len2 >= eps2)
|
||||
precompute[i] = 1.0f / len2;
|
||||
else
|
||||
precompute[i] = 0.0f;
|
||||
} else
|
||||
@@ -4689,8 +4691,8 @@ STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float sc
|
||||
float a = 3*(ax*bx + ay*by);
|
||||
float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);
|
||||
float c = mx*ax+my*ay;
|
||||
if (a == 0.0) { // if a is 0, it's linear
|
||||
if (b != 0.0) {
|
||||
if (STBTT_fabs(a) < eps2) { // if a is 0, it's linear
|
||||
if (STBTT_fabs(b) >= eps2) {
|
||||
res[num++] = -c/b;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user