Fix text written below cursor bug 39/268839/3
authorabdullah <abdullahhasan10@gmail.com>
Mon, 3 Jan 2022 14:20:42 +0000 (16:20 +0200)
committerabdullah <abdullahhasan10@gmail.com>
Thu, 6 Jan 2022 14:45:06 +0000 (16:45 +0200)
commit297612cc09fbe560a454742a52bfb3ed03a2655f
tree75fa93817bd751c8e9c364f4bebd7a6fe623813d
parent980728a7e35b8ddd28f70c090243e8076e21536e
Fix text written below cursor bug

***********************************************************
Description:

When we use different font sizes with min line size, text in the new line gets written below the cursor position.

Please use the code below to generate the issue.
***********************************************************

using namespace Dali;
using namespace Dali::Toolkit;

class SimpleApp : public ConnectionTracker
{
public:
  SimpleApp(Application &application)
      : mApplication(application)
  {
    mApplication.InitSignal().Connect(this, &SimpleApp::Create);
  }

  void Create(Application &application)
  {
    Window window = application.GetWindow();
    window.SetBackgroundColor(Vector4(0.04f, 0.345f, 0.392f, 1.0f));

    mEditor = TextEditor::New();
    mEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
    mEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
    mEditor.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    mEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
    mEditor.SetProperty( TextField::Property::TEXT, "H<span font-size='45' font-family='DejaVu Sans' font-width='condensed' font-slant='italic' text-color='red'>ello</span> Span\n <span font-size='50' text-color='red'>S</span> \n" );//issue here with the y position after the new line
    mEditor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
    mEditor.SetProperty(TextEditor::Property::POINT_SIZE, 15.0f);
    mEditor.SetBackgroundColor(Color::WHITE);
    mEditor.SetProperty(DevelTextEditor::Property::MIN_LINE_SIZE, 50.f);

    window.Add(mEditor);
  }

  bool OnButtonClicked(Button button)
  {
    if (button == mButton)
    {
      Vector3 originalSize = mEditor.GetNaturalSize();
    }
    return true;
  }

private:
  Application &mApplication;
  TextEditor mEditor;
  PushButton mButton;
  TextField mField;
};

int DALI_EXPORT_API main(int argc, char **argv)
{
  Application application = Application::New(&argc, &argv);
  SimpleApp test(application);
  application.MainLoop();

  return 0;
}

***********************************************************

Change-Id: I2868f923e38d9ecc14bf738959f24be015b754fd
automated-tests/src/dali-toolkit-internal/utc-Dali-TextEditor-internal.cpp [changed mode: 0755->0644]
dali-toolkit/internal/text/text-view.cpp