Font: Add clone constructor
This commit is contained in:
parent
f067e0eff8
commit
7549778dc6
15
src/font.cpp
15
src/font.cpp
|
@ -154,6 +154,16 @@ struct FontPrivate
|
||||||
sdlFont = shState->fontPool().request(this->name.constData(),
|
sdlFont = shState->fontPool().request(this->name.constData(),
|
||||||
this->size);
|
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";
|
QByteArray FontPrivate::defaultName = "Arial";
|
||||||
|
@ -177,6 +187,11 @@ Font::Font(const char *name,
|
||||||
p = new FontPrivate(name, size);
|
p = new FontPrivate(name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Font::Font(const Font &other)
|
||||||
|
{
|
||||||
|
p = new FontPrivate(*other.p);
|
||||||
|
}
|
||||||
|
|
||||||
Font::~Font()
|
Font::~Font()
|
||||||
{
|
{
|
||||||
delete p;
|
delete p;
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
|
|
||||||
Font(const char *name = 0,
|
Font(const char *name = 0,
|
||||||
int size = 0);
|
int size = 0);
|
||||||
|
/* Clone constructor */
|
||||||
|
Font(const Font &other);
|
||||||
~Font();
|
~Font();
|
||||||
|
|
||||||
const char *getName() const;
|
const char *getName() const;
|
||||||
|
|
Loading…
Reference in New Issue