B4J Question FontAwesome and CSS

ThRuST

Well-Known Member
Licensed User
Longtime User
Is it possible to use FontAwesome in a button when CSS is active? Somehow I only get strange characters instead of correct symbols. I have followed the tutorial to set FontAwesome and copied the symbol from clipboard that is visible in FontAwesome Icons, but it's still not showing in the button. I use B4j v601.
 

Cableguy

Expert
Licensed User
Longtime User
If you are using the designer, you also have to choose the correct font in the font list, not just pick the "icon" you want.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Hello Cableguy I did enable the font. Also tried LemonIsDeads solution but the button still looks like this, meaning the CSS script overrides the code. It might work to call the button something else in the CSS script and apply the custom settings. That's the only reasonable solution I can find, if that will work. Btw it's not supposed to show that symbol, right? :)


FAButton.JPG
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
How would you use a custom name for the button and have it recognized in the CSS script? To use a class outside the default one it should work with individual controls.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
set a tag value to it, like "myButton"
and in the CSS file use #myButton instead of .button
 
Last edited:
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I set the button tag to myButton and used this in the CSS script

#myButton
{
-fx-font-family: System;
-fx-font-size: 22px;
-fx-text-fill: Red;

}

But it still uses the button class CSS design.
Do you mind putting together a small source that shows that it really works?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
[EDIT]
You can set the ID in code, its part of most node's properties

button.id="myButton"
 
Last edited:
Upvote 0

Chris Lee

Member
Licensed User
I found by setting the font family along with my other style on the CSS side.
-fx-font-family: FontAwesome;

Then loading the font on the control side:

Dim fx As JFX
ButtonIcon.Font=fx.CreateFontAwesome(20)

It will display correctly. Not sure if that's the right way, but it works.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
@Chris Lee Thanks I will try that. I am using Cableguys method and it works great, but only with FontAwesome and not Material Font.
Hopefully your way works with both Fonts. Have not tested it yet though. You can see how I use FontAwesome button icons in Athena (B4J shared works).
 
Upvote 0
Top