- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Measure text height on an HTML5 canvas element
To get the text height, set the font in pt −
context.font="15pt Calibri";
Now, get the height like the following −
var height = parseInt(context.font.match(/\d+/), 10);
Above we have used a match to separate the font size from font face.
- Related Articles
- Change colour of an image drawn on an HTML5 canvas element.
- HTML5 Canvas Circle Text
- Drawing an SVG file on an HTML5 canvas
- Print a HTML5 canvas element
- How to prevent text select outside HTML5 canvas on double-click?
- Crop Canvas / Export HTML5 Canvas with certain width and height
- Properties to create text using HTML5 Canvas
- How to draw an SVG file on an HTML5 canvas?
- HTML5 Canvas Font Size Based on Canvas Size
- HTML5 Canvas Text Stroke for Large Font Size
- Create a text inside circles in HTML5 Canvas
- Can the HTML5 Canvas element be created from the Canvas constructor?
- addEventListener for keydown on HTML5 Canvas
- Update HTML5 canvas rectangle on hover
- How to put an outline on a canvas text on Tkinter?

Advertisements