FastUIDraw
glyph_metrics.hpp
Go to the documentation of this file.
1 /*!
2  * \file glyph_metrics.hpp
3  * \brief file glyph_metrics.hpp
4  *
5  * Copyright 2016 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 
20 #ifndef FASTUIDRAW_GLYPH_METRICS_HPP
21 #define FASTUIDRAW_GLYPH_METRICS_HPP
22 
23 #include <stdint.h>
24 
25 #include <fastuidraw/util/util.hpp>
26 #include <fastuidraw/util/vecN.hpp>
29 
30 namespace fastuidraw
31 {
32 /*!\addtogroup Glyph
33  * @{
34  */
35  class FontBase;
36 
37  /*!
38  * \brief
39  * A GlyphMetrics provides information on the metrics
40  * of a glyph, all the values are in units of the font
41  * glyph. The function units_per_EM() provides the
42  * conversion factor to pixel coordinates via
43  * \f$PixelCoordinates = FontCoordinates * PixelSize / units_per_EM()\f$
44  * where PixelSize is the pixel size in which one is
45  * to render the text.
46  */
48  {
49  public:
50  /*!
51  * Ctor.
52  */
53  GlyphMetrics(void):
54  m_d(nullptr)
55  {}
56 
57  /*!
58  * Returns true if the Glyph refers to actual
59  * glyph data
60  */
61  bool
62  valid(void) const
63  {
64  return m_d != nullptr;
65  }
66 
67  /*!
68  * The index of the glyph into the -font- of the glyph
69  */
70  uint32_t
71  glyph_code(void) const;
72 
73  /*!
74  * Font of the glyph
75  */
77  font(void) const;
78 
79  /*!
80  * The offset (in font coordinates) from the pen
81  * at which to display the glyph when performing
82  * horizontal text layout.
83  */
84  vec2
85  horizontal_layout_offset(void) const;
86 
87  /*!
88  * The offset (in font coordinates) from the pen
89  * at which to display the glyph when performing
90  * horizontal text layout.
91  */
92  vec2
93  vertical_layout_offset(void) const;
94 
95  /*!
96  * Size (in font coordinates) at which to draw
97  * the glyph.
98  */
99  vec2
100  size(void) const;
101 
102  /*!
103  * How much (in font coordinates) to advance the pen
104  * after drawing the glyph. The x-coordinate holds the
105  * advance when performing layout horizontally and
106  * the y-coordinate when performing layout vertically.
107  */
108  vec2
109  advance(void) const;
110 
111  /*!
112  * The number of font units per EM for the glyph.
113  * The conversion from font coordinates to pixel
114  * coordiantes is given by:
115  * \f$PixelCoordinates = FontCoordinates * PixelSize / units_per_EM\f$
116  */
117  float
118  units_per_EM(void) const;
119 
120  private:
121  friend class GlyphCache;
122  friend class Glyph;
123 
124  explicit
125  GlyphMetrics(void *p):
126  m_d(p)
127  {}
128 
129  void *m_d;
130  };
131 /*! @} */
132 }
133 
134 #endif
bool valid(void) const
vec2 advance(void) const
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A wrapper over a pointer to implement reference counting.
A GlyphCache represents a cache of glyphs and manages the uploading of the data to a GlyphAtlas...
Definition: glyph_cache.hpp:43
float units_per_EM(void) const
file c_array.hpp
vec2 size(void) const
file util.hpp
file vecN.hpp
A GlyphMetrics provides information on the metrics of a glyph, all the values are in units of the fon...
A Glyph is essentially an opaque pointer to data for rendering and performing layout of a glyph...
Definition: glyph.hpp:48
vec2 vertical_layout_offset(void) const
const reference_counted_ptr< const FontBase > & font(void) const
vec2 horizontal_layout_offset(void) const
uint32_t glyph_code(void) const
file reference_counted.hpp