BsFontImportOptions.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsImportOptions.h"
  4. #include "BsFont.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Determines how is a font rendered into the bitmap texture.
  9. */
  10. enum class FontRenderMode
  11. {
  12. Smooth, /*< Render antialiased fonts without hinting (slightly more blurry). */
  13. Raster, /*< Render non-antialiased fonts without hinting (slightly more blurry). */
  14. HintedSmooth, /*< Render antialiased fonts with hinting. */
  15. HintedRaster /*< Render non-antialiased fonts with hinting. */
  16. };
  17. /**
  18. * @brief Import options that allow you to control how is a font
  19. * imported.
  20. */
  21. class BS_CORE_EXPORT FontImportOptions : public ImportOptions
  22. {
  23. public:
  24. FontImportOptions();
  25. /**
  26. * @brief Sets font sizes that are to be imported. Sizes are in points.
  27. */
  28. void setFontSizes(const Vector<UINT32>& fontSizes) { mFontSizes = fontSizes; }
  29. /**
  30. * @brief Adds an index range of characters to import.
  31. */
  32. void addCharIndexRange(UINT32 from, UINT32 to);
  33. /**
  34. * @brief Clears all character indexes, so no character are imported.
  35. */
  36. void clearCharIndexRanges();
  37. /**
  38. * @brief Sets dots per inch resolution to use when rendering the characters into the texture.
  39. */
  40. void setDPI(UINT32 dpi) { mDPI = dpi; }
  41. /**
  42. * @brief Set the render mode used for rendering the characters into a bitmap.
  43. */
  44. void setRenderMode(FontRenderMode renderMode) { mRenderMode = renderMode; }
  45. /**
  46. * @brief Sets whether the bold font style should be used when rendering.
  47. */
  48. void setBold(bool bold) { mBold = bold; }
  49. /**
  50. * @brief Sets whether the italic font style should be used when rendering.
  51. */
  52. void setItalic(bool italic) { mItalic = italic; }
  53. /**
  54. * @brief Gets the sizes that are to be imported. Ranges are defined as unicode numbers.
  55. */
  56. Vector<UINT32> getFontSizes() const { return mFontSizes; }
  57. /**
  58. * @brief Gets character index ranges to import. Ranges are defined as unicode numbers.
  59. */
  60. Vector<std::pair<UINT32, UINT32>> getCharIndexRanges() const { return mCharIndexRanges; }
  61. /**
  62. * @brief Returns dots per inch scale that will be used when rendering the characters.
  63. */
  64. UINT32 getDPI() const { return mDPI; }
  65. /**
  66. * @brief Get the render mode used for rendering the characters into a bitmap.
  67. */
  68. FontRenderMode getRenderMode() const { return mRenderMode; }
  69. /**
  70. * @brief Sets whether the bold font style should be used when rendering.
  71. */
  72. bool getBold() const { return mBold; }
  73. /**
  74. * @brief Sets whether the italic font style should be used when rendering.
  75. */
  76. bool getItalic() const { return mItalic; }
  77. /************************************************************************/
  78. /* SERIALIZATION */
  79. /************************************************************************/
  80. public:
  81. friend class FontImportOptionsRTTI;
  82. static RTTITypeBase* getRTTIStatic();
  83. virtual RTTITypeBase* getRTTI() const override;
  84. private:
  85. Vector<UINT32> mFontSizes;
  86. Vector<std::pair<UINT32, UINT32>> mCharIndexRanges;
  87. UINT32 mDPI;
  88. FontRenderMode mRenderMode;
  89. bool mBold;
  90. bool mItalic;
  91. };
  92. }