BsFontImportOptions.h 3.3 KB

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