axmol icon indicating copy to clipboard operation
axmol copied to clipboard

FairyGUI problems with text update

Open paulocoutinhox opened this issue 9 months ago • 5 comments

  • axmol version: d6781284a5b2d9b21d3f98334a93a37cb49f55e3
  • devices test on: all
  • developing environments
    • NDK version: r23c
    • Xcode version: 14.2+
    • Visual Studio:
      • VS version: 2022 (17.9+)
      • MSVC version: 19.39+
      • Windows SDK version: 10.0.22621.0+
    • cmake version: 3.28.1 Steps to Reproduce:
  1. Create a FairGUI GTextField element with any custom font and a simple text, example "test"
  2. Change the text of GTextField in runtime with characters that is not in original text, example "text"

BEFORE CHANGE TEXT

image

AFTER CHANGE TEXT

image

The letter "x" that is not in design mode don't appear when new text have it.

Code:

auto lbMessage = dynamic_cast<fairygui::GTextField *>(getContentPane()->getChild("lbMessage"));
lbMessage->setText("text");

What is wrong?

paulocoutinhox avatar May 01 '24 08:05 paulocoutinhox

What is wrong?

Have you followed it with a debugger to narrow down where the issue is occurring?

rh101 avatar May 01 '24 08:05 rh101

Sure. Im try debug but i don't understand why it is cutting the chars that is not in the original text. I read all the source code, step by step with debug, but don't make sense to me.

paulocoutinhox avatar May 01 '24 08:05 paulocoutinhox

The steps is:

void GBasicTextField::setTextFieldText()
{
    if (_templateVars != nullptr)
        _label->setText(parseTemplate(_text.c_str()));
    else
        _label->setText(_text);
}

That call FUILabel.cpp setText:

void FUILabel::setText(std::string_view value)
{
    if (_fontSize < 0)
        applyTextFormat();

    setString(value);
}

That call core/2d/Label.cpp method setString:

void Label::setString(std::string_view text)
{
    if (text.compare(_utf8Text))
    {
        _utf8Text     = text;
        _contentDirty = true;

        std::u32string utf32String;
        if (StringUtils::UTF8ToUTF32(_utf8Text, utf32String))
        {
            _utf32Text = utf32String;
        }
    }
}

And when i changed the text, it set the new string, "text" in my sample, without problems:

image

Don't appear be nothing specific with FairyGUI, since it use Axmol Label.

paulocoutinhox avatar May 01 '24 18:05 paulocoutinhox

And the TTFConfig of Axmol label is this:

image

The font is ok, it generate the first text of label without problems.

The problems happen when i change the label string/text.

paulocoutinhox avatar May 01 '24 18:05 paulocoutinhox

Don't appear be nothing specific with FairyGUI, since it use Axmol Label.

Have you tested the same font with an ax::Label to see if it has the same issue? If it does not have an issue, then you should compare the behaviour of a standard ax::Label with that of the one used by FairyGUI. Follow it in the debugger to the construction of the texture from the text itself, and you should be able to spot the difference.

rh101 avatar May 02 '24 04:05 rh101

Hi, sure. Is this I'm doing, but without success. I'm debugging but do not discover the problem.

paulocoutinhox avatar May 02 '24 12:05 paulocoutinhox

Hi,

I think that there is wrong in my current project, because i create another sample with FairyGUI and axmol Label, and both works fine :(

https://github.com/paulocoutinhox/fairygui-bug

paulocoutinhox avatar May 03 '24 00:05 paulocoutinhox

In test project it works on both devices.

In my real project it have problems on Android only:

Screenshot_20240503_021149

paulocoutinhox avatar May 03 '24 05:05 paulocoutinhox

I solve the problems settings correct resolution in design resolution and the text problems is related to threads, because i call JNI somethings and it don't render when come from JNI call (i dont know why, but i call on callback the method runInAxmolThread). Thanks.

paulocoutinhox avatar May 03 '24 07:05 paulocoutinhox