Embedding font awesome icons in HTML text

Forum to discuss the new web client version of Servoy.

Embedding font awesome icons in HTML text

Postby huber » Thu Sep 14, 2023 2:26 pm

In a HTML help text (in i18n messages), I use embedded HTML symbols, like for example

Code: Select all
<h3>Button &#x26ed;&thinsp;&#x25bf;<h3>


which works fine. Now, I am experimenting to embed font awesome icons, but with no success yet. According to docu on the font awesome website, it should be something like:

Code: Select all
<span class="fas fa-circle"></span>


Is it even possible to embed font awesome in HTML text in Servoy?
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Embedding font awesome icons in HTML text

Postby mboegem » Fri Sep 15, 2023 7:02 pm

Hi Robert,

works straight away for me.
How did you install fontawesome / reference fontawesome css in your solution?
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Embedding font awesome icons in HTML text

Postby huber » Mon Sep 18, 2023 9:25 am

Hi Marc

We included Font Awesome within the Servoy Package Manager Service. But from your asking I assume there is more to do, as my example works in your environment. Is there to import some library/libraries in the less/css style sheet?

Regards,
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Embedding font awesome icons in HTML text

Postby mboegem » Tue Sep 19, 2023 9:32 pm

Hi Robert,

Tried a fresh 2023.6 install running TiNG client.
Just a simple form with a label and text property set to:
Code: Select all
<span class="fas fa-circle"></span>


From SPM, the FontAwesome package was installed, this results in the FontAwesome stylesheet added to the styles.css file in the browser.
I didn't do anything else, but it just works.

It should not make a difference where the text is coming from, either i18n or directly set onto the text property.

Of course the only thing that could break this, is when the component isn't set to display html.
But for (bootstrap) labels, this is the default.

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Embedding font awesome icons in HTML text

Postby rafig » Tue Sep 19, 2023 10:15 pm

Hi,
you could try adding this in your 'onSolutionOpen'
Code: Select all
plugins.fontawesomeLib.load();

Might help :D
Servoy Certified Developer
Image
rafig
 
Posts: 708
Joined: Mon Dec 22, 2003 12:58 pm
Location: Watford, UK

Re: Embedding font awesome icons in HTML text

Postby sanneke » Wed Sep 20, 2023 1:47 pm

I always use i instead of span like the samples of FO:
<i class="fas fa-circle"></i>
Sanneke
Yield Software Development: Need help on your project?
yieldsd.com
User avatar
sanneke
 
Posts: 383
Joined: Thu Jun 15, 2006 9:20 am
Location: Amersfoort

Re: Embedding font awesome icons in HTML text

Postby huber » Wed Sep 20, 2023 4:19 pm

Hi Marc, Rafi, and Sanneke

Thanks a lot for your suggestions, which of course helped to find the problem. I used a servoyextra-htmlaera, which displayed all the information I had correctly, except for the aforementioned:
Code: Select all
<span class=fas fa-circle"></span>
or
Code: Select all
<i class=fas fa-circle"></i>

as Sanneke suggests.

Using a DataLabel, all the info is correctly displayed, including the font awesome circle. Thanks for the hint, Marc.

Best regards,
Robert Huber
7r AG, Switzerland
SAN Developer
http://www.seven-r.ch
User avatar
huber
 
Posts: 518
Joined: Mon May 14, 2012 11:31 pm

Re: Embedding font awesome icons in HTML text

Postby mboegem » Wed Sep 20, 2023 4:37 pm

Hi Robert,

glad it worked out.
Basically the issue was similar to the one in you recent post: using the HTML area.

In smart client HTML area's were the way to display HTML, but in (Ti)NG, everything is HTML.
So in most components, you can use HTML right away.

The specific issue to the HTML area is the underlying component: TinyMCE, which will display the HTML in an iframe
The HTML within the iframe is just unable to use the css/less file in your solution, that's why it doesn't understand your code.

Best thing would be to replace all HTML area's where you don't use it to edit HTML.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 29 guests

cron