Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining arbitrary Unicode symbols, or Unicode characters with negative width

Tags:

unicode

glyph

Back in the older ZX Spectrum days, there was a way to print one glyph on top of another, creating a composite glyph with the help of OVER 1 instruction.

I wonder if there is a Unicode way to do the same on modern computers? Can I overlay two completely arbitrary printable glyphs (e.g. 7 and ~) on top of each other as if they were OR'ed or XOR'ed to produce this result?

DIGIT SEVEN (U+0037) TILDE (U+007E) OR'ed combination of DIGIT SEVEN and TILDE XOR'ed combination of DIGIT SEVEN and TILDE

Or, alternatively, are there any "negative width" Unicode symbols?

like image 208
toriningen Avatar asked Oct 22 '18 22:10

toriningen


1 Answers

There isn't a way to encode a superposition of two arbitrary characters in Unicode.

In some encodings predating even 8-bit computers, you could overstrike arbitrary characters by transmitting backspace, so è would be e backspace `. This did not work on early computer screens, but did on mechanical line printers!

There are combining characters in Unicode, including 7̴ and 7̃. Just not that particular one.

The closest thing to support for combining arbitrary characters into a single grapheme is the Zero-Width Joiner (zwidge), which for example is used to make 👩 (woman) + ZWJ + ⚕ (caduceus) = 👩‍⚕️ (female health worker). In emoji and many scripts, such as Devanagari and Arabic, this means something other than superimposing the symbols.

OpenType fonts support ligatures, so a given font might define 7~ or 7 ZWJ ~ as that symbol. Palatino Linotype is one that supports interrobang (‽) this way.

Generally, though, you would need to communicate this to your application some other way, such as embedding a custom font or transmitting the glyph as an inline vector graphic.

like image 65
Davislor Avatar answered Oct 17 '22 18:10

Davislor