font.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #if defined(Hiro_Font)
  2. const string Font::Sans = "{sans}";
  3. const string Font::Serif = "{serif}";
  4. const string Font::Mono = "{mono}";
  5. Font::Font(const string& family, float size) {
  6. setFamily(family);
  7. setSize(size);
  8. state.bold = false;
  9. state.italic = false;
  10. }
  11. Font::operator bool() const {
  12. return state.family || state.size || state.bold || state.italic;
  13. }
  14. auto Font::operator==(const Font& source) const -> bool {
  15. return family() == source.family() && size() == source.size() && bold() == source.bold() && italic() == source.italic();
  16. }
  17. auto Font::operator!=(const Font& source) const -> bool {
  18. return !operator==(source);
  19. }
  20. auto Font::bold() const -> bool {
  21. return state.bold;
  22. }
  23. auto Font::family() const -> string {
  24. return state.family;
  25. }
  26. auto Font::italic() const -> bool {
  27. return state.italic;
  28. }
  29. auto Font::reset() -> type& {
  30. state.family = "";
  31. state.size = 0;
  32. state.bold = false;
  33. state.italic = false;
  34. return *this;
  35. }
  36. auto Font::setBold(bool bold) -> type& {
  37. state.bold = bold;
  38. return *this;
  39. }
  40. auto Font::setFamily(const string& family) -> type& {
  41. state.family = family;
  42. return *this;
  43. }
  44. auto Font::setItalic(bool italic) -> type& {
  45. state.italic = italic;
  46. return *this;
  47. }
  48. auto Font::setSize(float size) -> type& {
  49. state.size = size;
  50. return *this;
  51. }
  52. auto Font::size() const -> float {
  53. return state.size;
  54. }
  55. auto Font::size(const string& text) const -> Size {
  56. return pFont::size(*this, text);
  57. }
  58. #endif