4 ms·
It's technically possible (although infeasible) with current web api though. You can draw texts to canvas, sample it, get the pixel value and find the true cent
by mmis1000 3y ago
It's technically possible (although infeasible) with current web api though. You can draw texts to canvas, sample it, get the pixel value and find the true center yourself. But web also never guarantee that text on canvas is as the same as the one you see visually, so you can only find it out one by one.
- aldousd666 3y agoYou can draw a whole span or div that is invisible with fonts in it and everything off screen measure it. Delete it or then show it or move it or whatever. But I've done this before with JavaScript.
- mmis1000 3y agoThat don't work for font that have bounding box disconnected to visual. Like the article just mentioned. Thus you need canvas if you absolutely need to figure out how bad is the bounding box of given font. Because it's the only way to get pixels in js.