Android Question CSBuilder: can we have different text sizes in one label?

bsnqt

Active Member
Licensed User
Longtime User
I tried to write text on a label with different text sizes but unluckily did not get it done for a whole day...it is strange.

B4X:
Dim cs As CSBuilder
cs.Initialize.Size(24).TypeFace(Typeface.FONTAWESOME).Append("(Chr(0xF028)" & CRLF).Pop.Pop
cs.Size(12).Typeface(Typeface.DEFAULT).Append("This is a test").PopAll

Label1.Text = cs

It always gives me: both of texts are 12 (small), or both of them are size 24 (big). Tried another one:

B4X:
Dim cs As CSBuilder
cs.Initialize.Size(24).TypeFace(Typeface.FONTAWESOME).Append("(Chr(0xF028)" & CRLF)
cs.Size(12).Typeface(Typeface.DEFAULT).Append("This is a test").Pop.Pop

Label1.Text = cs

This one is not workable as well...


B4X:
Dim cs As CSBuilder
cs.Initialize.TypeFace(Typeface.FONTAWESOME).Size(24).Append("(Chr(0xF028)" & CRLF).Pop.Pop
cs.Typeface(Typeface.CreateNew(Typeface.SANS_SERIF, Typeface.STYLE_NORMAL)).Size(12).Append("This is a test").PopAll

Label1.Text = cs

I tried to change the syntax many ways as I understand my syntax is wrong, but could not fix it. Please help.
 
Last edited:
Solution
test:

1633151608399.png

TILogistic

Expert
Licensed User
Longtime User
?
B4X:
    Dim cs As CSBuilder
    cs.Initialize
    cs.Size(14)
    cs.Append("Text with FontAwesome: ")
    cs.Append(CRLF)
    cs.Size(62)
    cs.Typeface(Typeface.FONTAWESOME)
    cs.Append(Chr(0xF209)).PopAll
    Label1.Text = cs

1633148976160.png
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
Other:

Colors and Align

B4X:
    Dim cs As CSBuilder
    cs.Initialize
    cs.Size(64)
    cs.Alignment("ALIGN_CENTER")
    cs.Color(Colors.Blue)
    cs.TypeFace(Typeface.FONTAWESOME)
    cs.Append(Chr(0xF028))
    cs.Append(CRLF)
    cs.Size(14)
    cs.Color(Colors.Green)
    cs.Append("This is a test CSBuilder")
    cs.PopAll

    Label1.Text = cs

1633149758744.png
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi oparra,

The solution is your post #3 and #4. The sample project runs well.
But the code in post #2 is giving me the same result as mine (was before). I am trying to figure out what is the reason/difference.
Thank you so much, your code is simple but very effective :D (I always make myself too complicated and ineffective šŸ˜­)
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi oparra,

Now I understand why I could not make it run well before...after trying your test and analyzing my code (which was before your post).
My mistake was I am simply stupid and I post here for someone who may face the same like mine.

I change the size of fontawsome in your code to 24 (instead of 64):

B4X:
    Dim cs As CSBuilder
    cs.Initialize
    cs.Size(22)
    cs.Alignment("ALIGN_CENTER")
    cs.Color(Colors.White)
    cs.TypeFace(Typeface.FONTAWESOME)
    cs.Append(Chr(0xF028))
    cs.Append(CRLF)
    cs.TypeFace(Typeface.DEFAULT)
    cs.Size(14)
    cs.Color(Colors.White)
    cs.Append("This is a test CSBuilder")
    cs.PopAll

    UKspeaker.Text = cs

And suddenly I see the fontawsome text again becomes as small as other text ("This is a test CSBuilder"). :rolleyes:
But soon I found out that the issue is with FONTAWSOME the size 22 is too small for us to see the text size diffenrence, and why I can wrongly see that both are same size. If now I increase Fontawsome text to 30 or bigger, I can see the diffence.
So stupid I am ...
Once again thanks.
 
Upvote 0
Top