FontFaceBitmap.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 Image;
  8. class Serializer;
  9. /// Bitmap font face description.
  10. class URHO3D_API FontFaceBitmap : public FontFace
  11. {
  12. public:
  13. /// Construct.
  14. explicit FontFaceBitmap(Font* font);
  15. /// Destruct.
  16. ~FontFaceBitmap() override;
  17. /// Load font face.
  18. bool Load(const unsigned char* fontData, unsigned fontDataSize, float pointSize) override;
  19. /// Load from existed font face, pack used glyphs into smallest texture size and smallest number of texture.
  20. bool Load(FontFace* fontFace, bool usedGlyphs);
  21. /// Save as a new bitmap font type in XML format. Return true if successful.
  22. bool Save(Serializer& dest, int pointSize, const String& indentation = "\t");
  23. private:
  24. /// Convert graphics format to number of components.
  25. unsigned ConvertFormatToNumComponents(unsigned format);
  26. /// Save font face texture as image resource.
  27. SharedPtr<Image> SaveFaceTexture(Texture2D* texture);
  28. /// Save font face texture as image file.
  29. bool SaveFaceTexture(Texture2D* texture, const String& fileName);
  30. /// Blit.
  31. void Blit(Image* dest, int x, int y, int width, int height, Image* source, int sourceX, int sourceY, int components);
  32. };
  33. }