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,212
4년 전 조회 3,837
4년 전 조회 4,238
4년 전 조회 4,200
4년 전 조회 4,597
4년 전 조회 3,941
4년 전 조회 4,732
4년 전 조회 5,949
4년 전 조회 2,911
4년 전 조회 5,352
4년 전 조회 6,150
4년 전 조회 3,967
4년 전 조회 6,477
4년 전 조회 3,348
4년 전 조회 3,859
4년 전 조회 5,745
4년 전 조회 4,045
4년 전 조회 3,259
4년 전 조회 6,459
4년 전 조회 5,292
4년 전 조회 3,514
4년 전 조회 1.3만
4년 전 조회 4,938
5년 전 조회 3,663
5년 전 조회 3,882
5년 전 조회 5,518
5년 전 조회 3,162
5년 전 조회 4,462
5년 전 조회 4,021
5년 전 조회 4,426