0 votes

I have a little scene which consists of Control - ColorRect - Label, RichTextLabel, AnimationPlayer(for beautiful output (modulate of container from zero tp default in 1 second) ) I read from file to set RichTextLabel.BbcodeText , because i need something to be centered , right alighned or justified. [center]{text}[/center] and [right]{text}[/right] work perfectly but there is no such teg as "justify" in godot. From godot docs i considered [fill] works similar to justify. But i have unexpected output: it is same as if i dint put [fill] teg and keep it left alighned. It's not what i want

Here is my code

using Godot;
using System;

public class ReadFileScene : Control
{

    public override void _Ready()
    {
        Label title = this.GetNode<Label>("background/container/title");
        RichTextLabel disclaimer = this.GetNode<RichTextLabel>("background/container/main");
        AnimationPlayer fadeIn = this.GetNode<AnimationPlayer>("background/container/fadeIn");

        disclaimer.BbcodeEnabled = true;
        disclaimer.BbcodeText = setText();
        fadeIn.Play("FadeIn");
    }

    private string setText()
    {
        string text = $"{System.Environment.NewLine}";
        string line;
        string[] tags = new string[5]{"center", "right", "fill", "center", "fill"};
        int tagsIndex = 0;

        Godot.File file = new File();

        file.Open("res://readMe.txt", File.ModeFlags.Read);
        while (file.EofReached() == false)
        {
            line = file.GetLine();

            if (tags[tagsIndex] == "center")
            {
                text += $"[center]{line}[/center]{System.Environment.NewLine}";
            }
            else if (tags[tagsIndex] == "right")
            {
                text  += $"[right]{line}[/right]{System.Environment.NewLine}";
            }
            else
            {
                text += $"{line}{System.Environment.NewLine}";
            }

            if (String.IsNullOrEmpty(line))
            {
                tagsIndex++;
            }

        }
        file.Close();
        return text;
    }
}

I want it to be like this. IT IS JUSTIFIED IT IS JUSTIFIED

in Engine by (34 points)

[fill]text[/fill] is the correct tag for justified text. However, form skimming over your code it looks like you never actually add the fill-tag?! Also note that the fill-tag is currently broken in 3.2.2, but has already been fixed and cherrypicked for 3.2.3, so if you run the nightly (or an older version) it should work.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.