From 7549778dc62b5c981db4393e264e9ab5a891e1e3 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Thu, 31 Oct 2013 10:09:57 +0100 Subject: [PATCH] Font: Add clone constructor --- src/font.cpp | 15 +++++++++++++++ src/font.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/font.cpp b/src/font.cpp index b7c07f0..d419c2e 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -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; diff --git a/src/font.h b/src/font.h index 21c3f36..7a70299 100644 --- a/src/font.h +++ b/src/font.h @@ -50,6 +50,8 @@ public: Font(const char *name = 0, int size = 0); + /* Clone constructor */ + Font(const Font &other); ~Font(); const char *getName() const;