Skip to content
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

Is there a plan to support ligatures? #182

Open
thepian opened this issue May 1, 2021 · 3 comments
Open

Is there a plan to support ligatures? #182

thepian opened this issue May 1, 2021 · 3 comments

Comments

@thepian
Copy link

thepian commented May 1, 2021

As described in Workshape/icon-font-generator#12 (comment)

@oscargm
Copy link

oscargm commented Nov 24, 2021

Hello,

I've created a PR to add a proposal to add ligatures.

Inspired by the comment of @thepian , I've digged into webfonts-generator code and looked to where it adds the ligature here.

I've done the changes locally and I've run the tests, I'm aware that they're failing, but so far I think that the returned value is "correct" considering the changes on the asset generation.

Summary of all failing tests
 FAIL  generators/asset-types/__tests__/svg.ts
  ● `SVG` font generator › resolves with the result of the completed `SVGIcons2SVGFontStream`

    expect(received).toMatchSnapshot()

    Snapshot name: `\`SVG\` font generator resolves with the result of the completed \`SVGIcons2SVGFontStream\` 1`

    Snapshot: "processed->content->/root/foo.svg|{\"name\":\"foo\",\"unicode\":[\"\\u0001\"]}$processed->content->/root/bar.svg|{\"name\":\"bar\",\"unicode\":[\"\\u0001\"]}$"
    Received: "processed->content->/root/foo.svg|{\"name\":\"foo\",\"unicode\":[\"\\u0001\",\"foo\"]}$processed->content->/root/bar.svg|{\"name\":\"bar\",\"unicode\":[\"\\u0001\",\"bar\"]}$"

      77 |     });
      78 | 
    > 79 |     expect(result).toMatchSnapshot();
         |                    ^
      80 |   });
      81 | 
      82 |   test('passes correctly format options to `SVGIcons2SVGFontStream`', async () => {

      at generators/asset-types/__tests__/svg.ts:79:20
      at fulfilled (generators/asset-types/__tests__/svg.ts:24:58)

  ● `SVG` font generator › passes correctly format options to `SVGIcons2SVGFontStream`

    expect(received).toMatchSnapshot()

    Snapshot name: `\`SVG\` font generator passes correctly format options to \`SVGIcons2SVGFontStream\` 1`

    Snapshot: "processed->content->/root/foo.svg|{\"name\":\"foo\",\"unicode\":[\"\\u0001\"]}$processed->content->/root/bar.svg|{\"name\":\"bar\",\"unicode\":[\"\\u0001\"]}$"
    Received: "processed->content->/root/foo.svg|{\"name\":\"foo\",\"unicode\":[\"\\u0001\",\"foo\"]}$processed->content->/root/bar.svg|{\"name\":\"bar\",\"unicode\":[\"\\u0001\",\"bar\"]}$"

      85 |     const result = await svgGen.generate(mockOptions(formatOptions), null);
      86 | 
    > 87 |     expect(result).toMatchSnapshot();
         |                    ^
      88 | 
      89 |     expect(SVGIcons2SVGFontStream).toHaveBeenCalledTimes(1);
      90 |     expect(SVGIcons2SVGFontStream).toHaveBeenCalledWith({

      at generators/asset-types/__tests__/svg.ts:87:20
      at fulfilled (generators/asset-types/__tests__/svg.ts:24:58)

Let me know if I miss something or there is something else to take into account.
I've seen that TTF depends on SVG, and woff, woff2 depend on TTF, so that's why i only changed SVG generator.

It'd be really nice to have ligatures creation added into the library.
Also adding an option in options to allow ligature enabling/disabling is on my mind (but as a next steps if everything looks corect for you).

@vfreitas-
Copy link

I need ligatures for my case as well, so I've tried the @oscargm PR and it seem to work fine here. Tested here: https://fontdrop.info/#/?darkmode=true on the Ligatures Tab and on my project and everything is going fine!

One thing to keep in mind is that it increases the final font file size, in my case the TTF file had around 240kb, and it increased to 320kb. So its probably better to keep it behind a config flag like @oscargm have mention as next step.

@oscargm
Copy link

oscargm commented Mar 4, 2022

If @tancredi don't see anything wrong, PR should be mergeable.

I've added:

  • ligatures to svg generator
  • An option named addLigatures to options to be able to enable ligatures (false by default).

And fixed all the tests, SVG generator is tested with and without ligatures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants