From feabe1497efb12af5b741ba35afb93a66d8d8775 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Sun, 11 Jan 2015 06:36:11 +0300 Subject: [PATCH] Implement Font constructor from TTF_Font* --- SDL2pp/Font.cc | 6 +++++- SDL2pp/Font.hh | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/SDL2pp/Font.cc b/SDL2pp/Font.cc index 5be27a8..4926716 100644 --- a/SDL2pp/Font.cc +++ b/SDL2pp/Font.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2014 Dmitry Marakasov + Copyright (C) 2014-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -27,6 +27,10 @@ namespace SDL2pp { +Font::Font(TTF_Font* font) { + font_ = font; +} + Font::Font(const std::string& file, int ptsize, long index) { if ((font_ = TTF_OpenFontIndex(file.c_str(), ptsize, index)) == nullptr) throw Exception("TTF_OpenFontIndex failed"); diff --git a/SDL2pp/Font.hh b/SDL2pp/Font.hh index 7fb534a..eae4258 100644 --- a/SDL2pp/Font.hh +++ b/SDL2pp/Font.hh @@ -49,6 +49,14 @@ private: TTF_Font* font_; ///< Managed TTF_Font object public: + //////////////////////////////////////////////////////////// + /// \brief Construct from existing TTF_Font structure + /// + /// \param font Existing TTF_Font to manage + /// + //////////////////////////////////////////////////////////// + Font(TTF_Font* font); + //////////////////////////////////////////////////////////// /// \brief Loads font from .ttf or .fon file ///