Support decimal values in Font sizes
This commit is contained in:
@@ -304,6 +304,6 @@ void SplashScreen::OnFontLoaded(Asset* asset)
|
|||||||
|
|
||||||
// Create fonts
|
// Create fonts
|
||||||
const float s = _dpiScale;
|
const float s = _dpiScale;
|
||||||
_titleFont = font->CreateFont((uint32)(35 * s));
|
_titleFont = font->CreateFont(35 * s);
|
||||||
_subtitleFont = font->CreateFont((uint32)(9 * s));
|
_subtitleFont = font->CreateFont(9 * s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
#include "IncludeFreeType.h"
|
#include "IncludeFreeType.h"
|
||||||
|
|
||||||
Font::Font(FontAsset* parentAsset, int32 size)
|
Font::Font(FontAsset* parentAsset, float size)
|
||||||
: ManagedScriptingObject(SpawnParams(Guid::New(), Font::TypeInitializer))
|
: ManagedScriptingObject(SpawnParams(Guid::New(), Font::TypeInitializer))
|
||||||
, _asset(parentAsset)
|
, _asset(parentAsset)
|
||||||
, _size(size)
|
, _size(size)
|
||||||
@@ -436,7 +436,7 @@ void Font::FlushFaceSize() const
|
|||||||
{
|
{
|
||||||
// Set the character size
|
// Set the character size
|
||||||
const FT_Face face = _asset->GetFTFace();
|
const FT_Face face = _asset->GetFTFace();
|
||||||
const FT_Error error = FT_Set_Char_Size(face, 0, ConvertPixelTo26Dot6<FT_F26Dot6>((float)_size * FontManager::FontScale), DefaultDPI, DefaultDPI);
|
const FT_Error error = FT_Set_Char_Size(face, 0, ConvertPixelTo26Dot6<FT_F26Dot6>(_size * FontManager::FontScale), DefaultDPI, DefaultDPI);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
LOG_FT_ERROR(error);
|
LOG_FT_ERROR(error);
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Font);
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
FontAsset* _asset;
|
FontAsset* _asset;
|
||||||
int32 _size;
|
float _size;
|
||||||
int32 _height;
|
int32 _height;
|
||||||
int32 _ascender;
|
int32 _ascender;
|
||||||
int32 _descender;
|
int32 _descender;
|
||||||
@@ -244,7 +244,7 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parentAsset">The parent asset.</param>
|
/// <param name="parentAsset">The parent asset.</param>
|
||||||
/// <param name="size">The size.</param>
|
/// <param name="size">The size.</param>
|
||||||
Font(FontAsset* parentAsset, int32 size);
|
Font(FontAsset* parentAsset, float size);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finalizes an instance of the <see cref="Font"/> class.
|
/// Finalizes an instance of the <see cref="Font"/> class.
|
||||||
@@ -264,7 +264,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets font size.
|
/// Gets font size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_PROPERTY() FORCE_INLINE int32 GetSize() const
|
API_PROPERTY() FORCE_INLINE float GetSize() const
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void FontAsset::SetOptions(const FontOptions& value)
|
|||||||
_options = value;
|
_options = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Font* FontAsset::CreateFont(int32 size)
|
Font* FontAsset::CreateFont(float size)
|
||||||
{
|
{
|
||||||
PROFILE_CPU();
|
PROFILE_CPU();
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="size">The font characters size.</param>
|
/// <param name="size">The font characters size.</param>
|
||||||
/// <returns>The created font object.</returns>
|
/// <returns>The created font object.</returns>
|
||||||
API_FUNCTION() Font* CreateFont(int32 size);
|
API_FUNCTION() Font* CreateFont(float size);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the font with bold style. Returns itself or creates a new virtual font asset using this font but with bold option enabled.
|
/// Gets the font with bold style. Returns itself or creates a new virtual font asset using this font but with bold option enabled.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace FlaxEngine
|
|||||||
private FontAsset _font;
|
private FontAsset _font;
|
||||||
|
|
||||||
[NoSerialize]
|
[NoSerialize]
|
||||||
private int _size;
|
private float _size;
|
||||||
|
|
||||||
[NoSerialize]
|
[NoSerialize]
|
||||||
private Font _cachedFont;
|
private Font _cachedFont;
|
||||||
@@ -33,7 +33,7 @@ namespace FlaxEngine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="font">The font.</param>
|
/// <param name="font">The font.</param>
|
||||||
/// <param name="size">The font size.</param>
|
/// <param name="size">The font size.</param>
|
||||||
public FontReference(FontAsset font, int size)
|
public FontReference(FontAsset font, float size)
|
||||||
{
|
{
|
||||||
_font = font;
|
_font = font;
|
||||||
_size = size;
|
_size = size;
|
||||||
@@ -91,7 +91,7 @@ namespace FlaxEngine
|
|||||||
/// The size of the font characters.
|
/// The size of the font characters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EditorOrder(10), Limit(1, 500, 0.1f), Tooltip("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;
|
get => _size;
|
||||||
set
|
set
|
||||||
@@ -187,7 +187,7 @@ namespace FlaxEngine
|
|||||||
unchecked
|
unchecked
|
||||||
{
|
{
|
||||||
int hashCode = _font ? _font.GetHashCode() : 0;
|
int hashCode = _font ? _font.GetHashCode() : 0;
|
||||||
hashCode = (hashCode * 397) ^ _size;
|
hashCode = (hashCode * 397) ^ _size.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,14 +73,14 @@ void TextRender::SetColor(const Color& value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 TextRender::GetFontSize() const
|
float TextRender::GetFontSize() const
|
||||||
{
|
{
|
||||||
return _size;
|
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)
|
if (_size != value)
|
||||||
{
|
{
|
||||||
_size = value;
|
_size = value;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ private:
|
|||||||
LocalizedString _text;
|
LocalizedString _text;
|
||||||
Color _color;
|
Color _color;
|
||||||
TextLayoutOptions _layoutOptions;
|
TextLayoutOptions _layoutOptions;
|
||||||
int32 _size;
|
float _size;
|
||||||
int32 _sceneRenderingKey = -1;
|
int32 _sceneRenderingKey = -1;
|
||||||
|
|
||||||
BoundingBox _localBox;
|
BoundingBox _localBox;
|
||||||
@@ -91,12 +91,12 @@ public:
|
|||||||
/// Gets the font characters size.
|
/// Gets the font characters size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(32), Limit(1, 1000), EditorDisplay(\"Text\")")
|
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(32), Limit(1, 1000), EditorDisplay(\"Text\")")
|
||||||
int32 GetFontSize() const;
|
float GetFontSize() const;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the font characters size.
|
/// Sets the font characters size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_PROPERTY() void SetFontSize(int32 value);
|
API_PROPERTY() void SetFontSize(float value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The draw passes to use for rendering this object.
|
/// The draw passes to use for rendering this object.
|
||||||
|
|||||||
Reference in New Issue
Block a user