Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderSpan = (ctx, line, textAnchor) => {
ctx.save();
const x = R.pathOr(0, ['box', 'x'], line);
const y = R.pathOr(0, ['box', 'y'], line);
const width = lineWidth(line);
switch (textAnchor) {
case 'middle':
ctx.translate(x - width / 2, y);
break;
case 'end':
ctx.translate(x - width, y);
break;
default:
ctx.translate(x, y);
break;
}
for (const run of line.runs) {
renderRun(ctx, run);
}