CDN/CSS来自Font Awesome是如何工作的?

huangapple go评论73阅读模式
英文:

How does the CDN/CSS from font awesome work?

问题

I have a general knowledge gap when it comes to how the content of this CDN works. The following is the link to the CDN I'm referring to Font Awesome 6.3. I grabbed the text inside the said CDN and measured its size of it which amounts to 99.65kb. Given the extensive library that font awesome is, it seems unlikely that all the icons can be contained in that small size. Looking through the code i can see that icons have very little code to them only referring to content.

> .fa-calendar-days:before{content:"\f073"}

What i don't understand is how do you actually retrieve the icon from this CSS. For example if i wrote <i class="fas fas-calendar-days/> inside my HTML, does that initiate another server request to Font Awesome to retrieve that icon with content:"\f073"?

英文:

I have a general knowledge gap when it comes to how the content of this CDN works. The following is the link to the CDN I'm referring to Font Awesome 6.3. I grabbed the text inside the said CDN and measured its size of it which amounts to 99.65kb. Given the extensive library that font awesome is, it seems unlikely that all the icons can be contained in that small size. Looking through the code i can see that icons have very little code to them only referring to content.

> .fa-calendar-days:before{content:"\f073"}

What i don't understand is how do you actually retrieve the icon from this CSS. For example if i wrote <i class="fas fas-calendar-days/> inside my HTML, does that initiate another server request to Font Awesome to retrieve that icon with content:"\f073"?

答案1

得分: 1

@font-face{font-family:"FontAwesome";font-display:block;src:url(../webfonts/fa-v4compatibility.woff2) format("woff2"),url(../webfonts/fa-v4compatibility.ttf) format("truetype");

基本上,Font Awesome 使用了一个特殊的“字体”(因此其名称的前半部分),其中的Unicode实际上是图标,所以在该字体中\f073指的是一个特定定义的东西,从给定的字体中呈现出来。图标的实际样式是作为字体文件的一部分定义的。

英文:

If you scroll all the way to the bottom of the page, you'll see part of the CSS that goes:

@font-face{font-family:"FontAwesome";font-display:block;src:url(../webfonts/fa-v4compatibility.woff2) format("woff2"),url(../webfonts/fa-v4compatibility.ttf) format("truetype");

Basically, Font Awesome uses a special "font" (hence the first part of its name) where unicodes are actually icons, so \f073 in that font refers to a specially defined something that renders from the given font. What the icons actually look like is defined as part of that font file.

huangapple
  • 本文由 发表于 2023年2月19日 12:27:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75497990.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定