"When enabled the font engine will train a weighting model to provide estimates for string sizes. Once the model is sufficiently trained it will perform string wrapping without calling ctx.measureText once. This leads to massive performance gains at the cost of accuracy."

excuse me, what?

text sizes are too slow! lets instead train a model to estimate text size, inaccurately
yeah it does a thing where it measures the width of characters up until you've rendered 20,000 (or 500,000?) characters and then if so, it relies on a small hashmap of character->info that it estimates from instead of using the real measureText
that is slightly wacky and I'm not sure I want to use it
@foone Maybe it would be better if it was on the blockchain?
@foone "train a model" is an EXTREMELY OTT way to say "we precalculate the width of each character and fudge the numbers a bit because it worked a bit better"
@foone feels like an oversight in font rendering toolkits that you can't just ask for an approximate width, as it would probably know best

@greg @foone is there any way to like, general case do that with modern fonts with ligatures and what have you that is meaningfully faster than just rendering and checking how many pixels you end up with?

edit: I didn’t the word „approximate“ in there oops. But yeah

@foone "this leads to massive performance gains at the cost of accuracy" also holds true for just using a static value 🤣🤣
@foone I searched this on GitHub to find the source and ended up stumbling upon what appears to be someone trying to earn some kind of cryptocurrency by spamming GitHub and npm with fake contributions, this is just one of the accounts: https://github.com/f1stnpm2
f1stnpm2

f1stnpm2 has 1979 repositories available. Follow their code on GitHub.

GitHub