xoreos  0.0.5
fonthandle.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include <cassert>
26 
27 #include "src/graphics/font.h"
28 
31 
32 namespace Graphics {
33 
34 namespace Aurora {
35 
36 ManagedFont::ManagedFont(Font *f) : font(f), referenceCount(0) {
37 }
38 
39 
40 FontHandle::FontHandle() : _empty(true) {
41 }
42 
43 FontHandle::FontHandle(FontMap::iterator &i) : _empty(false), _it(i) {
44  _it->second->referenceCount++;
45 }
46 
47 FontHandle::FontHandle(const FontHandle &right) : _empty(true) {
48  *this = right;
49 }
50 
52  clear();
53 }
54 
56  if (this == &right)
57  return *this;
58 
59  clear();
60 
61  FontMan.assign(*this, right);
62 
63  return *this;
64 }
65 
66 bool FontHandle::empty() const {
67  return _empty;
68 }
69 
72  if (_empty)
73  return kEmptyString;
74 
75  return _it->first;
76 }
77 
79  FontMan.release(*this);
80 }
81 
83  assert(!_empty);
84 
85  return *_it->second->font;
86 }
87 
88 } // End of namespace Aurora
89 
90 } // End of namespace Graphics
A class holding an UTF-8 string.
Definition: ustring.h:48
const Common::UString kEmptyString
Definition: fonthandle.cpp:70
A handle to a font.
Definition: fonthandle.h:52
The Aurora font manager.
A handle to an Aurora font.
An abstract font.
Definition: font.h:39
const Common::UString & getName() const
Definition: fonthandle.cpp:71
A font.
FontHandle & operator=(const FontHandle &right)
Definition: fonthandle.cpp:55
FontMap::iterator _it
Definition: fonthandle.h:69
#define FontMan
Shortcut for accessing the font manager.
Definition: fontman.h:105