Nez icon indicating copy to clipboard operation
Nez copied to clipboard

`FontScaleX` for default skin set to zero in `TextButton`

Open etiket-io opened this issue 3 years ago • 5 comments

The Issue TextButton does not show any text under default skin/style settings, although Label is visible.

Minimal Example:

using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Nez;
using Nez.UI;


namespace MyGame
{
    public class TitleScene : Scene
    {
        public UICanvas Canvas;

        Table _table;

        public TitleScene()
        { }


        public override void Initialize()
        {
            base.Initialize();

            // Using PixelPerfor
            SetDesignResolution(512, 256, SceneResolutionPolicy.NoPolicy);
            Screen.SetSize(512, 256;

            // add a UI render layer
            Canvas = CreateEntity("ui").AddComponent(new UICanvas());
            var skin = Skin.CreateDefaultSkin();
            _table = Canvas.Stage.AddElement(new Table());
            _table.SetFillParent(true).Center().Top();
            _table.Row();
            // `Label`s work
            _table.Add(new Label("Some Buttons", new LabelStyle())).SetFillX().SetMinHeight(30);
            _table.Row();
            var battleButton = new TextButton("A button", skin);
            // commenting this out causes no text to appear on the buttons 
            // battleButton.GetStyle().FontScaleX = 1.0f;
            _table.Add(new TextButton("Another button", skin)).SetFillX().SetMinHeight(30)
            _table.Row().SetPadTop(10);
            var exitButton = _table.Add(new TextButton("Exit", skin)).SetFillX().SetMinHeight(30).GetElement<TextButton>();
        }
    }
}

etiket-io avatar Aug 11 '21 00:08 etiket-io

In the current Master-branch NoPolicy seems to no longer exists, so after changing it to None it looks like this for me: (Which seems fine to me) image

Uncommenting the FontScaleX-Line does not work for me, FontScaleX seems to also no longer exists.

image

So, this issue may vanished together with FontScale. If you still experience this issue with the master branch, could you provide a new example? Since I am unable to reproduce the problem with this example.

Tobi-Mob avatar Oct 15 '21 08:10 Tobi-Mob

Just works on my Linux Mint 20.

But issue occurred on OS Name: Microsoft Windows 7 Enterprise OS Version: 6.1.7601 Service Pack 1 Build 7601 running as VM in VMWare Workstation 16.1 with GPU passing

TextButton().GetLabel().SetFontScale(2) fixed the issue

Tobi-Mob avatar Oct 17 '21 19:10 Tobi-Mob

https://github.com/prime31/Nez/blob/master/Nez.Portable/UI/Widgets/TextButton.cs#L124 should be: public float FontScaleX = 1; public float FontScaleY = 1;

ilmenit avatar Oct 17 '21 19:10 ilmenit

The problem only occurres in the master branch, not in the version used by the Samples Repository

image

https://github.com/prime31/Nez/tree/7a87b151a831b60cf0f95e942084c285d3effb21 Introduced with commit: https://github.com/prime31/Nez/commit/22b35ba33926fa34eeda4ff875d6054b19b314a7

Tobi-Mob avatar Oct 17 '21 20:10 Tobi-Mob

should be fixed: #696

Tobi-Mob avatar Oct 18 '21 12:10 Tobi-Mob