mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix crash when Text object font is set to 0
This commit is contained in:
@@ -274,7 +274,7 @@ bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb,
|
||||
} else if (propertyNb == 1) {
|
||||
ChangeFont(newValue);
|
||||
} else if (propertyNb == 2) {
|
||||
SetCharacterSize(newValue.To<int>());
|
||||
SetCharacterSize(std::max(1, newValue.To<int>()));
|
||||
} else if (propertyNb == 3) {
|
||||
gd::String r, gb, g, b;
|
||||
{
|
||||
@@ -297,7 +297,7 @@ bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb,
|
||||
|
||||
SetColor(r.To<int>(), g.To<int>(), b.To<int>());
|
||||
} else if (propertyNb == 4) {
|
||||
SetOpacity(newValue.To<float>());
|
||||
SetOpacity(std::min(std::max(0.0f, newValue.To<float>()), 255.0f));
|
||||
} else if (propertyNb == 5) {
|
||||
SetSmooth(!(newValue == _("No")));
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ gdjs.TextRuntimeObject = function(runtimeScene, objectData)
|
||||
{
|
||||
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
|
||||
|
||||
this._characterSize = objectData.characterSize;
|
||||
this._characterSize = Math.max(1, objectData.characterSize);
|
||||
this._fontName = objectData.font;
|
||||
this._bold = objectData.bold;
|
||||
this._italic = objectData.italic;
|
||||
|
@@ -87,7 +87,7 @@ RenderedTextInstance.prototype.update = function() {
|
||||
|
||||
if (this._styleFontDirty) {
|
||||
this._pixiObject.style.fontFamily = this._fontFamily || 'Arial';
|
||||
this._pixiObject.style.fontSize = this._characterSize + 'px';
|
||||
this._pixiObject.style.fontSize = Math.max(1, this._characterSize) + 'px';
|
||||
this._pixiObject.style.fontStyle = this._isItalic ? 'italic' : 'normal';
|
||||
this._pixiObject.style.fontWeight = this._isBold ? 'bold' : 'normal';
|
||||
this._pixiObject.style.wordWrap = this._wrapping;
|
||||
|
Reference in New Issue
Block a user