Skip to content

Commit

Permalink
Label rendering- fix text not rendered without a scaling factor
Browse files Browse the repository at this point in the history
Fix faulty logic when updating the text which caused text to be measure
only but not rendered when game was configured without a scaling factor
for the text.
  • Loading branch information
tzachshabtay committed Feb 13, 2018
1 parent 735065a commit d6e188c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/Engine/AGS.Engine/UI/Text/GLLabelRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ private void updateBoundingBoxes(IObject obj, IDrawableInfoComponent drawable, I
_shouldUpdateBoundingBoxes = false;
if (autoFit == AutoFit.LabelShouldFitText)
{
updateText(_glTextHitTest, resolutionMatches, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue);
updateText(_glTextHitTest, false, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue);
if (!resolutionMatches) updateText(_glTextRender, true, GLText.EmptySize, scaleUpText, scaleDownText, int.MaxValue);
CustomImageSize = new SizeF(_glTextHitTest.Width, _glTextHitTest.Height);
}
else if (autoFit == AutoFit.TextShouldWrapAndLabelShouldFitHeight)
{
updateText(_glTextHitTest, resolutionMatches, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width);
updateText(_glTextHitTest, false, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width);
if (!resolutionMatches) updateText(_glTextRender, true, new SizeF(BaseSize.Width, GLText.EmptySize.Height), scaleUpText, scaleDownText, (int)BaseSize.Width);
CustomImageSize = new SizeF(BaseSize.Width, _glTextHitTest.Height);
}
Expand Down Expand Up @@ -335,7 +335,7 @@ private void updateBoundingBoxes(GLText glText, AutoFit autoFit, IGLMatrices tex
{
case AutoFit.NoFitting:
build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox);
updateText(glText, buildRenderBox, BaseSize, textScaleUp, textScaleDown, int.MaxValue);
updateText(glText, !buildHitTestBox, BaseSize, textScaleUp, textScaleDown, int.MaxValue);
build(_textBoundingBoxes, glText.BitmapWidth, glText.BitmapHeight, textMatrices, buildRenderBox, buildHitTestBox);

_usedLabelBoundingBoxes = _labelBoundingBoxes;
Expand All @@ -352,7 +352,7 @@ private void updateBoundingBoxes(GLText glText, AutoFit autoFit, IGLMatrices tex

case AutoFit.TextShouldFitLabel:
build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox);
updateText(glText, buildRenderBox, glText.Width > BaseSize.Width ? new SizeF(0f, BaseSize.Height) : BaseSize, textScaleUp, textScaleDown, int.MaxValue);
updateText(glText, !buildHitTestBox, glText.Width > BaseSize.Width ? new SizeF(0f, BaseSize.Height) : BaseSize, textScaleUp, textScaleDown, int.MaxValue);

float textWidth = glText.Width < BaseSize.Width ? glText.BitmapWidth : MathUtils.Lerp(0f, 0f, glText.Width, BaseSize.Width, glText.BitmapWidth);
float textHeight = glText.Height < BaseSize.Height ? glText.BitmapHeight : MathUtils.Lerp(0f, 0f, glText.Height, BaseSize.Height, glText.BitmapHeight);
Expand All @@ -373,7 +373,7 @@ private void updateBoundingBoxes(GLText glText, AutoFit autoFit, IGLMatrices tex

case AutoFit.TextShouldCrop:
build(_labelBoundingBoxes, BaseSize.Width / labelResolutionFactor.X, BaseSize.Height / labelResolutionFactor.Y, labelMatrices, buildRenderBox, buildHitTestBox);
updateText(glText, buildRenderBox, glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), textScaleUp, textScaleDown, (int)BaseSize.Width, true);
updateText(glText, !buildHitTestBox, glText.Width > BaseSize.Width ? GLText.EmptySize : new SizeF(BaseSize.Width, GLText.EmptySize.Height), textScaleUp, textScaleDown, (int)BaseSize.Width, true);

float heightOfText = glText.Height < BaseSize.Height ? glText.BitmapHeight : MathUtils.Lerp(0f, 0f, glText.Height, BaseSize.Height, glText.BitmapHeight);

Expand Down

0 comments on commit d6e188c

Please sign in to comment.