FontEngineInterfaceDefault.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include "../../../Include/RmlUi/Core/FontEngineInterface.h"
  3. namespace Rml {
  4. class RMLUICORE_API FontEngineInterfaceDefault : public FontEngineInterface {
  5. public:
  6. /// Called when RmlUi is being initialized.
  7. void Initialize() override;
  8. /// Called when RmlUi is being shut down.
  9. void Shutdown() override;
  10. /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
  11. bool LoadFontFace(const String& file_name, int face_index, bool fallback_face, Style::FontWeight weight) override;
  12. /// Adds a new font face to the database using the provided family, style and weight.
  13. bool LoadFontFace(Span<const byte> data, int face_index, const String& font_family, Style::FontStyle style, Style::FontWeight weight,
  14. bool fallback_face) override;
  15. /// Returns a handle to a font face that can be used to position and render text. This will return the closest match
  16. /// it can find, but in the event a font family is requested that does not exist, NULL will be returned instead of a
  17. /// valid handle.
  18. FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size) override;
  19. /// Prepares for font effects by configuring a new, or returning an existing, layer configuration.
  20. FontEffectsHandle PrepareFontEffects(FontFaceHandle handle, const FontEffectList& font_effects) override;
  21. /// Returns the font metrics of the given font face.
  22. const FontMetrics& GetFontMetrics(FontFaceHandle handle) override;
  23. /// Returns the width a string will take up if rendered with this handle.
  24. int GetStringWidth(FontFaceHandle handle, StringView string, const TextShapingContext& text_shaping_context, Character prior_character) override;
  25. /// Generates the geometry required to render a single line of text.
  26. int GenerateString(RenderManager& render_manager, FontFaceHandle face_handle, FontEffectsHandle effects_handle, StringView string,
  27. Vector2f position, ColourbPremultiplied colour, float opacity, const TextShapingContext& text_shaping_context,
  28. TexturedMeshList& mesh_list) override;
  29. /// Returns the current version of the font face.
  30. int GetVersion(FontFaceHandle handle) override;
  31. /// Releases resources owned by sized font faces, including their textures and rendered glyphs.
  32. void ReleaseFontResources() override;
  33. };
  34. } // namespace Rml