FontFaceFreeType.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../UI/FontFace.h"
  5. namespace Urho3D
  6. {
  7. class FreeTypeLibrary;
  8. class Texture2D;
  9. /// Free type font face description.
  10. class URHO3D_API FontFaceFreeType : public FontFace
  11. {
  12. public:
  13. /// Construct.
  14. explicit FontFaceFreeType(Font* font);
  15. /// Destruct.
  16. ~FontFaceFreeType() override;
  17. /// Load font face.
  18. bool Load(const unsigned char* fontData, unsigned fontDataSize, float pointSize) override;
  19. /// Return pointer to the glyph structure corresponding to a character. Return null if glyph not found.
  20. const FontGlyph* GetGlyph(c32 c) override;
  21. /// Return if font face uses mutable glyphs.
  22. bool HasMutableGlyphs() const override { return hasMutableGlyph_; }
  23. private:
  24. /// Setup next texture.
  25. bool SetupNextTexture(int textureWidth, int textureHeight);
  26. /// Load char glyph.
  27. bool LoadCharGlyph(c32 charCode, Image* image = nullptr);
  28. /// Smooth one row of a horizontally oversampled glyph image.
  29. void BoxFilter(unsigned char* dest, size_t destSize, const unsigned char* src, size_t srcSize);
  30. /// FreeType library.
  31. SharedPtr<FreeTypeLibrary> freeType_;
  32. /// FreeType face. Non-null after creation only in dynamic mode.
  33. void* face_{};
  34. /// Load mode.
  35. int loadMode_{};
  36. /// Use subpixel glyph positioning?
  37. bool subpixel_{};
  38. /// Oversampling level.
  39. int oversampling_{};
  40. /// Ascender.
  41. float ascender_{};
  42. /// Has mutable glyph.
  43. bool hasMutableGlyph_{};
  44. /// Glyph area allocator.
  45. AreaAllocator allocator_;
  46. };
  47. }