font-face 명령어
@font-face 명령어는 파일에 저장된 소스를 가진
사용자 정의 글꼴을 정의할 수 있게 합니다. 이 글꼴은 이후
font-family 속성을 사용하여 연결할 수 있습니다.
문법
@font-face {
font-family: 글꼴 이름;
src: 글꼴 소스 위치;
}
예시
로컬 컴퓨터에서 글꼴을 찾아봅시다:
<body>
This is Montserrat SemiBold.
</body>
@font-face {
font-family: "Montserrat SemiBold";
src: local("Montserrat SemiBold");
}
body {
font-family: "Montserrat SemiBold";
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
예시
이제 원격 서버 주소를 지정하여 글꼴을 찾아봅시다:
<body>
This is Bitstream Vera Serif Bold.
</body>
@font-face {
font-family: "Bitstream Vera Serif Bold";
src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf");
}
body {
font-family: "Bitstream Vera Serif Bold", serif;
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
: