Just started playing around with Fuse today and wanted to use icons around the app. I came up with this import to use Font-Awesome icons as classes. Sorry for the long post, but there are almost 700 icons. Not sure if this would work everywhere (couldn’t try it out on my phone yet) but maybe it can be usefull to someone.
MainView.ux
<App Theme="Basic">
<!-- Declare the Icon font (place in ./fonts folder) -->
<Font File="fonts/fontawesome-webfont.ttf" ux:Global="fa" />
<!-- Example of usage -->
<fa-upload FontSize="50" />
</App>
The same technique works for other fonts. I am using elusive icons (http://elusiveicons.com/icons/) and font web symbols liga (http://www.justbenice.ru/studio/websymbols/). For Elusive icons, you can click on the icon you’re interested in and it will show you the unicode code for it in the header below the displayed icon in different sizes.
Hey guys, thank you for that. It works super fine with 4 digits unicodes, but I’m Trying to do the same with a font which uses unicodes with 5 digits such this one: http://unicode-table.com/en/1F440/
<Text ux:Class="icnLink" Font="gzm">🔗</Text> <!-- 5 digits unicode: It doesn't work -->
<Text ux:Class="icnUnlink" Font="gzm"></Text> <!-- 4 digits: It works -->
Helder, I found a fix, not sure if it’s the best around, but it works (store the chars inside the .JS)
var Observable = require("FuseJS/Observable");
var icn = Observable();
icn = {
mail:"\u2709", // "✉ <-- works fine inside value or string in UX
eye:"\ud83d\udc40" // "👀" <-- does NOT work inside value or string in UX
//both works well as databinded values. Show them like that:
//<Text Value="{icn.eye}" />
}
module.exports = {
icn: icn
};
Interesting to notice that the 16-bit char does not appear correctly on the Local preview (Mac), but works fine on them device (Android). iOS was not tested.
Not sure if this is an issue or expected but I find that this does not work anymore unless you ux:include the Icon.ux file into your main file i.e. MainView.ux
If I do not include the Icon.ux file I get errors such as:
build\Local\Preview4\cache\BackButton.g.uno(36,25): E3114: There is nothing named 'fa_chevron_left' accessible in this scope. Are you missing a package reference?