Fontawesome icons in Web 2.0: Newbie

I am developing my first application in Xojo Web 2.0 and I would like to add the Fontawesome icons. In the API 1.0 I did it adding to the HTML header this text:

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" />

And then in the ‘Opening’ event of the WebTextfield I added the unicode character of the chosen icon, e.g.

Me.Text = Text.FromUnicodeCodepoint(&hf0a9)

The fact is that I would now like to use the latest version of Fontawesome (v5.15.1) and I have added the code for my kit to the HTML header:

<script src="https://kit.fontawesome.com/fxxxxxxxxa.js" crossorigin="anonymous"></script>

But when I try to add some icon to a WebTextfield it doesn’t work. I tried also in the Shown event and it didn’t work either.

I’ve seen that on the Web 2.0 we have the WebPicture.BootstrapIcons but I like the Fontawesome icons better.

Could someone help me, please?.

Thank you very much,

Best regards,
Sergio

I have managed to make it work in two ways:

  1. Copying the SVG code and pasting it into a WebImageViewer object.

  2. Following the example of Lars Lehmann who uses javascript

I find both options very laborious compared to the simple line of code I had to write before.
I’m sure there’s a simpler way but I can’t get it.

Suggestions?

Does anyone have a suggestion? My idea is to use Fontawesome’s icons to create a canvas button with text + icon.

How do you do it then?.

Thanks,
Sergio

There’s always GraffitiFontAwesome. Once loaded, it can be used literally anywhere you can use HTML. So in a button’s Caption, for example:

<raw><i class="fas fa-adjust"></i></raw> Button

image

1 Like