New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 6? #16
Comments
Good question! I've been meaning to rework the parsing process regardless, but I'm not aware of the changes brought in with v6 yet. I'll look into it. |
Well all the individual svg's are still there - so maybe instead of starting w/ a prebuild list and stopped the removed icons, start with the individual svg's and combine into a font file? |
Possibly. It seems in doing so [removing the SVG files] they also removed much of the context for mapping unicode characters to SVG glyphs as well. I'll have to get creative, and likely end up with more regexing. |
I tried a hello world: package.json
main.js
and it fails with:
might be related to this. |
@cirosantilli pinning font awesome to v5.14.0 should resolve your problem until an update comes out. "@fortawesome/fontawesome-free": "5.14.0", |
Unfortunately, standard SVGs and SVG fonts use different formats so the icons cannot just be assembled directly into an SVG font (so the remainder of the conversion can take place). As much as I hate the idea of relying on dependency on top of dependency that may just be what it takes. I do have some of this working with the new version so will keep pushing along and probably put out a beta version so some of you can assist in testing. I don't have access to FontAwesome Pro anymore so I'm a bit limited on testing some of the functionality / layout of the extended formats [like duotone]. |
@omacranger Would it be possible to use the EDIT: All icons metadata |
I put together a quick script that subsets FontAwesome 6 using the subset-font library. I'm sure some of this could be more elegant but it works: const fs = require('fs')
const path = require('path')
const Glob = require("glob")
const YAML = require('yaml')
const subsetFont = require('subset-font')
const faFile = require.resolve('@fortawesome/fontawesome-free')
const faMetadata = path.resolve(faFile, '../../metadata/icons.yml')
const faWebFonts = path.resolve(faFile, '../../webfonts')
const outDir = path.resolve('./assets/fontawesome-subset')
const iconYaml = fs.readFileSync(faMetadata, 'utf8')
const icons = YAML.parse(iconYaml)
const iconSubset = [
"check",
"minus",
"plus"
]
let iconSubSetUnicode = []
iconSubset.forEach((ico) => {
console.log(icons[ico])
iconSubSetUnicode.push(String.fromCodePoint(parseInt(icons[ico]['unicode'], 16)))
})
const outputTypes = [
{ targetFormat: 'woff2', fileExt: 'woff2' },
{ targetFormat: 'sfnt', fileExt: 'ttf' }
]
Glob.sync(faWebFonts + '/*.ttf').forEach((entry) => {
console.log(entry)
const fontData = fs.readFileSync(entry);
outputTypes.forEach((ftype) => {
const subsetBuffer = subsetFont(fontData, iconSubSetUnicode.join(' '), {
targetFormat: ftype.targetFormat,
});
subsetBuffer.then((data) => {
const fName = path.parse(entry).name + '.' + ftype.fileExt;
const fPath = path.join(outDir, fName)
fs.writeFile(fPath, data, err => {
if (err) {
console.error(err);
}
});
})
})
}) |
hi @saurori, subset-font library does a great job!! thank you for sharing this :) |
@saurori Thank you for sharing your script, based on the paths in the script I made some assumptions... |
I use it in a project with Yarn. In my
And then you can run |
Thanks a ton, will work on implementing it now! Is it ok to redistribute your script that you shared? |
Sure. My hope was the author of this repository would use it in some fashion to update with version 6 support, vs creating some new package. |
I created a subset of fontawesome using FontForge for my Zola theme Abridge Using FontForge worked, but it required many steps, so just trying to get something working on the command line for now. GOT IT WORKING! Thanks again! |
For anyone less familiar with setting these things up, or that just wants to save some time, you can use the repo here: |
Hey all, thank you for the contributions! Marvelous work. Simplifies a lot of things. I imagine it should still hold full support and would probably be backwards compatible aside from the reduction of output font types. I put together a PR in #20 (so I could tidy up some code style changes & refactor a few things while I was in there). Let me know what you guys think and I'll see if I can get it published / pushed here in the next few days. |
Or just use the // npm install --save-dev subset-iconfont @fortawesome/fontawesome-free
import { FaFreeProvider } from 'subset-iconfont';
const fa = new FaFreeProvider (['plus', 'clock', '500px'], {
formats: ['ttf', 'woff2'],
});
fa.makeFonts('./outputDir').then((result) => {
console.log('Done!');
}); That will generate exactly the same file structure, including scss and css, with LICENSE included, with codepoints same as the offical ones. A simple subclass would suffice for PRO version, but with |
It appears version 6 no longer ships with the webfont svgs - just sprite sheets. Is that fatal for this project?
The text was updated successfully, but these errors were encountered: