stb_truetype: fix incorrect antialiasing computation in v2 rasterizer, and handle certain cases where math blew up
This commit is contained in:
@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "DS_TEST" /FR /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /GX /Zi /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "TT_TEST" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
stbtt_fontinfo font;
|
||||
unsigned char *bitmap;
|
||||
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 34807), s = (argc > 2 ? atoi(argv[2]) : 32);
|
||||
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : '@'), s = (argc > 2 ? atoi(argv[2]) : 32);
|
||||
|
||||
//debug();
|
||||
|
||||
@ -49,6 +49,25 @@ int main(int argc, char **argv)
|
||||
stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
|
||||
|
||||
#if 0
|
||||
{
|
||||
stbtt__bitmap b;
|
||||
stbtt__point p[2];
|
||||
int wcount[2] = { 2,0 };
|
||||
p[0].x = 0.2f;
|
||||
p[0].y = 0.3f;
|
||||
p[1].x = 3.8f;
|
||||
p[1].y = 0.8f;
|
||||
b.w = 16;
|
||||
b.h = 2;
|
||||
b.stride = 16;
|
||||
b.pixels = malloc(b.w*b.h);
|
||||
stbtt__rasterize(&b, p, wcount, 1, 1, 1, 0, 0, 0, 0, 0, NULL);
|
||||
for (i=0; i < 8; ++i)
|
||||
printf("%f\n", b.pixels[i]/255.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
{
|
||||
static stbtt_pack_context pc;
|
||||
static stbtt_packedchar cd[256];
|
||||
@ -60,16 +79,14 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
{
|
||||
static stbtt_pack_context pc;
|
||||
static stbtt_packedchar cd[256];
|
||||
static unsigned char atlas[1024*1024];
|
||||
unsigned char *data;
|
||||
|
||||
stbtt_PackBegin(&pc, atlas, 1024,1024,1024,1,NULL);
|
||||
stbtt_PackFontRange(&pc, ttf_buffer, 0, 32.0, 'u', 1, cd);
|
||||
stbtt_PackEnd(&pc);
|
||||
|
||||
data = stbtt_GetCodepointSDF(&font, stbtt_ScaleForPixelHeight(&font,32.0), 'u', 4, 128, 128/4, &w,&h,&i,&j);
|
||||
for (j=0; j < h; ++j) {
|
||||
for (i=0; i < w; ++i) {
|
||||
@ -77,8 +94,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
stbtt_BakeFontBitmap(ttf_buffer,stbtt_GetFontOffsetForIndex(ttf_buffer,0), 40.0, temp_bitmap[0],BITMAP_W,BITMAP_H, 32,96, cdata); // no guarantee this fits!
|
||||
@ -117,8 +134,16 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0);
|
||||
(void)stbtt_GetCodepointBitmapSubpixel(&font,
|
||||
0.4972374737262726f,
|
||||
0.4986416995525360f,
|
||||
0.2391788959503174f,
|
||||
0.1752119064331055f,
|
||||
'd',
|
||||
&w, &h,
|
||||
0,0);
|
||||
|
||||
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0);
|
||||
for (j=0; j < h; ++j) {
|
||||
for (i=0; i < w; ++i)
|
||||
putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
|
||||
|
Reference in New Issue
Block a user