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:
Sasha Szpakowski
2023-10-20 20:19:30 -03:00
parent 8c13943f64
commit 5a0a6a1a27
12 changed files with 84 additions and 74 deletions
+6 -3
View File
@@ -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());
}