FontEngineInterfaceDefault.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 RMLUICOREFONTENGINEINTERFACEDEFAULT_H
  28. #define RMLUICOREFONTENGINEINTERFACEDEFAULT_H
  29. #include "../../Include/RmlUi/Core/FontEngineInterface.h"
  30. namespace Rml {
  31. namespace Core {
  32. class RMLUICORE_API FontEngineInterfaceDefault: public FontEngineInterface
  33. {
  34. public:
  35. FontEngineInterfaceDefault();
  36. virtual ~FontEngineInterfaceDefault();
  37. /// Adds a new font face to the database. The face's family, style and weight will be determined from the face itself.
  38. /// @param[in] file_name The file to load the face from.
  39. /// @return True if the face was loaded successfully, false otherwise.
  40. virtual bool LoadFontFace(const String& file_name) override;
  41. /// Returns a handle to a font face that can be used to position and render text. This will return the closest match
  42. /// it can find, but in the event a font family is requested that does not exist, NULL will be returned instead of a
  43. /// valid handle.
  44. /// @param[in] family The family of the desired font handle.
  45. /// @param[in] charset The set of characters required in the font face, as a comma-separated list of unicode ranges.
  46. /// @param[in] style The style of the desired font handle.
  47. /// @param[in] weight The weight of the desired font handle.
  48. /// @param[in] size The size of desired handle, in points.
  49. /// @return A valid handle if a matching (or closely matching) font face was found, NULL otherwise.
  50. virtual FontFaceHandle GetFontFaceHandle(const String& family, const String& charset, Style::FontStyle style, Style::FontWeight weight, int size) override;
  51. /// Generates, if required, the layer configuration for a given array of font effects.
  52. /// @param[in] FontHandle
  53. /// @param[in] font_effects The list of font effects to generate the configuration for.
  54. /// @return The index to use when generating geometry using this configuration.
  55. virtual int GenerateLayerConfiguration(FontFaceHandle, const FontEffectList& font_effects) const override;
  56. /// Returns the average advance of all glyphs in this font face.
  57. /// @param[in] FontHandle
  58. /// @return An approximate width of the characters in this font face.
  59. virtual int GetCharacterWidth(FontFaceHandle) const override;
  60. /// Returns the point size of this font face.
  61. /// @param[in] FontHandle
  62. /// @return The face's point size.
  63. virtual int GetSize(FontFaceHandle) const override;
  64. /// Returns the pixel height of a lower-case x in this font face.
  65. /// @param[in] FontHandle
  66. /// @return The height of a lower-case x.
  67. virtual int GetXHeight(FontFaceHandle) const override;
  68. /// Returns the default height between this font face's baselines.
  69. /// @param[in] FontHandle
  70. /// @return The default line height.
  71. virtual int GetLineHeight(FontFaceHandle) const override;
  72. /// Returns the font's baseline, as a pixel offset from the bottom of the font.
  73. /// @param[in] FontHandle
  74. /// @return The font's baseline.
  75. virtual int GetBaseline(FontFaceHandle) const override;
  76. /// Returns the font's underline, as a pixel offset from the bottom of the font.
  77. /// @param[in] FontHandle
  78. /// @return The font's underline thickness.
  79. virtual float GetUnderline(FontFaceHandle, float *thickness) const override;
  80. /// Returns the width a string will take up if rendered with this handle.
  81. /// @param[in] FontHandle
  82. /// @param[in] string The string to measure.
  83. /// @param[in] prior_character The optionally-specified character that immediately precedes the string. This may have an impact on the string width due to kerning.
  84. /// @return The width, in pixels, this string will occupy if rendered with this handle.
  85. virtual int GetStringWidth(FontFaceHandle, const WString& string, word prior_character = 0) override;
  86. /// Generates the geometry required to render a single line of text.
  87. /// @param[out] geometry An array of geometries to generate the geometry into.
  88. /// @param[in] FontHandle
  89. /// @param[in] string The string to render.
  90. /// @param[in] position The position of the baseline of the first character to render.
  91. /// @param[in] colour The colour to render the text.
  92. /// @return The width, in pixels, of the string geometry.
  93. virtual int GenerateString(FontFaceHandle, GeometryList& geometry, const WString& string, const Vector2f& position, const Colourb& colour, int layer_configuration) const override;
  94. };
  95. }
  96. }
  97. #endif