Rework internal module registration to happen in constructors.

This commit is contained in:
Sasha Szpakowski
2024-02-24 15:21:38 -04:00
parent c7e4dafd88
commit 1e97e09b28
73 changed files with 154 additions and 248 deletions
+2 -1
View File
@@ -34,7 +34,8 @@ namespace font
// Default TrueType font, gzip-compressed.
#include "NotoSans-Regular.ttf.gzip.h"
Font::Font()
Font::Font(const char *name)
: Module(M_FONT, name)
{
auto compressedbytes = (const char *) NotoSans_Regular_ttf_gzip;
size_t compressedsize = NotoSans_Regular_ttf_gzip_len;
+3 -4
View File
@@ -43,7 +43,6 @@ class Font : public Module
public:
Font();
virtual ~Font() {}
virtual Rasterizer *newRasterizer(love::filesystem::FileData *data) = 0;
@@ -58,9 +57,9 @@ public:
virtual GlyphData *newGlyphData(Rasterizer *r, const std::string &glyph);
virtual GlyphData *newGlyphData(Rasterizer *r, uint32 glyph);
// Implement Module.
virtual ModuleType getModuleType() const { return M_FONT; }
virtual const char *getName() const = 0;
protected:
Font(const char *name);
private:
+1 -5
View File
@@ -36,6 +36,7 @@ namespace freetype
{
Font::Font()
: love::font::Font("love.font.freetype")
{
if (FT_Init_FreeType(&library))
throw love::Exception("TrueTypeFont Loading error: FT_Init_FreeType failed");
@@ -66,11 +67,6 @@ Rasterizer *Font::newTrueTypeRasterizer(love::Data *data, int size, const font::
return new TrueTypeRasterizer(library, data, size, settings, defaultdpiscale);
}
const char *Font::getName() const
{
return "love.font.freetype";
}
} // freetype
} // font
} // love
-3
View File
@@ -47,9 +47,6 @@ public:
Rasterizer *newRasterizer(love::filesystem::FileData *data) override;
Rasterizer *newTrueTypeRasterizer(love::Data *data, int size, const font::TrueTypeRasterizer::Settings &settings) override;
// Implement Module
const char *getName() const override;
private:
// FreeType library