Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Class names reference wrong icon character (sorting issue) #379

Open
asalant opened this issue Mar 15, 2018 · 4 comments
Open

Class names reference wrong icon character (sorting issue) #379

asalant opened this issue Mar 15, 2018 · 4 comments

Comments

@asalant
Copy link

asalant commented Mar 15, 2018

In a project that has been using grunt-webfont for a couple years without issue, we are now seeing an issue where the order in which class names are listed in the generated CSS does not match the order of the font characters in the generated font files.

The issue appears to be specific to the sorting rules for the class names in the CSS file. For example, the files:

circle.svg
circle-1.svg
circle-2.svg

are ordered in the font file in the order shown above but in the CSS (Stylus in this case) in the order:

$icon-circle-1 = "\e634"
.icon-circle-1:before
  content:"\e634"

$icon-circle-2 = "\e635"
.icon-circle-2:before
  content:"\e635"

$icon-circle = "\e636"
.icon-circle:before
  content:"\e636"

So a CSS reference to .icon-circle-1 actually renders the font charactercircle.svg as it is first in the font file.

We are using fontforge and it is not clear if the root of the issue is with a recent release of fontforge. Reverting to an older version (we were not seeing these issues the last time we generated web fonts in July 2017) produced errors that prevented running grunt-webfont at all.

Grunt task looks like:

webfont: {
      icons: {
        src: 'public/svg/icons/*.svg',
        dest: 'public/static/fonts',
        destCss: 'client/css/styleguide',
        options: {
          hashes: false,
          htmlDemo: false,
          embed: 'ttf,woff',
          startCodepoint: 0xE600,
          stylesheet: 'styl',
          relativeFontPath: '/static/fonts',
          template: './tasks/icons.template.css',
          templateOptions: {
            baseClass: 'icon',
            classPrefix: 'icon-',
          },
        },
      },
    },

Posting this issue as I have not found a similar open issue for this project or for fontforge and it appears to be new in the last 6 months or so. There is a closed issue #91 that appears related but it is very old (2014).

@asalant
Copy link
Author

asalant commented Mar 15, 2018

FYI @budleigh

@alampros
Copy link
Collaborator

Are you using the codepoints option? If not, I can you try it and see if that corrects the issue?

@andrewfluck
Copy link

This happens regardless of engine, I switched to node and the same bug happens, this is a hassle to my workflow. I will try the codepoints option @alampros

@andrewfluck
Copy link

Hmm, it doesn't seem to change anything

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

No branches or pull requests

3 participants