Font: Add clone constructor

This commit is contained in:
Jonas Kulla 2013-10-31 10:09:57 +01:00
parent f067e0eff8
commit 7549778dc6
2 changed files with 17 additions and 0 deletions

View File

@ -154,6 +154,16 @@ struct FontPrivate
sdlFont = shState->fontPool().request(this->name.constData(),
this->size);
}
FontPrivate(const FontPrivate &other)
: name(other.name),
size(other.size),
bold(other.bold),
italic(other.italic),
color(&colorTmp),
colorTmp(*other.color),
sdlFont(other.sdlFont)
{}
};
QByteArray FontPrivate::defaultName = "Arial";
@ -177,6 +187,11 @@ Font::Font(const char *name,
p = new FontPrivate(name, size);
}
Font::Font(const Font &other)
{
p = new FontPrivate(*other.p);
}
Font::~Font()
{
delete p;

View File

@ -50,6 +50,8 @@ public:
Font(const char *name = 0,
int size = 0);
/* Clone constructor */
Font(const Font &other);
~Font();
const char *getName() const;