Wrapper for canvas.getContext, designed to fix differences in textBaseline in different browsers
Install with npm
$ npm install fix-text-baseline
Or install with yarn
$ yarn add fix-text-baseline
import fixTextBaseline from "fix-text-baseline";
Or umd builds are also available
<script src="path/to/fix-text-baseline.js"></script>
Will expose the global variable to window.fixTextBaseline
.
var canvas = document.createElement("canvas");
var ctx = fixTextBaseline(canvas.getContext("2d"));
ctx.font = "40px Arial";
ctx.fillText("test", 0, 10);
MIT © Harvey Zack