Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/measure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import parseFont from '../font/index.js';
// Canvas is the prefered way of doing this because
// it is a clean env, and does not touch the DOM tree
export const getCanvasHandler = doc => {
const canvas = doc && doc.createElement('canvas');
const canvas =
(typeof OffscreenCanvas !== 'undefined' && new OffscreenCanvas(100, 100)) ||
(doc && doc.createElement('canvas'));
if (canvas && canvas.getContext) {
const context = canvas.getContext('2d');
if (context && typeof context.measureText === 'function') {
Expand Down