Chemical Data Processing Library C++ API - Version 1.4.0
CairoFontMetrics.hpp
Go to the documentation of this file.
1 /*
2  * CairoFontMetrics.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_CAIROFONTMETRICS_HPP
30 #define CDPL_VIS_CAIROFONTMETRICS_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Vis/FontMetrics.hpp"
37 
38 
39 typedef struct _cairo _cairo_t;
40 
41 
42 namespace CDPL
43 {
44 
45  namespace Vis
46  {
47 
54  {
55 
56  public:
64 
66 
71 
73 
78  void setFont(const Font& font);
79 
84  double getAscent() const;
85 
90  double getDescent() const;
91 
96  double getHeight() const;
97 
102  double getLeading() const;
103 
109  double getWidth(const std::string& str) const;
110 
116  double getWidth(char ch) const;
117 
123  void getBounds(const std::string& str, Rectangle2D& bounds) const;
124 
130  void getBounds(char ch, Rectangle2D& bounds) const;
131 
132  private:
133  struct CairoExtents;
134 
135  CairoPointer<cairo_t> cairoContext;
136  std::unique_ptr<CairoExtents> cairoExtents;
137  };
138  } // namespace Vis
139 } // namespace CDPL
140 
141 #endif // CDPL_VIS_CAIROFONTMETRICS_HPP
struct _cairo _cairo_t
Definition: CairoFontMetrics.hpp:39
Definition of class CDPL::Vis::CairoPointer.
Definition of class CDPL::Vis::FontMetrics.
Definition of the preprocessor macro CDPL_VIS_API.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Implements the FontMetrics interface for the Cairo rendering backend.
Definition: CairoFontMetrics.hpp:54
CairoFontMetrics(const CairoPointer< cairo_t > &cairo_ctxt)
Constructs a font metrics object that operates on the Cairo drawing context specified by cairo_ctxt.
double getLeading() const
Returns the leading of the current font.
double getDescent() const
Returns the descent of the current font.
void setFont(const Font &font)
Specifies the font to use for the calculation of text metrics.
void getBounds(const std::string &str, Rectangle2D &bounds) const
Computes the tight bounding rectangle of the rendered string str in the current font.
CairoFontMetrics(const CairoFontMetrics &)=delete
CairoFontMetrics & operator=(const CairoFontMetrics &)=delete
double getAscent() const
Returns the ascent of the current font.
double getWidth(const std::string &str) const
Returns the total advance width of the rendered string str in the current font.
double getWidth(char ch) const
Returns the advance width of the rendered character ch in the current font.
void getBounds(char ch, Rectangle2D &bounds) const
Computes the tight bounding rectangle of the rendered character ch in the current font.
double getHeight() const
Returns the height of the current font.
Interface providing methods for querying information about the metrics of a font.
Definition: FontMetrics.hpp:71
Specifies a font for drawing text.
Definition: Font.hpp:54
Specifies an axis aligned rectangular area in 2D space.
Definition: Rectangle2D.hpp:51
The namespace of the Chemical Data Processing Library.