HTML कैनवास फ़ॉन्ट गुण
उदाहरण
"एरियल" फ़ॉन्ट का उपयोग करके कैनवास पर 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 |
परिभाषा और उपयोग
फ़ॉन्ट गुण कैनवास पर पाठ सामग्री के लिए वर्तमान फ़ॉन्ट गुण सेट या लौटाता है।
फ़ॉन्ट गुण CSS फ़ॉन्ट गुण के समान सिंटैक्स का उपयोग करता है ।
डिफ़ॉल्ट मान: | 10px बिना सेरिफ़ |
---|---|
जावास्क्रिप्ट सिंटैक्स: | संदर्भ .font = "इटैलिक स्मॉल-कैप बोल्ड 12px एरियल"; |
सम्पत्ति की कीमत
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 कैनवास संदर्भ