Verovio
Source code documentation
glyph.h
1 // Name: glyph.h
3 // Author: Rodolfo Zitellini
4 // Created: 30/07/2012
5 // Copyright (c) Authors and others. All rights reserved.
7 
8 #ifndef __VRV_GLYPH_H__
9 #define __VRV_GLYPH_H__
10 
11 #include <algorithm>
12 #include <cstdint>
13 #include <string>
14 
15 //----------------------------------------------------------------------------
16 
17 #include "devicecontextbase.h"
18 #include "vrvdef.h"
19 
20 namespace vrv {
21 
32 class Glyph {
33 public:
38  Glyph();
39  Glyph(int unitsPerEm);
40  virtual ~Glyph();
42 
44  void GetBoundingBox(int &x, int &y, int &w, int &h) const;
45 
51  void SetBoundingBox(double x, double y, double w, double h);
52 
57  int GetUnitsPerEm() const { return m_unitsPerEm; }
58  void SetUnitsPerEm(int units) { m_unitsPerEm = units; }
60 
65  const std::string &GetCodeStr() const { return m_codeStr; }
66  void SetCodeStr(const std::string &codeStr) { m_codeStr = codeStr; }
68 
73  int GetHorizAdvX() const { return m_horizAdvX; }
74  void SetHorizAdvX(double horizAdvX) { m_horizAdvX = (int)(horizAdvX * 10.0); }
76 
81  void SetAnchor(std::string anchorStr, double x, double y);
82 
86  bool HasAnchor(SMuFLGlyphAnchor anchor) const;
87 
91  const Point *GetAnchor(SMuFLGlyphAnchor anchor) const;
92 
97  void SetFace(uint64_t faceIdentity, int glyphId)
98  {
99  m_faceIdentity = faceIdentity;
100  m_glyphId = glyphId;
101  }
102  uint64_t GetFaceIdentity() const { return m_faceIdentity; }
103  int GetGlyphId() const { return m_glyphId; }
105 
106 private:
107  //
108 public:
109  //
110 private:
112  int m_x;
113  int m_y;
114  int m_width;
115  int m_height;
117  int m_horizAdvX;
119  int m_unitsPerEm;
121  std::string m_codeStr;
123  std::map<SMuFLGlyphAnchor, Point> m_anchors;
125  uint64_t m_faceIdentity;
126  int m_glyphId;
127 };
128 
129 } // namespace vrv
130 
131 #endif
This class is used for storing a music font glyph.
Definition: glyph.h:32
void SetAnchor(std::string anchorStr, double x, double y)
Add an anchor for the glyph.
void SetBoundingBox(double x, double y, double w, double h)
Set the bounds of the glyph These are original values from the font and will be stored as (int)(10....
bool HasAnchor(SMuFLGlyphAnchor anchor) const
Check if the glyph has anchor provided.
const Point * GetAnchor(SMuFLGlyphAnchor anchor) const
Return the SMuFL anchor for the glyph.
void GetBoundingBox(int &x, int &y, int &w, int &h) const
Get the bounds of the glyph.
Simple class for representing points.
Definition: devicecontextbase.h:203