Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

css - How do ligature icons work in Material Icons?

Using Material Icons, a plus icon can be added as follows:

<i class="material-icons">add</i>  

The text add is no longer visible. Why does this happen and where does the plus icon come from? I know it's defined in the font file, but how?

If it's due to the word add linked with the plus icon in the font file, then why doesn't the following work in Bootstrap, with its Glyphicons?

<span style="font-family: 'Glyphicons Halflings'">20ac</span>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

EXPLANATION

When you strip all the technical information, the answer is really quite straightforward, the font file incorporates a few tables amongst which:

  • [MANDATORY] the list of characters
  • [MANDATORY] the hexadecimal codes of those characters
  • [OPTIONAL] one or more aliases/alternative names for those characters

The one or more aliases/alternative names are the 'ligatures' you are referring to and reside in the font file.

Essentially, when using a character/icon from a font file with ligatures, we have the option to use

  • the 'regular' hexadecimal code: <i class="some-font-with-ligatures">&#xxxx;</i>
  • or the alternative/alias/ligature name: <i class="some-font-with-ligatures">ligature-name or alias</i>

That is probably all the important info for a web designer to know.


EXTRAS

Go to CSS-Tricks: How do ligature icons work... to see usage examples and a brief explanation.

And if you want to mess around with your own icon font files I suggest you start using the IcoMoon APP:

  • start the APP, select an icon and select 'generate font' (bottom right)
  • Enable display of ligatures with the 'show ligatures'-button (top left 3rd button)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...