How to use @fortawesome/fontawesome-svg-core
Comprehensive @fortawesome/fontawesome-svg-core code examples:
How to use @fortawesome/fontawesome-svg-core.parse:
173 174 175 176 177 178 179 180 181 182
var iconDefinition = { prefix: iconOptions.prefix, iconName: iconOptions.icon }; var transform = angular.isString(_this.transform) ? fontawesomeSvgCore.parse.transform(_this.transform) : {}; var mask = angular.isString(_this.mask) ? fontawesomeSvgCore.icon(maskToIcon(_this.mask)) : null; var params = { classes: classList(iconOptions), transform: transform,
How to use @fortawesome/fontawesome-svg-core.dom:
55 56 57 58 59 60 61 62 63 64
let ampcss = "" try { ampcss += "/*Based on Bootstrap v4.1.3 (https://getbootstrap.com)|Copyright 2011-2018 The Bootstrap Authors|Copyright 2011-2018 Twitter, Inc.|Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)*/\n" ampcss += (await promisify(sass.render)({ file: "theme/styl/amp/amp_main.sass" })).css.toString() ampcss += "\n" ampcss += fontawesome.dom.css() ampcss += "\n" ampcss = new CleanCss().minify(ampcss).styles.replace(/!important/g, "").replace(/@charset "UTF-8";/g, "").replace(/@-ms-viewport{width:device-width}/g, "") glog(`making amp css: ${Buffer.byteLength(ampcss)}Byte`)
How to use @fortawesome/fontawesome-svg-core.library:
6 7 8 9 10 11 12 13 14 15 16 17
var _fontawesomeSvgCore = require("@fortawesome/fontawesome-svg-core"); var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons"); var _default = _fontawesomeSvgCore.library.add(_freeSolidSvgIcons.faPen, _freeSolidSvgIcons.faArrowRight); exports["default"] = _default;
How to use @fortawesome/fontawesome-svg-core.toHtml:
145 146 147 148 149 150 151 152 153 154
}).abstract; // We inject the "children" into the svg tag of the first icon spritesAbstract[0].children.push(...iconAbstract[0].children); }); return fontawesome.toHtml(spritesAbstract[0]); }); // Add collections eleventyConfig.addCollection("posts", (collection) => {
How to use @fortawesome/fontawesome-svg-core.findIconDefinition:
1 2 3 4 5 6 7 8 9 10
const {fas} = require('@fortawesome/free-solid-svg-icons'); library.add(fas); function drawFontAwesomeIcon(node, ctx, iconName, x, y, size, color = "white", prefix = "far") { let def = findIconDefinition({prefix: prefix, iconName: iconName}); if (!def) return; let icn = icon(def, { transform: { // can't use scale here, as that apparently only affects CSS not the actual path data
How to use @fortawesome/fontawesome-svg-core.icon:
3 4 5 6 7 8 9 10 11 12
library.add(fas); function drawFontAwesomeIcon(node, ctx, iconName, x, y, size, color = "white", prefix = "far") { let def = findIconDefinition({prefix: prefix, iconName: iconName}); if (!def) return; let icn = icon(def, { transform: { // can't use scale here, as that apparently only affects CSS not the actual path data } });