Python, 125.833 score
ᵉᵛªˡ(ᵇʸᵗᵉſ(ᵐªᵖ(ˡᵉⁿ,''.ſᵖˡᵢᵗ(''))))
Attempt This Online! or Score this online!
Explanation
Through some experimentation, I found that \u200a
(zero width space) takes up zero pixels. In addition, as kindly pointed out by Mukundan314, \u200c
seems to use up zero pixels as well, though only when surrounded by \u200a
. Using this fact, I created an algorithm to encode any string using only the characters \u200c
and \u200a
. The algorithm works by encoding each character as a string of \u200c
s whose size is the value of its unicode codepoint. Then, they are joined together by \u200a
.
Then, decoding it is simply a matter of splitting the string by the \u200c
delimiter, mapping each element to its length, and converting it back into a string using the bytes
builtin:
bytes(map(len,'...'.split('\u200c')))
In the implementation, the strange-looking unicode characters are converted to ASCII due to Python's implicit NFKC normalization of identifiers, which help slightly shorten the pixel width.
Python, 139.097 score
-0.002 score thanks to @Neil, who noticed that the \u200b
s are apparently unnecessary here.
ᵉᵛªˡ(ᵇʸᵗᵉſ(ºʳᵈ(ˡ)%126for ˡ in'ֲًٌٍٍِّّ֑᷿͈ۘۚ︠̔ۘ̔̔ۛٓ̔̕ﱢٍَْ᷿ۘ̔ͬ̔ۛۙ̔᷾ۘ̔ﱡ̔ﱡٌُ֑۠۟̔︡'))
Attempt This Online!
An alternative solution, which although longer, may port better to other languages. The idea here is that any string of accent characters embedded between two \u200b
s has a pixel width of zero.
A
, the width is 10. Now tryA\u200b
(append a zero-width space), strangely it becomes 9. \$\endgroup\$getsize_multiline
instead. \$\endgroup\$