FontEngineInterfaceDefault.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef RMLUI_CORE_FONTENGINEDEFAULT_FONTENGINEINTERFACEDEFAULT_H
  28. #define RMLUI_CORE_FONTENGINEDEFAULT_FONTENGINEINTERFACEDEFAULT_H
  29. #include "../../../Include/RmlUi/Core/FontEngineInterface.h"
  30. namespace Rml {
  31. class RMLUICORE_API FontEngineInterfaceDefault : public FontEngineInterface {
  32. public:
  33. /// Called when RmlUi is being initialized.
  34. void Initialize() override;
  35. /// Called when RmlUi is being shut down.
  36. void Shutdown() override;
  37. void OnBeginFrame() override;
  38. /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
  39. bool LoadFontFace(const String& file_name, int face_index, bool fallback_face, Style::FontWeight weight) override;
  40. /// Adds a new font face to the database using the provided family, style and weight.
  41. bool LoadFontFace(Span<const byte> data, int face_index, const String& font_family, Style::FontStyle style, Style::FontWeight weight,
  42. bool fallback_face) override;
  43. /// Returns a handle to a font face that can be used to position and render text. This will return the closest match
  44. /// it can find, but in the event a font family is requested that does not exist, NULL will be returned instead of a
  45. /// valid handle.
  46. FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size) override;
  47. /// Prepares for font effects by configuring a new, or returning an existing, layer configuration.
  48. FontEffectsHandle PrepareFontEffects(FontFaceHandle handle, const FontEffectList& font_effects) override;
  49. /// Returns the font metrics of the given font face.
  50. const FontMetrics& GetFontMetrics(FontFaceHandle handle) override;
  51. /// Returns the width a string will take up if rendered with this handle.
  52. int GetStringWidth(FontFaceHandle handle, StringView string, const TextShapingContext& text_shaping_context, Character prior_character) override;
  53. /// Generates the geometry required to render a single line of text.
  54. int GenerateString(RenderManager& render_manager, FontFaceHandle face_handle, FontEffectsHandle effects_handle, StringView string,
  55. Vector2f position, ColourbPremultiplied colour, float opacity, const TextShapingContext& text_shaping_context,
  56. TexturedMeshList& mesh_list) override;
  57. bool EnsureGlyphs(FontFaceHandle face_handle, StringView string) override;
  58. /// Returns the current version of the font face.
  59. int GetVersion(FontFaceHandle handle) override;
  60. /// Releases resources owned by sized font faces, including their textures and rendered glyphs.
  61. void ReleaseFontResources() override;
  62. };
  63. } // namespace Rml
  64. #endif