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 <string>
13 
14 //----------------------------------------------------------------------------
15 
16 #include "devicecontextbase.h"
17 #include "vrvdef.h"
18 
19 namespace vrv {
20 
31 class Glyph {
32 public:
37  Glyph();
38  Glyph(std::string path, std::string codeStr);
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  std::string GetCodeStr() const { return m_codeStr; }
66  void SetCodeStr(const std::string &codeStr) { m_codeStr = codeStr; }
68 
73  std::string GetPath() const { return m_path; }
74  void SetPath(const std::string &path) { m_path = path; }
76 
81  int GetHorizAdvX() const { return m_horizAdvX; }
82  void SetHorizAdvX(double horizAdvX) { m_horizAdvX = (int)(horizAdvX * 10.0); }
84 
89  bool GetFallback() const { return m_isFallback; }
90  void SetFallback(bool isFallback) { m_isFallback = isFallback; }
92 
97  void SetAnchor(std::string anchorStr, double x, double y);
98 
102  bool HasAnchor(SMuFLGlyphAnchor anchor) const;
103 
107  const Point *GetAnchor(SMuFLGlyphAnchor anchor) const;
108 
113  void SetXML(const std::string &xml) { m_xml = xml; }
114 
119  std::string GetXML() const;
120 
121 private:
122  //
123 public:
124  //
125 private:
127  int m_x;
128  int m_y;
129  int m_width;
130  int m_height;
132  int m_horizAdvX;
134  int m_unitsPerEm;
136  std::string m_codeStr;
138  std::string m_path;
140  std::string m_xml;
142  std::map<SMuFLGlyphAnchor, Point> m_anchors;
144  bool m_isFallback;
145 };
146 
147 } // namespace vrv
148 
149 #endif
This class is used for storing a music font glyph.
Definition: glyph.h:31
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....
std::string GetXML() const
Return the XML (content) of the glyph.
void SetXML(const std::string &xml)
Set the XML (content) of the glyph.
Definition: glyph.h:113
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