B4J Tutorial [B4X] FontAwesome & Material Icons fonts

Discussion in 'B4J Tutorials' started by Erel, Nov 9, 2016.

  1. fbritop

    fbritop Active Member Licensed 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: Dec 14, 2016
  2. Erel

    Erel Administrator Staff Member Licensed User

    Not sure that I understand. You should use the copy to clipboard button and then paste it in your code.
     
  3. fbritop

    fbritop Active Member Licensed 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:

    Code:
    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
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    This is the correct solution. It is a bit cumbersome however it will not affect the performance in any way.
     
  5. fbritop

    fbritop Active Member Licensed User

    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:
    Code:
    imgDistance.Typeface=Typeface.LoadFromAssets("b4x_materialicons.ttf")
    Cheers
     
    tufanv and Mashiane like this.
  6. so27

    so27 Active Member Licensed 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?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for these questions in the questions forum.
     
  8. walt61

    walt61 Active Member Licensed User

  9. tufanv

    tufanv Expert Licensed 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.
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice