Combining arbitrary Unicode symbols, or Unicode characters with negative width
Asked Answered
F

1

14

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?

Flatfoot answered 22/10, 2018 at 22:55 Comment(0)
C
11

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; U+200D), 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.

Castara answered 23/10, 2018 at 1:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.