BsFontImportOptions.h 3.0 KB

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