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

{fontawesome} doesn't recognize aliases (though they render just fine) #94

Closed
mmuurr opened this issue Aug 15, 2022 · 4 comments · Fixed by #96
Closed

{fontawesome} doesn't recognize aliases (though they render just fine) #94

mmuurr opened this issue Aug 15, 2022 · 4 comments · Fixed by #96

Comments

@mmuurr
Copy link

mmuurr commented Aug 15, 2022

icon("times")
# This Font Awesome icon ('times') does not exist:
# * if providing a custom `html_dependency` these `name` checks can
#   be deactivated with `verify_fa = FALSE`

Possibly related to #76?

This seems to be happening (to me, at least) specifically with FA's icon aliases*. Some icons have accumulated lots of aliases over the years, e.g. the x-multiplication symbol: officially "xmark", but acceptable aliases are "close", "multiply", "times", and "remove".

In any case, the newer {fontawesome} package doesn't seem to extract aliases when building fa_tbl (nor maintains a separate alias table). The icons.json file is parsed, however, and here's an example entry (for "xmark"), note the aliases property:

  "xmark": {
    "changes": [
      "1.0.0",
      "5.0.0",
      "5.0.13",
      "5.11.0",
      "5.11.1",
      "6.0.0-beta1"
    ],
    "ligatures": [],
    "search": {
      "terms": []
    },
    "styles": [
      "solid"
    ],
    "unicode": "f00d",
    "aliases": {
      "names": [
        "close",
        "multiply",
        "remove",
        "times"
      ],
      "unicodes": {
        "composite": [
          "1f5d9",
          "2715",
          "2716",
          "274c",
          "d7"
        ],
        "secondary": [
          "10f00d"
        ]
      }
    },
    "label": "X Mark",
    "voted": false,
    "svg": {
      "solid": {
        "last_modified": 1641078268587,
        "raw": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 320 512\"><path d=\"M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z\"/></svg>",
        "viewBox": [
          0,
          0,
          320,
          512
        ],
        "width": 320,
        "height": 512,
        "path": "M310.6 361.4c12.5 12.5 12.5 32.75 0 45.25C304.4 412.9 296.2 416 288 416s-16.38-3.125-22.62-9.375L160 301.3L54.63 406.6C48.38 412.9 40.19 416 32 416S15.63 412.9 9.375 406.6c-12.5-12.5-12.5-32.75 0-45.25l105.4-105.4L9.375 150.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0L160 210.8l105.4-105.4c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25l-105.4 105.4L310.6 361.4z"
      }
    },
    "free": [
      "solid"
    ]
  },

So I think this can be solved pretty easily, and I'm happy to submit a PR, though I don't know if you'd prefer to have an ancillary table (like fa_tbl_shims), or add (partially redundant, apart from the icon name) rows to fa_tbl itself. Unlike with the fa_tbl_shims, the aliases represent a one-to-many relationship, so the left-join here doesn't work so well, and instead it might make sense to build a master inverted index (with all names: v6, v4, and aliases) to find the fa_tbl row (if it exists).




(* something something about naming and cache invalidation being the two hardest problems in computing)

@ismirsehregal
Copy link

ismirsehregal commented Aug 16, 2022

@mmuurr regarding the table including v4 and v6 names you mentioned: this might be of interest.

@krlmlr
Copy link

krlmlr commented Aug 25, 2022

Do we need a lookup for icons renamed in v5?

The PR linked to by @ismirsehregal contains pointers:

fontawesome::fa("times")
#> Error: This Font Awesome icon ('times') does not exist
fontawesome::fa("xmark")
#> Warning: fontawesome does not support this output. Icon(s) will not show.

Created on 2022-08-25 by the reprex package (v2.0.1)

@ismirsehregal
Copy link

@krlmlr this is v4 -> v6:

v4 -> v5 (if needed) can be found here:

https://fontawesome.com/v5/docs/web/setup/upgrade-from-v4#icon-name-changes-between-version-4-and-5

@rich-iannone
Copy link
Member

Thanks for posting this issue. I'm addressing this as part of #96. With that, all past known aliases for icons available in the v6.2 set (taken from Font Awesome's metadata) should now work when used as short names (e.g., fa("times")).

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

Successfully merging a pull request may close this issue.

4 participants