FortAwesome / Font-Awesome

The iconic SVG, font, and CSS toolkit
https://fontawesome.com
Other
73.63k stars 12.19k forks source link

Add (or document) ability to import custom prefix #13647

Open davidAlittle opened 6 years ago

davidAlittle commented 6 years ago

Electron/Vue project. I've worked out how to add my own SVG:

  1. I've created an Icons.js file.
  2. Added a couple SVG icons, following the format from the library:

    'use strict';
    Object.defineProperty(exports, '__esModule', { value: true });
    exports.navReels = {
    prefix: 'cus',
    iconName: 'nav-reels',
    icon: [
    171.04,
    118.5,
    [],
    'E001',
    'M134.54 0a36.49 ... z'
    ]};
    
    exports.rollsAuto = {
    prefix: 'cus',
    iconName: 'rolls-auto',
    icon: [
      510.02,
      486.61,
      [],
      'E002',
      'M508.82,159.66c-6.23 ... Z'
    ]};
  3. Add the custom icons to my imports:
    import { library, dom } from '@fortawesome/fontawesome-svg-core'
    import { fas } from '@fortawesome/free-solid-svg-icons'
    import {navReels, rollsAuto} from './Icons/Icons'
    import { FontAwesomeIcon, FontAwesomeLayers, FontAwesomeLayersText  } from '@fortawesome/vue-fontawesome'
    library.add(fas, navReels, rollsAuto)
    Vue.component( 'font-awesome-icon', FontAwesomeIcon )
    Vue.component( 'font-awesome-layers', FontAwesomeLayers )
    Vue.component('font-awesome-layers-text', FontAwesomeLayersText)
    dom.watch()
  4. Use: <font-awesome-icon :icon="['cus','rolls-auto']"/>

7-27-2018 1-29-32 pm

So, that all works as intended. What I'd like to do, though is to import my whole prefix e.g. import { cus } from './Icons/Icons' . Importing them all individually gets a bit verbose, and adds a step to adding icons to our in-house lib.

What I'm missing is that the font libs have a dependency that defines the prefixes.

Is there a way to do this without forking the project?

tagliala commented 6 years ago

Hi!

Thanks for being part of the Font Awesome Community.

I cannot help on this, leaving this open waiting for feedback from the community