A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/apis/canvas/CanvasRenderingContext2D/font below:

font ยท WebPlatform Docs

font Summary

The current canvas context font and characteristics, in the manner of the CSS font property.

Property of apis/canvas/CanvasRenderingContext2Dapis/canvas/CanvasRenderingContext2D

Syntax
var result = CanvasRenderingContext2D.font;
CanvasRenderingContext2D.font = value;
Return Value

Returns an object of type StringString

The font string can consist of any CSS font description and is analogous to the CSS font property. The default font is 10px sans-serif. Values that are not CSS font values are ignored.

Examples

The following exaple write a sample string in the canvas

function draw() {
  var ctx = document.getElementById('MyCanvas').getContext('2d');

  ctx.font = "16px Times New Roman";
  ctx.fillText("Lorem ipsum", 0, 30);
}
Related specifications
W3C HTML Canvas 2D Specification
W3C Candidate Recommendation
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4