HTML 캔버스 글꼴 속성
예시
"Arial" 글꼴을 사용하여 캔버스에 30px 높이의 텍스트를 씁니다.
자바스크립트:
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hello World", 10, 50);
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
font | Yes | 9.0 | Yes | Yes | Yes |
정의 및 사용
font 속성은 캔버스의 텍스트 내용에 대한 현재 글꼴 속성을 설정하거나 반환합니다.
font 속성은 CSS font 속성 과 동일한 구문을 사용합니다 .
기본값: | 10px 산세리프체 |
---|---|
자바스크립트 구문: | context .font="이탤릭체 작은 대문자 굵게 12px arial"; |
속성 값
Values | Description | Play it |
---|---|---|
font-style | Specifies the font style. Possible values:
|
|
font-variant | Specifies the font variant. Possible values:
|
|
font-weight | Specifies the font weight. Possible values:
|
|
font-size/line-height | Specifies the font size and the line-height, in pixels | |
font-family | Specifies the font family | |
caption | Use the font captioned controls (like buttons, drop-downs, etc.) | |
icon | Use the font used to label icons | |
menu | Use the font used in menus (drop-down menus and menu lists) | |
message-box | Use the font used in dialog boxes | |
small-caption | Use the font used for labeling small controls | |
status-bar | Use the fonts used in window status bar |
❮ HTML 캔버스 참조