by kccqzy · 1y ago · 0 comments
Wait. I thought Windows has ClearType which could render black text on white background using colors. And furthermore there is a wizard to allow users to adjust how much ClearType adjustment there is. This feels like a totally incorrect solution.
And apparently starting from 2021 Microsoft Edge did in fact begin to use ClearText according to this article https://blogs.windows.com/msedgedev/2021/06/02/improving-fon... from Microsoft. So the author's approach would be broken in Microsoft Edge since 2021.
https://github.com/talkjs/country-flag-emoji-polyfill/blob/5...
Just randomly sharing, the part of the trick I like the most is that it renders the emojis scaled down to a 1x1 canvas, so it renders just a single pixel. That makes checking stuff like "am i not accidentally reading in the transparent area of the glyph" and stuff like that no problem, because the whole emoji is blurred down to a single pixel.
The author's example is a bit weird in this regard, it does the same trick (set the canvas width and height to 1), and then it still loops through all 1 pixels and discards any transparent ones.