B4J Tutorial [B4X] FontAwesome & Material Icons fonts

Status
Not open for further replies.

fbritop

Well-Known Member
Licensed User
Longtime User
Erel, how do you setup the TypeFace of the control in order to use it as Awesome o Material from the code editor?. Actually I'm adding a invisible label control to the activity and copy the typeface from there (added from the Designer)

Thanks
FBP
 
Last edited:

fbritop

Well-Known Member
Licensed User
Longtime User
For example, I have a button that I want to add an icon and text. The button is created on the activity.create and not in the designer. What typeface to the button should I assign so the button can understand:

B4X:
btnComplete.Text=Chr(0xF00C) & " Finalizar Solicitud"

I cannot find a typeface to assign during runtime. What I'm doing right now, which is not very efficient, is adding a label control to the layout in my designer, with FontAwesome as type face and make it invisible. And then during runtime, when I create the button (which by the way needs to be created because it is added to a custom list view) I assing button.typeface=buttonAddedInDesigner.typeface

So how can I have button.typeface=typeface.FontAwesome or something like that. For both cases, FontAwesome and Material Icons.

I hope it is more clear now.
Thanks
FBP
 

fbritop

Well-Known Member
Licensed User
Longtime User
This is the correct solution. It is a bit cumbersome however it will not affect the performance in any way.

I found a workarround. You can copy both files to the assets (I dont know why when I switched to Release mode both TTF files were not copied, so I copied them manually and put the as Read Only).

Then you can do:
B4X:
imgDistance.Typeface=Typeface.LoadFromAssets("b4x_materialicons.ttf")

Cheers
 

so27

Active Member
Licensed User
Longtime User
Can I add the icons also in dialogs (MsgBox2, DateDialog) as an icon? If so, how the? Can I do this with Activity.AddMenuItem3 use?
 

tufanv

Expert
Licensed User
Longtime User
this is one of the biggest feature of b4x. Previously I was searching for the icons on the internet , some free some paid , than create imageviews , make them transparent etc. But these icons saved a l lot of time . Thanks again Erel. As I use them, I understand their importance.
 

drgottjr

Expert
Licensed User
Longtime User
B4X:
    Dim MyFont As Typeface = Typeface.LoadFromAssets("Whatever.ttf")
    Dim MyLabel as Label
    MyLabel.Initialize("")
    MyLabel.Typeface = MyFont
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…