FontEngineInterfaceDefault.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. {
  33. public:
  34. FontEngineInterfaceDefault();
  35. virtual ~FontEngineInterfaceDefault();
  36. /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
  37. bool LoadFontFace(const String& file_name, bool fallback_face, Style::FontWeight weight) override;
  38. /// Adds a new font face to the database using the provided family, style and weight.
  39. bool LoadFontFace(const byte* data, int data_size, const String& font_family, Style::FontStyle style, Style::FontWeight weight, bool fallback_face) override;
  40. /// Returns a handle to a font face that can be used to position and render text. This will return the closest match
  41. /// it can find, but in the event a font family is requested that does not exist, NULL will be returned instead of a
  42. /// valid handle.
  43. FontFaceHandle GetFontFaceHandle(const String& family, Style::FontStyle style, Style::FontWeight weight, int size) override;
  44. /// Prepares for font effects by configuring a new, or returning an existing, layer configuration.
  45. FontEffectsHandle PrepareFontEffects(FontFaceHandle, const FontEffectList& font_effects) override;
  46. /// Returns the point size of this font face.
  47. int GetSize(FontFaceHandle) override;
  48. /// Returns the pixel height of a lower-case x in this font face.
  49. int GetXHeight(FontFaceHandle) override;
  50. /// Returns the default height between this font face's baselines.
  51. int GetLineHeight(FontFaceHandle) override;
  52. /// Returns the font's baseline, as a pixel offset from the bottom of the font.
  53. int GetBaseline(FontFaceHandle) override;
  54. /// Returns the font's underline, as a pixel offset from the bottom of the font.
  55. float GetUnderline(FontFaceHandle, float& thickness) override;
  56. /// Returns the width a string will take up if rendered with this handle.
  57. int GetStringWidth(FontFaceHandle, const String& string, Character prior_character) override;
  58. /// Generates the geometry required to render a single line of text.
  59. int GenerateString(FontFaceHandle, FontEffectsHandle, const String& string, const Vector2f& position, const Colourb& colour, float opacity,
  60. GeometryList& geometry) override;
  61. /// Returns the current version of the font face.
  62. int GetVersion(FontFaceHandle handle) override;
  63. /// Releases resources owned by sized font faces, including their textures and rendered glyphs.
  64. void ReleaseFontResources() override;
  65. };
  66. } // namespace Rml
  67. #endif