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  WeightLight = 25, /*!< Weight Light. */
87  WeightNormal = 50, /*!< Weight Normal. */
88  WeightDemiBold = 63, /*!< Weight DemiBold.*/
89  WeightBold = 75, /*!< Weight Bold. */
90  WeightBlack = 87 /*!< Weight Black. */
91  };
92 
93  /** @name Initializer Methods
94  * Methods related to instantiation and destruction.
95  */
96  //@{
97 
98  /*! \brief It initializes a new Font. */
99  Font();
100 
101  /*! \brief Destructor. */
102  ~Font();
103 
104  //@}
105 
106  /** @name Accessor methods
107  * Methods used to get or set properties.
108  */
109  //@{
110 
111  /*!
112  \brief Add a SvgParameter to this Font.
113 
114  \note If there is already a SvgParamater with the same name it will be overrided.
115  \note The Font object will take the ownership of the informed p pointer.
116  */
117  void add(SvgParameter* p);
118 
119  void setFamily(const std::string& family);
120 
121  void setStyle(const FontStyleType& style);
122 
123  void setWeight(const FontWeightType& weight);
124 
125  void setSize(const std::string& size);
126 
127  const SvgParameter* getFamily() const;
128 
129  const SvgParameter* getStyle() const;
130 
131  const SvgParameter* getWeight() const;
132 
133  const SvgParameter* getSize() const;
134 
135  //@}
136 
137  /*! \brief It creates a new copy of this object. */
138  Font* clone() const;
139 
140  private:
141 
142  void setParameter(const std::string& name, const std::string& value);
143 
144  const SvgParameter* getParameter(const std::string& name) const;
145 
146  private:
147 
148  std::map<std::string, SvgParameter*> m_svgParams; //!< Set of SvgParameters.
149 
150  static std::map<FontStyleType, std::string> sm_fontStyleMap; //!< A map that associates FontStyleType to the correct string value.
151  static std::map<FontWeightType, std::string> sm_fontWeightMap; //!< A map that associates FontWeightType to the correct string value.
152 
153  static const std::string sm_family; //!< SVG/CSS "font-family" parameter.
154  static const std::string sm_style; //!< SVG/CSS "font-style parameter.
155  static const std::string sm_weight; //!< SVG/CSS "font-weight" parameter.
156  static const std::string sm_size; //!< SVG/CSS "font-size" parameter.
157  };
158 
159  } // end namespace se
160 } // end namespace te
161 
162 #endif // __TERRALIB_SE_INTERNAL_FONT_H
163 
static const std::string sm_family
SVG/CSS "font-family" parameter.
Definition: Font.h:153
std::map< std::string, SvgParameter * > m_svgParams
Set of SvgParameters.
Definition: Font.h:148
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:155
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:156
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:154
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:151
static std::map< FontStyleType, std::string > sm_fontStyleMap
A map that associates FontStyleType to the correct string value.
Definition: Font.h:150