mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +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:
@@ -74,12 +74,12 @@ void Deprecations::draw(Graphics *gfx)
|
||||
|
||||
if (font.get() == nullptr)
|
||||
{
|
||||
auto hinting = font::TrueTypeRasterizer::HINTING_NORMAL;
|
||||
font::TrueTypeRasterizer::Settings settings;
|
||||
|
||||
if (!isGammaCorrect() && gfx->getScreenDPIScale() <= 1.0)
|
||||
hinting = font::TrueTypeRasterizer::HINTING_LIGHT;
|
||||
settings.hinting = font::TrueTypeRasterizer::HINTING_LIGHT;
|
||||
|
||||
font.set(gfx->newDefaultFont(9, hinting), Acquire::NORETAIN);
|
||||
font.set(gfx->newDefaultFont(9, settings), Acquire::NORETAIN);
|
||||
}
|
||||
|
||||
gfx->flushBatchedDraws();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ public:
|
||||
|
||||
Quad *newQuad(Quad::Viewport v, double sw, double sh);
|
||||
Font *newFont(love::font::Rasterizer *data);
|
||||
Font *newDefaultFont(int size, font::TrueTypeRasterizer::Hinting hinting);
|
||||
Font *newDefaultFont(int size, const font::TrueTypeRasterizer::Settings &settings);
|
||||
Video *newVideo(love::video::VideoStream *stream, float dpiscale);
|
||||
|
||||
SpriteBatch *newSpriteBatch(Texture *texture, int size, BufferDataUsage usage);
|
||||
|
||||
Reference in New Issue
Block a user