Font.h
1 /* Copyright (C) 2006-2015 Laurentiu-Gheorghe Crisan
2  Copyright (C) 2006-2015 Marc Boris Duerner
3  Copyright (C) 2010 Aloysius Indrayanto
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  As a special exception, you may use this file as part of a free
11  software library without restriction. Specifically, if other files
12  instantiate templates or use macros or inline functions from this
13  file, or you compile this file and link it with other files to
14  produce an executable, this file does not by itself cause the
15  resulting executable to be covered by the GNU General Public
16  License. This exception does not however invalidate any other
17  reasons why the executable file might be covered by the GNU Library
18  General Public License.
19 
20  This library is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  Lesser General Public License for more details.
24 
25  You should have received a copy of the GNU Lesser General Public
26  License along with this library; if not, write to the Free Software
27  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28  02110-1301 USA
29 */
30 
31 #ifndef PT_GFX_FONT_H
32 #define PT_GFX_FONT_H
33 
34 #include <Pt/Gfx/Api.h>
35 #include <Pt/Types.h>
36 #include <Pt/String.h>
37 
38 
39 namespace Pt {
40 namespace Gfx {
41 
42 
43 class PT_GFX_API Font
44 {
45  public:
46  enum Style
47  {
48  Normal = 0,
49  Bold,
50  Italic,
51  BoldItalic
52  };
53 
54  public:
55  Font();
56 
58  explicit Font( const std::string& name,
59  size_t size,
60  Style style = Normal,
61  ssize_t angle = 0);
62 
64  Font(const std::string& name, const Font& font);
65 
67  const std::string& name() const;
68 
70  size_t size() const;
71 
73  Style style() const;
74 
76  ssize_t angle() const;
77 
78  bool isNull() const;
79 
80  friend bool operator==(const Font& a, const Font& b);
81 
82  friend bool operator!=(const Font& a, const Font& b);
83 
84  // ### TODO: Remove it later! ###
85  friend bool operator<(const Font& a, const Font& b);
86 
87  private:
88  std::string _name;
89  size_t _size;
90  Style _style;
91  ssize_t _angle;
92 };
93 
94 
95 inline bool operator==(const Font& a, const Font& b)
96 {
97  return a._name == b._name &&
98  a._style == b._style &&
99  a._size == b._size &&
100  a._angle == b._angle;
101 }
102 
103 
104 inline bool operator!=(const Font& a, const Font& b)
105 {
106  return a._name != b._name ||
107  a._style != b._style ||
108  a._size != b._size ||
109  a._angle != b._angle;
110 }
111 
112 // ### TODO: Remove it later! ###
113 inline bool operator<(const Font& a, const Font& b)
114 {
115  if(a._name < b._name)
116  return true;
117 
118  if(a._name > b._name)
119  return false;
120 
121  return a._style < b._style;
122 }
123 
124 
125 } //namespace
126 } //namespace
127 
128 #endif