mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Rework internal module registration to happen in constructors.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user