Label line right to left

Anything libgdx related goes here!

Label line right to left

Postby xpdt » Sun Sep 15, 2019 11:47 am

Hi
There is some "\n" in my text used in Label:
Code: Select all
Label("Hi\nMy name in Jone.\nI'm from USA.", new Label.LabelStyle(Asset.asset.font24, Color.BLACK));

The text show in 3 line without problem.
But my language is right to left And lines must be made from right to left like this:
Code: Select all
I'm from USA.
My name in Jone.
Hi

Are there any properties for this or I have to do it manually?
xpdt
 
Posts: 82
Joined: Mon Jul 04, 2016 2:29 am

Re: Label line right to left

Postby evilentity » Sun Sep 15, 2019 12:05 pm

Perhaps setting the label alignement to right will help.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am

Re: Label line right to left

Postby xpdt » Sun Sep 15, 2019 12:17 pm

evilentity wrote:Perhaps setting the label alignement to right will help.

Does not work.
xpdt
 
Posts: 82
Joined: Mon Jul 04, 2016 2:29 am

Re: Label line right to left

Postby raeleus » Sun Sep 15, 2019 12:49 pm

Use label.setAlignment(Align.right)

Don't confuse that with table.add(label).right()
Join us on Discord for faster and friendlier service.
Create skins visually with Skin Composer.
JOIN THE libGDX Jam of October 2019!
raeleus
 
Posts: 474
Joined: Wed Aug 07, 2013 10:57 pm

Re: Label line right to left

Postby xpdt » Sun Sep 15, 2019 5:34 pm

raeleus wrote:Use label.setAlignment(Align.right)

Don't confuse that with table.add(label).right()

Does not work. Probably not related to this.
xpdt
 
Posts: 82
Joined: Mon Jul 04, 2016 2:29 am

Re: Label line right to left

Postby raeleus » Sun Sep 15, 2019 5:37 pm

Draw us a picture of exactly what you want then. It's not clear from what you posted.
Join us on Discord for faster and friendlier service.
Create skins visually with Skin Composer.
JOIN THE libGDX Jam of October 2019!
raeleus
 
Posts: 474
Joined: Wed Aug 07, 2013 10:57 pm

Re: Label line right to left

Postby captainflyaway » Sun Sep 15, 2019 8:29 pm

I think he is talking about the actual reading direction of his language.

He wants to mirror the whole text so the characters (not english ones) go from right to left. Like a "d" should be a "b" in his language.
captainflyaway
 
Posts: 237
Joined: Mon Feb 20, 2017 7:52 am

Re: Label line right to left

Postby evilentity » Sun Sep 15, 2019 10:01 pm

Align works as expected.
Code: Select all
{
   VisLabel label = new VisLabel("Hello\naligned\nworld!");
   label.setAlignment(Align.left);
   root.add(label).pad(16).row();
}
{
   VisLabel label = new VisLabel("Hello\naligned\nworld!");
   label.setAlignment(Align.center);
   root.add(label).pad(16).row();
}
{
   VisLabel label = new VisLabel("Hello\naligned\nworld!");
   label.setAlignment(Align.right);
   root.add(label).pad(16).row();
}

Image

If you want actual right to left script, like arabic or something, thats not supported. There was a pr for that long time ago, but seems dead.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am

Re: Label line right to left

Postby xpdt » Mon Sep 16, 2019 9:04 am

thanks for the reply
Sorry, I think I didn't ask the question correctly.
There are several sentences in the text:
"Sentence1\nSentence2\nSentence3"
The default output is:
Sentence1
Sentence2
Sentence3

I need:
Sentence3
Sentence2
Sentence1

Because my language is right-to-left, so the first sentence is on the right. Of course, sentences can be easily reversed If not predicted at LibGDX.
xpdt
 
Posts: 82
Joined: Mon Jul 04, 2016 2:29 am

Re: Label line right to left

Postby captainflyaway » Mon Sep 16, 2019 1:01 pm

You want to inverse the order from top to bottom.

You just split the string at the newline and add it up from behind
captainflyaway
 
Posts: 237
Joined: Mon Feb 20, 2017 7:52 am


Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest