FontEngineInterfaceDefault.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
  38. bool LoadFontFace(const String& file_name, bool fallback_face, Style::FontWeight weight) override;
  39. /// Adds a new font face to the database using the provided family, style and weight.
  40. bool LoadFontFace(Span<const byte> data, const String& font_family, Style::FontStyle style, Style::FontWeight weight,
  41. bool fallback_face) override;
  42. /// Returns a handle to a font face that can be used to position and render text. This will return the closest match
  43. /// it can find, but in the event a font family is requested that does not exist, NULL will be returned instead of a
  44. /// valid handle.
  45. FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size) override;
  46. /// Prepares for font effects by configuring a new, or returning an existing, layer configuration.
  47. FontEffectsHandle PrepareFontEffects(FontFaceHandle handle, const FontEffectList& font_effects) override;
  48. /// Returns the font metrics of the given font face.
  49. const FontMetrics& GetFontMetrics(FontFaceHandle handle) override;
  50. /// Returns the width a string will take up if rendered with this handle.
  51. int GetStringWidth(FontFaceHandle handle, StringView string, const TextShapingContext& text_shaping_context, Character prior_character) override;
  52. /// Generates the geometry required to render a single line of text.
  53. int GenerateString(RenderManager& render_manager, FontFaceHandle face_handle, FontEffectsHandle effects_handle, StringView string,
  54. Vector2f position, ColourbPremultiplied colour, float opacity, const TextShapingContext& text_shaping_context,
  55. TexturedMeshList& mesh_list) override;
  56. /// Returns the current version of the font face.
  57. int GetVersion(FontFaceHandle handle) override;
  58. /// Releases resources owned by sized font faces, including their textures and rendered glyphs.
  59. void ReleaseFontResources() override;
  60. };
  61. } // namespace Rml
  62. #endif