Font.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/se/Font.h
22 
23  \brief A Font specifies the text font to use in a text symbolizer.
24 */
25 
26 #ifndef __TERRALIB_SE_INTERNAL_FONT_H
27 #define __TERRALIB_SE_INTERNAL_FONT_H
28 
29 // TerraLib
30 #include "Config.h"
31 
32 // STL
33 #include <map>
34 #include <string>
35 
36 // Boost
37 #include <boost/noncopyable.hpp>
38 
39 namespace te
40 {
41  namespace se
42  {
43 // Forward declarations
44  class SvgParameter;
45 
46  /*!
47  \class Font
48 
49  \brief A Font specifies the text font to use in a text symbolizer.
50 
51  The allowed SvgParameters are:
52  <ul>
53  <li>font-family</li>
54  <li>font-style: normal, italic, and oblique</li>
55  <li>font-weight: normal and bold</li>
56  <li>font-size</li>
57  </ul>
58 
59  \ingroup se
60 
61  \sa TextSymbolizer
62  */
63  class TESEEXPORT Font : public boost::noncopyable
64  {
65  public:
66 
67  /*!
68  \enum FontStyleType
69 
70  \brief It defines the style to use for a font.
71  */
73  {
74  StyleNormal, /*!< Normal font style. */
75  StyleItalic, /*!< Italic font style. */
76  StyleOblique /*!< Oblique font style. */
77  };
78 
79  /*!
80  \enum FontWeightType
81 
82  \brief It gives the amount of weight or boldness to use for a font.
83  */
85  {
86  WeightNormal, /*!< Normal. */
87  WeightBold /*!< Bold. */
88  };
89 
90  /** @name Initializer Methods
91  * Methods related to instantiation and destruction.
92  */
93  //@{
94 
95  /*! \brief It initializes a new Font. */
96  Font();
97 
98  /*! \brief Destructor. */
99  ~Font();
100 
101  //@}
102 
103  /** @name Accessor methods
104  * Methods used to get or set properties.
105  */
106  //@{
107 
108  /*!
109  \brief Add a SvgParameter to this Font.
110 
111  \note If there is already a SvgParamater with the same name it will be overrided.
112  \note The Font object will take the ownership of the informed p pointer.
113  */
114  void add(SvgParameter* p);
115 
116  void setFamily(const std::string& family);
117 
118  void setStyle(const FontStyleType& style);
119 
120  void setWeight(const FontWeightType& weight);
121 
122  void setSize(const std::string& size);
123 
124  const SvgParameter* getFamily() const;
125 
126  const SvgParameter* getStyle() const;
127 
128  const SvgParameter* getWeight() const;
129 
130  const SvgParameter* getSize() const;
131 
132  //@}
133 
134  /*! \brief It creates a new copy of this object. */
135  Font* clone() const;
136 
137  private:
138 
139  void setParameter(const std::string& name, const std::string& value);
140 
141  const SvgParameter* getParameter(const std::string& name) const;
142 
143  private:
144 
145  std::map<std::string, SvgParameter*> m_svgParams; //!< Set of SvgParameters.
146 
147  static std::map<FontStyleType, std::string> sm_fontStyleMap; //!< A map that associates FontStyleType to the correct string value.
148  static std::map<FontWeightType, std::string> sm_fontWeightMap; //!< A map that associates FontWeightType to the correct string value.
149 
150  static const std::string sm_family; //!< SVG/CSS "font-family" parameter.
151  static const std::string sm_style; //!< SVG/CSS "font-style parameter.
152  static const std::string sm_weight; //!< SVG/CSS "font-weight" parameter.
153  static const std::string sm_size; //!< SVG/CSS "font-size" parameter.
154  };
155 
156  } // end namespace se
157 } // end namespace te
158 
159 #endif // __TERRALIB_SE_INTERNAL_FONT_H
160 
static const std::string sm_family
SVG/CSS "font-family" parameter.
Definition: Font.h:150
std::map< std::string, SvgParameter * > m_svgParams
Set of SvgParameters.
Definition: Font.h:145
URI C++ Library.
A Font specifies the text font to use in a text symbolizer.
Definition: Font.h:63
static const std::string sm_weight
SVG/CSS "font-weight" parameter.
Definition: Font.h:152
FontStyleType
It defines the style to use for a font.
Definition: Font.h:72
#define TESEEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:187
static const std::string sm_size
SVG/CSS "font-size" parameter.
Definition: Font.h:153
Configuration flags for the Symbology Encoding support of TerraLib.
A SvgParameter refers to an SVG/CSS graphical-formatting parameter.
Definition: SvgParameter.h:48
static const std::string sm_style
SVG/CSS "font-style parameter.
Definition: Font.h:151
FontWeightType
It gives the amount of weight or boldness to use for a font.
Definition: Font.h:84
static std::map< FontWeightType, std::string > sm_fontWeightMap
A map that associates FontWeightType to the correct string value.
Definition: Font.h:148
static std::map< FontStyleType, std::string > sm_fontStyleMap
A map that associates FontStyleType to the correct string value.
Definition: Font.h:147