Glyph.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. #include "Types.h"
  25. namespace crown
  26. {
  27. class Glyph
  28. {
  29. public:
  30. /// Constructor
  31. Glyph() :
  32. m_code_point(0),
  33. m_left(0),
  34. m_right(0),
  35. m_bottom(0),
  36. m_top(0),
  37. m_width(0),
  38. m_height(0),
  39. m_advance(0),
  40. m_baseline(0)
  41. {
  42. }
  43. /// Constructor
  44. Glyph(uint32_t code, float left, float right, float bottom, float top, float width, float height, float advance, float baseline) :
  45. m_code_point(code),
  46. m_left(left),
  47. m_right(right),
  48. m_bottom(bottom),
  49. m_top(top),
  50. m_width(width),
  51. m_height(height),
  52. m_advance(advance),
  53. m_baseline(baseline)
  54. {
  55. }
  56. /// Destructor
  57. ~Glyph()
  58. {
  59. }
  60. /// Returns the glyph's metrics
  61. void metrics(float& left, float& right, float& bottom, float& top, float& width, float& height, float& advance, float& baseline) const
  62. {
  63. left = m_left;
  64. right = m_right;
  65. bottom = m_bottom;
  66. top = m_top;
  67. width = m_width;
  68. height = m_height;
  69. advance = m_advance;
  70. baseline = m_baseline;
  71. }
  72. /// Sets the glyph's metrics
  73. void set_metrics(float left, float right, float bottom, float top, float width, float height, float advance, float baseline)
  74. {
  75. m_left = left;
  76. m_right = right;
  77. m_bottom = bottom;
  78. m_top = top;
  79. m_width = width;
  80. m_height = height;
  81. m_advance = advance;
  82. m_baseline = baseline;
  83. }
  84. /// Returns the glyph's code point
  85. uint32_t code_point() const
  86. {
  87. return m_code_point;
  88. }
  89. private:
  90. uint32_t m_code_point;
  91. float m_left;
  92. float m_right;
  93. float m_bottom;
  94. float m_top;
  95. float m_width;
  96. float m_height;
  97. float m_advance;
  98. float m_baseline;
  99. };
  100. } // namespace crown