Allow a different font to be used
Closed this issue · 0 comments
jwarby commented
This feature would allow a font other than FontAwesome to be used. This is desirable for a number of reasons:
- FontAwesome has a wide variety of icons, but often lacks the kind of icons required by specialised web applications
- FontAwesome has a slow release cycle, which can be frustrating
- Grants the plugin a lot more flexibility
This feature should be fairly easy to implement; there are two main changes that need to be addressed:
- change the hard-coded font string to reference an option instead
- allow a way to specify the CSS class for icon. For instance, FontAwesome icons require the class
.fa fa-<icon name>
.
Suggested approach is thus:
-
specify a different font using a new
font
option, e.g.$(...).awesomeCursor('some-icon', { font: 'MyAmazingIconFont' });
-
specify CSS class using a new
cssClass
option, which can be:- a string, where
'%s'
will be the name of the icon, e.g.
$(...).awesomeCursor('some-icon', { cssClass: 'fa fa-%s' });
- a function, which would receive the name as the only parameter, and would be expected to return the CSS class for the icon; e.g.
$(...).awesomeCursor('some-icon', { cssClass: function(name) { return 'fa fa-' + name; } });
- a string, where
It may also be worth wrapping both of these new options in an object since they are so closely related:
$(...).awesomeCursor('some-icon', {
font: {
name: 'MyAmazingIconFont',
cssClass: 'fa fa-%s'
}
});
However this is implemented, it will default to the usual FontAwesome-specific values. and will of course be overridable:
console.log($.fn.awesomeCursor.defaults);
// ...
// font: {
// name: 'FontAwesome',
// cssClass: 'fa fa-%s'
// }
// ...