Fix for #570: round glyph positions to pixels using floor

This commit is contained in:
Mikko Mononen 2020-03-18 23:10:53 +02:00
parent bff4734a9a
commit 426aa3f149

View file

@ -924,7 +924,7 @@ int fonsAddFont(FONScontext* stash, const char* name, const char* path, int font
readed = fread(data, 1, dataSize, fp);
fclose(fp);
fp = 0;
if (readed != dataSize) goto error;
if (readed != (size_t)dataSize) goto error;
return fonsAddFontMem(stash, name, data, dataSize, 1, fontIndex);
@ -1225,8 +1225,8 @@ static void fons__getQuad(FONScontext* stash, FONSfont* font,
y1 = (float)(glyph->y1-1);
if (stash->params.flags & FONS_ZERO_TOPLEFT) {
rx = (float)(int)(*x + xoff);
ry = (float)(int)(*y + yoff);
rx = floorf(*x + xoff);
ry = floorf(*y + yoff);
q->x0 = rx;
q->y0 = ry;
@ -1238,8 +1238,8 @@ static void fons__getQuad(FONScontext* stash, FONSfont* font,
q->s1 = x1 * stash->itw;
q->t1 = y1 * stash->ith;
} else {
rx = (float)(int)(*x + xoff);
ry = (float)(int)(*y - yoff);
rx = floorf(*x + xoff);
ry = floorf(*y - yoff);
q->x0 = rx;
q->y0 = ry;