Big1

웹폰트와 CSS font-display 속성

구글 Material Icons을 웹에서 사용할 때 
이렇게 사용하라고 명시되어 있습니다.
https://fonts.googleapis.com/icon?family=Material+Icons


[code]
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<span class="material-icons">store</span>
[/code]

 

그런데, 문제점은 웹폰트를 로딩하기 전에는 
아이콘이 나오지 않으므로 
위의 예시에서 store 텍스트가 랜더링된 후 
웹폰트가 로딩되면 아이콘이 랜더링 되죠. 

 

웹폰트 로딩 전

3696253845_1614911291.5003.png
웹폰트 로딩 후

3696253845_1614911297.4355.png

 

웹폰트 로딩 전까지 텍스트가 나타나지 않게 하려면
font-display 속성을 이용하면 됩니다만 ( font-display: block; )
구글 웹폰트에서는 font-display에 대한 파라메터를 제공하고 있습니다. (display=block)
(다른 구글 웹폰트에서는 display=swap을 기본으로 안내하고 있습니다.)
https://fonts.googleapis.com/icon?family=Material+Icons&display=block


[code]
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block">
<span class="material-icons">store</span>
[/code]

 

웹폰트 로딩 전

3696253845_1614911984.3509.png
웹폰트 로딩 후

3696253845_1614911316.6884.png


----------

 

참고

 

# Google Material Icons
https://developers.google.com/fonts/docs/material_icons#setup_method_1_using_via_google_fonts

 

# Google Material Icons Resource
https://fonts.google.com/icons
https://material.io/resources/icons/?icon=settings_input_composite&style=baseline

 

# CSS font-display
https://developer.mozilla.org/ko/docs/Web/CSS/@font-face/font-display

 

# NAVER D2 폰트 디스플레이에 대한 자세한 설명 (꼭 읽어보세요)
https://d2.naver.com/helloworld/4969726

|

댓글 1개

좋은정보 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
4년 전 조회 5,300
4년 전 조회 3,911
4년 전 조회 4,305
4년 전 조회 4,281
4년 전 조회 4,685
4년 전 조회 4,023
4년 전 조회 4,801
4년 전 조회 6,027
4년 전 조회 2,980
4년 전 조회 5,447
4년 전 조회 6,247
4년 전 조회 4,043
4년 전 조회 6,602
4년 전 조회 3,411
4년 전 조회 3,938
4년 전 조회 5,952
4년 전 조회 4,112
5년 전 조회 3,328
5년 전 조회 6,533
5년 전 조회 5,377
5년 전 조회 3,574
5년 전 조회 1.3만
5년 전 조회 5,006
5년 전 조회 3,729
5년 전 조회 3,944
5년 전 조회 5,584
5년 전 조회 3,222
5년 전 조회 4,530
5년 전 조회 4,087
5년 전 조회 4,498