Skip to content

Commit feabe14

Browse files
committed
Implement Font constructor from TTF_Font*
1 parent 1e5c17c commit feabe14

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

SDL2pp/Font.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
libSDL2pp - C++11 bindings/wrapper for SDL2
3-
Copyright (C) 2014 Dmitry Marakasov <[email protected]>
3+
Copyright (C) 2014-2015 Dmitry Marakasov <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages
@@ -27,6 +27,10 @@
2727

2828
namespace SDL2pp {
2929

30+
Font::Font(TTF_Font* font) {
31+
font_ = font;
32+
}
33+
3034
Font::Font(const std::string& file, int ptsize, long index) {
3135
if ((font_ = TTF_OpenFontIndex(file.c_str(), ptsize, index)) == nullptr)
3236
throw Exception("TTF_OpenFontIndex failed");

SDL2pp/Font.hh

+8
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ private:
4949
TTF_Font* font_; ///< Managed TTF_Font object
5050

5151
public:
52+
////////////////////////////////////////////////////////////
53+
/// \brief Construct from existing TTF_Font structure
54+
///
55+
/// \param font Existing TTF_Font to manage
56+
///
57+
////////////////////////////////////////////////////////////
58+
Font(TTF_Font* font);
59+
5260
////////////////////////////////////////////////////////////
5361
/// \brief Loads font from .ttf or .fon file
5462
///

0 commit comments

Comments
 (0)