| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsCorePrerequisites.h" |
| 6 | #include "Importer/BsImportOptions.h" |
| 7 | #include "Text/BsFont.h" |
| 8 | |
| 9 | namespace bs |
| 10 | { |
| 11 | /** @addtogroup Text |
| 12 | * @{ |
| 13 | */ |
| 14 | |
| 15 | /** Determines how is a font rendered into the bitmap texture. */ |
| 16 | enum class BS_SCRIPT_EXPORT(m:Text,api:bsf,api:bed) FontRenderMode |
| 17 | { |
| 18 | Smooth, /*< Render antialiased fonts without hinting (slightly more blurry). */ |
| 19 | Raster, /*< Render non-antialiased fonts without hinting (slightly more blurry). */ |
| 20 | HintedSmooth, /*< Render antialiased fonts with hinting. */ |
| 21 | HintedRaster /*< Render non-antialiased fonts with hinting. */ |
| 22 | }; |
| 23 | |
| 24 | /** Represents a range of character code. */ |
| 25 | struct BS_SCRIPT_EXPORT(m:Text,pl:true,api:bsf,api:bed) CharRange |
| 26 | { |
| 27 | CharRange() = default; |
| 28 | CharRange(UINT32 start, UINT32 end) |
| 29 | : start(start), end(end) |
| 30 | { } |
| 31 | |
| 32 | UINT32 start = 0; |
| 33 | UINT32 end = 0; |
| 34 | }; |
| 35 | |
| 36 | /** Import options that allow you to control how is a font imported. */ |
| 37 | class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Text,api:bsf,api:bed) FontImportOptions : public ImportOptions |
| 38 | { |
| 39 | public: |
| 40 | FontImportOptions() = default; |
| 41 | |
| 42 | /** Determines font sizes that are to be imported. Sizes are in points. */ |
| 43 | BS_SCRIPT_EXPORT() |
| 44 | Vector<UINT32> fontSizes = { 10 }; |
| 45 | |
| 46 | /** Determines character index ranges to import. Ranges are defined as unicode numbers. */ |
| 47 | BS_SCRIPT_EXPORT() |
| 48 | Vector<CharRange> charIndexRanges = { CharRange(33, 166) }; // Most used ASCII characters |
| 49 | |
| 50 | /** Determines dots per inch scale that will be used when rendering the characters. */ |
| 51 | BS_SCRIPT_EXPORT() |
| 52 | UINT32 dpi = 96; |
| 53 | |
| 54 | /** Determines the render mode used for rendering the characters into a bitmap. */ |
| 55 | BS_SCRIPT_EXPORT() |
| 56 | FontRenderMode renderMode = FontRenderMode::HintedSmooth; |
| 57 | |
| 58 | /** Determines whether the bold font style should be used when rendering. */ |
| 59 | BS_SCRIPT_EXPORT() |
| 60 | bool bold = false; |
| 61 | |
| 62 | /** Determines whether the italic font style should be used when rendering. */ |
| 63 | BS_SCRIPT_EXPORT() |
| 64 | bool italic = false; |
| 65 | |
| 66 | /** Creates a new import options object that allows you to customize how are fonts imported. */ |
| 67 | BS_SCRIPT_EXPORT(ec:T) |
| 68 | static SPtr<FontImportOptions> create(); |
| 69 | |
| 70 | /************************************************************************/ |
| 71 | /* SERIALIZATION */ |
| 72 | /************************************************************************/ |
| 73 | public: |
| 74 | friend class FontImportOptionsRTTI; |
| 75 | static RTTITypeBase* getRTTIStatic(); |
| 76 | RTTITypeBase* getRTTI() const override; |
| 77 | }; |
| 78 | |
| 79 | /** @} */ |
| 80 | } |