2026, 새로운 도약을 시작합니다.

웹폰트와 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 팁자료실

번호 제목 글쓴이 날짜 조회
공지 3년 전 조회 4,598
2741 3일 전 조회 122
2740 5일 전 조회 109
2739 1주 전 조회 210
2738 1주 전 조회 218
2737 1주 전 조회 181
2736 1주 전 조회 281
2735 3주 전 조회 284
2734 3주 전 조회 263
2733 1개월 전 조회 265
2732 1개월 전 조회 301
2731 1개월 전 조회 268
2730 1개월 전 조회 227
2729 1개월 전 조회 357
2728 1개월 전 조회 245
2727 1개월 전 조회 422
2726 1개월 전 조회 256
2725 1개월 전 조회 332
2724 1개월 전 조회 361
2723 1개월 전 조회 267
2722 1개월 전 조회 300
2721 1개월 전 조회 212
2720 2개월 전 조회 304
2719 2개월 전 조회 307
2718 2개월 전 조회 202
2717 2개월 전 조회 337
2716 2개월 전 조회 202
2715 2개월 전 조회 312
2714 2개월 전 조회 273
2713 2개월 전 조회 376
2712 2개월 전 조회 289
🐛 버그신고