💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.5 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef ANTKEEPER_TYPE_FREETYPE_TYPEFACE_HPP
  20. #define ANTKEEPER_TYPE_FREETYPE_TYPEFACE_HPP
  21. #include "type/typeface.hpp"
  22. #include <ft2build.h>
  23. #include FT_FREETYPE_H
  24. namespace type {
  25. namespace freetype {
  26. /**
  27. * Typeface implementation using the FreeType library.
  28. *
  29. * @see type::typeface
  30. */
  31. class typeface: public type::typeface
  32. {
  33. public:
  34. /**
  35. * Creates a FreeType typeface.
  36. *
  37. * @param library Pointer to a FreeType library instance.
  38. * @param face Pointer to the FreeType object instance.
  39. * @param buffer Pointer to file buffer containing FreeType face data.
  40. */
  41. typeface(FT_Library library, FT_Face face, unsigned char* buffer);
  42. /// Destroys a FreeType typeface.
  43. virtual ~typeface();
  44. /// @copydoc type::typeface::has_kerning() const
  45. virtual bool has_kerning() const;
  46. /// @copydoc type::typeface::has_glyph(char32_t) const
  47. virtual bool has_glyph(char32_t code) const;
  48. /// @copydoc type::typeface::get_metrics(float, font_metrics&) const
  49. virtual bool get_metrics(float height, font_metrics& metrics) const;
  50. /// @copydoc type::typeface::get_metrics(float, char32_t, glyph_metrics&) const
  51. virtual bool get_metrics(float height, char32_t code, glyph_metrics& metrics) const;
  52. /// @copydoc type::typeface::get_bitmap(float, char32_t, image&) const
  53. virtual bool get_bitmap(float height, char32_t code, image& bitmap) const;
  54. /// @copydoc type::typeface::get_kerning(float, char32_t, char32_t, float2&) const
  55. virtual bool get_kerning(float height, char32_t first, char32_t second, float2& offset) const;
  56. private:
  57. void set_face_pixel_size(float height) const;
  58. FT_Library library;
  59. FT_Face face;
  60. unsigned char* buffer;
  61. mutable float height;
  62. };
  63. } // namespace freetype
  64. } // namespace type
  65. #endif // ANTKEEPER_TYPE_FREETYPE_TYPEFACE_HPP