mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
All constructors for making a TrueType font take an optional settings table.
This supersedes the existing optional hinting and dpi scale parameters. The table's fields are:
{
hinting = "normal",
dpiscale = 1, -- nil will default to the current window DPI scale.
}
This commit is contained in:
@@ -294,13 +294,13 @@ Font *Graphics::newFont(love::font::Rasterizer *data)
|
||||
return new Font(data, states.back().defaultSamplerState);
|
||||
}
|
||||
|
||||
Font *Graphics::newDefaultFont(int size, font::TrueTypeRasterizer::Hinting hinting)
|
||||
Font *Graphics::newDefaultFont(int size, const font::TrueTypeRasterizer::Settings &settings)
|
||||
{
|
||||
auto fontmodule = Module::getInstance<font::Font>(M_FONT);
|
||||
if (!fontmodule)
|
||||
throw love::Exception("Font module has not been loaded.");
|
||||
|
||||
StrongRef<font::Rasterizer> r(fontmodule->newTrueTypeRasterizer(size, hinting), Acquire::NORETAIN);
|
||||
StrongRef<font::Rasterizer> r(fontmodule->newTrueTypeRasterizer(size, settings), Acquire::NORETAIN);
|
||||
return newFont(r.get());
|
||||
}
|
||||
|
||||
@@ -731,7 +731,10 @@ void Graphics::checkSetDefaultFont()
|
||||
|
||||
// Create a new default font if we don't have one yet.
|
||||
if (!defaultFont.get())
|
||||
defaultFont.set(newDefaultFont(13, font::TrueTypeRasterizer::HINTING_NORMAL), Acquire::NORETAIN);
|
||||
{
|
||||
font::TrueTypeRasterizer::Settings settings;
|
||||
defaultFont.set(newDefaultFont(13, settings), Acquire::NORETAIN);
|
||||
}
|
||||
|
||||
states.back().font.set(defaultFont.get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user