omacranger / fontawesome-subset

Creates subsets of FontAwesome fonts for optimized use on the web.
GNU General Public License v3.0
66 stars 15 forks source link

Error: Could not convert the given font. #21

Closed lamhoangtung closed 2 years ago

lamhoangtung commented 2 years ago

Hi, I'm trying to use this package but encountering Error: Could not convert the given font..

Here is how to replicate it. First create these file on the same directory:

fontawesomeSubset([ 'envelope-o', 'github', 'linkedin', 'facebook' ], 'output');


Now run:
```console
❯ npm i

added 111 packages, and audited 112 packages in 29s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Then:

❯ node extract_font.js
/Users/linus/myself/lamhoangtung.github.io/node_modules/fontawesome-subset/dist/index.js:115
        (0, fs_1.writeFileSync)(`${outputFile}.woff2`, ttf2woff2(ttf));
                                                       ^

Error: Could not convert the given font.
    at fontawesomeSubset (/Users/linus/myself/lamhoangtung.github.io/node_modules/fontawesome-subset/dist/index.js:115:56)
    at Object.<anonymous> (/Users/linus/myself/lamhoangtung.github.io/extract_font.js:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Here you can see the Error: Could not convert the given font..

Also the output folder will be created with some of these files, but certainly not what we need.

❯ tree output
output
├── fa-solid-900.eot
├── fa-solid-900.svg
├── fa-solid-900.ttf
└── fa-solid-900.woff

0 directories, 4 files

Btw, my node version are v16.13.1.

Are there anything that I'm doing wrong here ? How can I overcome this problem ? Thanks for checking by !

christopherpickering commented 2 years ago

Hi @lamhoangtung

Yes, the envelope-o should be envelope-open, and the brands should be in a separate group. Like this:

fontawesomeSubset({
    solid: ['envelope-open'],
    brands:['github', 'linkedin',  'Facebook']
  } , 'output');

https://github.com/omacranger/fontawesome-subset#example-generating-separate-glyphs-for-regular-and-solid-styles

lamhoangtung commented 2 years ago

Thanks for helping me out @christopherpickering