I have some code that uses non-ASCII unicode chars. Here's a simple example that happens to be JS but the problem exists more generally:
function replaceFractions(text) {
// We're ignoring ⅙⅚⅑⅐⅑⅒
return text
.replace(/([0-9])½/g, '$1.5')
.replace(/([0-9])⅓/g, '$1.333')
.replace(/([0-9])⅔/g, '$1.666')
.replace(/([0-9])¼/g, '$1.25')
.replace(/([0-9])¾/g, '$1.75')
.replace(/([0-9])⅕/g, '$1.2')
.replace(/([0-9])⅖/g, '$1.4')
.replace(/([0-9])⅗/g, '$1.6')
.replace(/([0-9])⅘/g, '$1.8')
.replace(/([0-9])⅛/g, '$1.125')
.replace(/([0-9])⅜/g, '$1.375')
.replace(/([0-9])⅝/g, '$1.625')
.replace(/([0-9])⅞/g, '$1.875')
}
As I see this in Stackoverflow, it's perfectly aligned as I'd expect it to be.
I'm using Monospace-12 in emacs via the following in .emacs:
(set-frame-font "Monospace-12")
If I look at it I see this:
There's bigger gaps than there should be between the 3/4 and 1/5 lines, the 1/5, 2/5, 3/5 and 4/5 are all taking more horizontal space and it's basically ugly. I get similar issues with superscripts (e.g. ⁰¹²³⁴⁵⁶⁷⁸⁹⁽⁾⁻⁺⁼ⁿⁱ)
Is there any way to get this so it's equal width for all chars not just a subset? Ideally I'd like it for all unicode chars but I can live without the weirder ones, emojis and so forth. What I do want is subscripts, superscripts, fractions, currency symbols to all be consistently spaced.