I've recently been troubled by fonts. I'm attempting to use a pixelly font, but they always end up looking crappy, like this:
![Image](http://dl.dropbox.com/u/45554193/qenbox/qenbox%20why%20blurry%20text%20why%20why%20why.png)
As you can see, the linear filtering really messes us the crispness and makes it look like someone couldn't keep down their alphabet soup.
Annoyed by this and the lack of a way to solve it in my code, I request that you add the option to choose the types of filtering for a font.
I've read through the source code and I have found that Graphics->newFont can accept filtering options, but in the wrapper's newFont1 function, you completely ignore it and force all fonts created with love.graphics.newFont to use linear filtering.
I suggest you alter it to something like this:
Code: Select all
int w_newFont1(lua_State * L)
{
Data * font_data = NULL;
// Convert to File, if necessary.
if (lua_isstring(L, 1))
luax_convobj(L, 1, "filesystem", "newFile");
// Convert to Data, if necessary.
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
{
love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
try
{
font_data = f->read();
}
catch (love::Exception & e)
{
return luaL_error(L, e.what());
}
lua_remove(L, 1); // get rid of the file
luax_newtype(L, "Data", DATA_T, (void*)font_data);
lua_insert(L, 1); // put it at the bottom of the stack
}
// Convert to Rasterizer, if necessary.
if (luax_istype(L, 1, DATA_T))
{
int idxs[] = {1, 2};
luax_convobj(L, idxs, 2, "font", "newRasterizer");
}
if (font_data)
font_data->release();
love::font::Rasterizer * rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
Image::Filter filter;
Image::FilterMode min;
Image::FilterMode mag;
const char * minstr = luaL_checkstring(L, 2);
const char * magstr = luaL_checkstring(L, 3);
if (!Image::getConstant(minstr, min))
return luaL_error(L, "Invalid filter mode: %s", minstr);
if (!Image::getConstant(magstr, mag))
return luaL_error(L, "Invalid filter mode: %s", magstr);
filter.min = min;
filter.mag = mag;
// Create the font.
Font * font = instance->newFont(rasterizer, filter);
if (font == 0)
return luaL_error(L, "Could not load font.");
// Push the type.
luax_newtype(L, "Font", GRAPHICS_FONT_T, (void*)font);
return 1;
}