Author Topic: Text styling questions  (Read 12913 times)

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Text styling questions
« on: October 09, 2017, 01:22:04 AM »

I'm hoping someone can help me with a, hopefully, pretty simple newbie question.

I have the following string that I want to be able to style in two different colours:

Code: [Select]
local details = fe.add_text("[Title] - Plays: [PlayedCount]", flx*0.235, fly*0.02, flw*0.300, flh*0.500 );
For example, I want the title to be white but the play count to be blue. But I have to have the two grouped together so that the play count always follows on directly from the title - I don't them to be positioned independently.

Also, how can I make this string uppercase? I have tried using toupper, as below, but it doesn't work.

Code: [Select]
details.toupper();
thanks in advance for any help.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #1 on: October 09, 2017, 03:42:19 AM »
A string is "A string". You must separate your parts to style them differently.

details.toupper() is not a declaration. Assign the result to your details variable as such: details = details.toupper();

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Text styling questions
« Reply #2 on: October 09, 2017, 05:31:54 AM »
OK. So, to get my desired effect - of having the Title and Play Count coloured individually, but placed within / positioned with the same text object - presumably I need to define and colour each individually and then call them together within a text object? (as you can tell, I'm no programmer and so very likely not using the correct terms here).
If so, how would I go about doing this?

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Text styling questions
« Reply #3 on: October 09, 2017, 07:28:14 AM »
I think the "easy way" to get uppercase text is set an "only uppercase" font on your layout  :)

Code: [Select]
fe.layout.font="New Athletic M54";
To get different text styles make something like this:

Code: [Select]
local tittletext = fe.add_text("[Title] , flx*0.235, fly*0.02, flw*0.300, flh*0.500 );
tittletext.charsize = 16;
tittletext.align = Align.Left;
tittletext.word_wrap = true;
tittletext.alpha = 255;
//tittletext.style = Style.Bold;

And then just change this part:

Code: [Select]
local tittletext = fe.add_text("[Title]
Code: [Select]
local manufacturertext = fe.add_text("[Manufacturer]
Download my theme here , you will see a bunch of text examples.

http://forum.attractmode.org/index.php?topic=1558.0

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Text styling questions
« Reply #4 on: October 10, 2017, 01:29:30 AM »
Thanks for the responses.
So, it pretty much looks like I can't easily get the effect/layout I'm after and will have to compromise with text all the same colour and not uppercase.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #5 on: October 10, 2017, 03:38:35 AM »
Thanks for the responses.
So, it pretty much looks like I can't easily get the effect/layout I'm after and will have to compromise with text all the same colour and not uppercase.

Make them two different objects like I said. If your worried about positioning with different aspect ratios, you could always duplicate the object with complete text, change text to the second text, and change color. This would only work with justify left or right, not center. Hopefully overlaying the object doesn't show artifacts.

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Text styling questions
« Reply #6 on: October 10, 2017, 04:31:11 AM »
That wouldn't achieve the alignment I'm after - I want the two to flow together in one text object. Example below.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #7 on: October 10, 2017, 05:26:47 AM »
That wouldn't achieve the alignment I'm after - I want the two to flow together in one text object. Example below.

Yes. Same result in two objects.

Create object with "the simpsons plays 13".
Style it blue.
Create object with "the simpsons" and same positioning as previous object.
Style it green.

Let me know how it looks.

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Text styling questions
« Reply #8 on: October 10, 2017, 06:08:16 AM »
Ah, I get you now. Yeah, that sounds like it'd work fine. I'll give it a try this evening and will let you know how it turned out.
Thanks!

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Text styling questions
« Reply #9 on: October 10, 2017, 06:59:15 AM »
here you are...




Code: [Select]
//game title1
local l = fe.add_text("[Title]   players:  [Players]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );
l.charsize = 47;
l.alpha = 255;
l.font="mad";
l.set_rgb( 66, 206, 244 );
l.align = Align.Left;
l.rotation = ( 90 );

//game title2
local l = fe.add_text("[Title]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );
l.charsize = 47;
l.alpha = 255;
l.font="mad";
l.set_rgb( 255, 0, 0 );
l.align = Align.Left;
l.rotation = ( 90 );
help a friend....

jdye82

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Text styling questions
« Reply #10 on: October 11, 2017, 01:11:23 AM »
Got the colours working now. Thanks all for the advice.
Now searching for a decent replacement font that's all caps. If only I could get .toupper could work!

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #11 on: October 11, 2017, 03:24:36 AM »
Got the colours working now. Thanks all for the advice.
Now searching for a decent replacement font that's all caps. If only I could get .toupper could work!

http://www.squirrel-lang.org/squirreldoc/reference/language/builtin_functions.html#string.toupper

string.toupper()
returns a uppercase copy of the string.

It works. Make sure you reasign string if you want to change it. Example: string = string.toupper();

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Text styling questions
« Reply #12 on: October 11, 2017, 06:35:21 AM »
here is all i can see of the use on the site

http://forum.attractmode.org/index.php?topic=636.msg4503#msg4503

with a working example that you made ,, but i cant get it to show anything.

i know your bizzy dude, but could you please make a working example from this..
Code: [Select]
local l = fe.add_text("[Title]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );
it,s pretty obvious that this is a bit over our heads...,, then we could all learn something from you.
thanks.

update to reply,,,thanks brother u rock...


« Last Edit: October 11, 2017, 07:15:22 AM by jedione »
help a friend....

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #13 on: October 11, 2017, 07:03:46 AM »
here is all i can see of the use on the site

http://forum.attractmode.org/index.php?topic=636.msg4503#msg4503

with a working example that you made ,, but i cant get it to show anything.

i know your bizzy dude, but could you please make a working example from this..
Code: [Select]
local l = fe.add_text("[Title]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );
it,s pretty obvious that this is a bit over our heads...,, then we could all learn something from you.
thanks.

Will do when out of work tonight. Super simple. No worries.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Text styling questions
« Reply #14 on: October 11, 2017, 03:52:50 PM »
here is all i can see of the use on the site

http://forum.attractmode.org/index.php?topic=636.msg4503#msg4503

with a working example that you made ,, but i cant get it to show anything.

i know your bizzy dude, but could you please make a working example from this..
Code: [Select]
local l = fe.add_text("[Title]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );
it,s pretty obvious that this is a bit over our heads...,, then we could all learn something from you.
thanks.

update to reply,,,thanks brother u rock...

Try this:

Code: [Select]
function title(){
  local text = fe.game_info(Info.Title);
  return text.toupper();
}
local title = fe.add_text(„[!title]", flx*0.185, fly*0.080, flw*0.300, flh*0.500 );