diff --git a/Source/Editor/Windows/SplashScreen.cpp b/Source/Editor/Windows/SplashScreen.cpp index 3e36d3618..7cf7a7f78 100644 --- a/Source/Editor/Windows/SplashScreen.cpp +++ b/Source/Editor/Windows/SplashScreen.cpp @@ -304,6 +304,6 @@ void SplashScreen::OnFontLoaded(Asset* asset) // Create fonts const float s = _dpiScale; - _titleFont = font->CreateFont((uint32)(35 * s)); - _subtitleFont = font->CreateFont((uint32)(9 * s)); + _titleFont = font->CreateFont(35 * s); + _subtitleFont = font->CreateFont(9 * s); } diff --git a/Source/Engine/Render2D/Font.cpp b/Source/Engine/Render2D/Font.cpp index f12a9ce1c..90423f5ce 100644 --- a/Source/Engine/Render2D/Font.cpp +++ b/Source/Engine/Render2D/Font.cpp @@ -7,7 +7,7 @@ #include "Engine/Threading/Threading.h" #include "IncludeFreeType.h" -Font::Font(FontAsset* parentAsset, int32 size) +Font::Font(FontAsset* parentAsset, float size) : ManagedScriptingObject(SpawnParams(Guid::New(), Font::TypeInitializer)) , _asset(parentAsset) , _size(size) @@ -436,7 +436,7 @@ void Font::FlushFaceSize() const { // Set the character size const FT_Face face = _asset->GetFTFace(); - const FT_Error error = FT_Set_Char_Size(face, 0, ConvertPixelTo26Dot6((float)_size * FontManager::FontScale), DefaultDPI, DefaultDPI); + const FT_Error error = FT_Set_Char_Size(face, 0, ConvertPixelTo26Dot6(_size * FontManager::FontScale), DefaultDPI, DefaultDPI); if (error) { LOG_FT_ERROR(error); diff --git a/Source/Engine/Render2D/Font.h b/Source/Engine/Render2D/Font.h index d68f497d6..90f723cd8 100644 --- a/Source/Engine/Render2D/Font.h +++ b/Source/Engine/Render2D/Font.h @@ -228,7 +228,7 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Font); private: FontAsset* _asset; - int32 _size; + float _size; int32 _height; int32 _ascender; int32 _descender; @@ -244,7 +244,7 @@ public: /// /// The parent asset. /// The size. - Font(FontAsset* parentAsset, int32 size); + Font(FontAsset* parentAsset, float size); /// /// Finalizes an instance of the class. @@ -264,7 +264,7 @@ public: /// /// Gets font size. /// - API_PROPERTY() FORCE_INLINE int32 GetSize() const + API_PROPERTY() FORCE_INLINE float GetSize() const { return _size; } diff --git a/Source/Engine/Render2D/FontAsset.cpp b/Source/Engine/Render2D/FontAsset.cpp index 5fa07771f..f000eb3c6 100644 --- a/Source/Engine/Render2D/FontAsset.cpp +++ b/Source/Engine/Render2D/FontAsset.cpp @@ -92,7 +92,7 @@ void FontAsset::SetOptions(const FontOptions& value) _options = value; } -Font* FontAsset::CreateFont(int32 size) +Font* FontAsset::CreateFont(float size) { PROFILE_CPU(); diff --git a/Source/Engine/Render2D/FontAsset.h b/Source/Engine/Render2D/FontAsset.h index abc601f45..60dbee01d 100644 --- a/Source/Engine/Render2D/FontAsset.h +++ b/Source/Engine/Render2D/FontAsset.h @@ -139,7 +139,7 @@ public: /// /// The font characters size. /// The created font object. - API_FUNCTION() Font* CreateFont(int32 size); + API_FUNCTION() Font* CreateFont(float size); /// /// Gets the font with bold style. Returns itself or creates a new virtual font asset using this font but with bold option enabled. diff --git a/Source/Engine/Render2D/FontReference.cs b/Source/Engine/Render2D/FontReference.cs index 290e10312..cc32bcd9a 100644 --- a/Source/Engine/Render2D/FontReference.cs +++ b/Source/Engine/Render2D/FontReference.cs @@ -13,7 +13,7 @@ namespace FlaxEngine private FontAsset _font; [NoSerialize] - private int _size; + private float _size; [NoSerialize] private Font _cachedFont; @@ -33,7 +33,7 @@ namespace FlaxEngine /// /// The font. /// The font size. - public FontReference(FontAsset font, int size) + public FontReference(FontAsset font, float size) { _font = font; _size = size; @@ -91,7 +91,7 @@ namespace FlaxEngine /// The size of the font characters. /// [EditorOrder(10), Limit(1, 500, 0.1f), Tooltip("The size of the font characters.")] - public int Size + public float Size { get => _size; set @@ -187,7 +187,7 @@ namespace FlaxEngine unchecked { int hashCode = _font ? _font.GetHashCode() : 0; - hashCode = (hashCode * 397) ^ _size; + hashCode = (hashCode * 397) ^ _size.GetHashCode(); return hashCode; } } diff --git a/Source/Engine/UI/TextRender.cpp b/Source/Engine/UI/TextRender.cpp index d4db794eb..cd60abddf 100644 --- a/Source/Engine/UI/TextRender.cpp +++ b/Source/Engine/UI/TextRender.cpp @@ -73,14 +73,14 @@ void TextRender::SetColor(const Color& value) } } -int32 TextRender::GetFontSize() const +float TextRender::GetFontSize() const { return _size; } -void TextRender::SetFontSize(int32 value) +void TextRender::SetFontSize(float value) { - value = Math::Clamp(value, 1, 1024); + value = Math::Clamp(value, 1.0f, 1024.0f); if (_size != value) { _size = value; diff --git a/Source/Engine/UI/TextRender.h b/Source/Engine/UI/TextRender.h index d69b5427b..816ad8aa4 100644 --- a/Source/Engine/UI/TextRender.h +++ b/Source/Engine/UI/TextRender.h @@ -38,7 +38,7 @@ private: LocalizedString _text; Color _color; TextLayoutOptions _layoutOptions; - int32 _size; + float _size; int32 _sceneRenderingKey = -1; BoundingBox _localBox; @@ -91,12 +91,12 @@ public: /// Gets the font characters size. /// API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(32), Limit(1, 1000), EditorDisplay(\"Text\")") - int32 GetFontSize() const; + float GetFontSize() const; /// /// Sets the font characters size. /// - API_PROPERTY() void SetFontSize(int32 value); + API_PROPERTY() void SetFontSize(float value); /// /// The draw passes to use for rendering this object.