Compare commits
2 commits
b219ed5f8d
...
24fd8beaa2
Author | SHA1 | Date | |
---|---|---|---|
24fd8beaa2 | |||
647aceb51d |
1 changed files with 25 additions and 0 deletions
25
src/font_rendering.dj
Normal file
25
src/font_rendering.dj
Normal file
|
@ -0,0 +1,25 @@
|
|||
`attrubutes`{published="2024-05-05 11:05"}
|
||||
|
||||
# The Suprisingly Complex Process of Drawing Text
|
||||
|
||||
Converting strings to pixels on your screen is one of the most complex operations in computer science. Don't believe me? In this article, I'll dive into the full process of text rendering from start to paint.
|
||||
|
||||
## Step 1: Unicode
|
||||
|
||||
For those who don't know, Unicode is how computers convert bytes in memory, to actual letters. For example, the number `97` in Unicode is the letter `a`. Unicode supports more than just the letters A-Z though. In fact, there are around 149,000 characters in the Unicode standard. This includes every letter from nearly every language in human history, emojis, box drawing characters, various markup characters like bullet points, formatting instructions for hardware like typewriters and teletypes, and more stuff like the angzarr ([which no one even knows the meaning of](https://www.youtube.com/watch?v=cCoed5Oo_J4))
|
||||
|
||||
TL;DR, there are _*a lot*_ of characters in Unicode, and a lot of them aren't even that (things like emojis). We'll call them "code-points" in this article[^twilio].
|
||||
|
||||
The standard that _everyone_ uses (except for JavaScript and Windows), is UTF-8. Which assigns each letter 8 or more bits. But if each character can only be 8 bits, how can there be so many?
|
||||
|
||||
That's because "UTF-8 is a 'variable-width' encoding standard."[^twilio]. That means that if needed, a given code-point can extend past it's 8 bit boundary and become 16, or even 32 bits.
|
||||
|
||||
### TODO: Replace this image
|
||||
|
||||
![An image of an example UTF-8 character and it's encoded bits](https://www.twilio.com/_next/image?url=https%3A%2F%2Fdocs-assets.prod.twilio.com%2F92975df5f0ebb97c1e1746c11bd3a95eff45fe654d08410e79cabb99059a5dcc.png&w=640&q=75)[^twilio]
|
||||
|
||||
|
||||
|
||||
Works Cited
|
||||
|
||||
[^twilio]: "What is UTF-8?" _Twilio Docs_, Twilio, [www.twilio.com/docs/glossary/what-utf-8](https://www.twilio.com/docs/glossary/what-utf-8). Accessed 6 May 2024.
|
Loading…
Reference in a new issue