FiraCode icon indicating copy to clipboard operation
FiraCode copied to clipboard

Similar to 0×F, add support for binary and octal constants

Open kshetline opened this issue 5 years ago • 12 comments

It would be great if a binary constant, such as 0b1101, could be displayed with a small, raised letter b, and likewise, an octal constant such as 0o644 could be displayed with a small, raised letter o.

image

kshetline avatar Jun 11 '20 10:06 kshetline

I’d get confused with 0o644 rendered as 0○644

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

(I can't find any unicode for a small centered O)

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

Using a lowercase o is already established in JavaScript as the way to express octal numbers, so if that's confusing, the confusion already exists. This change would make the formatting more clear, not less clear, that an octal constant was intended.

And yes, unlike the case for 0×F, it's not as easy to point to an existing glyph to create this "ligature" (more technically, a "contextual alternate"). But I've accomplished this by hand-editing a font, taking the existing b and o, scaling them by a factor of 75%, shifting the positions upward a little, and then adding the results as two new non-Unicode glyphs which are used just for these contextual alternates.

kshetline avatar Jun 11 '20 10:06 kshetline

What I’m saying is, centering the O makes it more similar to a 0, as much as there is no dot/slash.

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

If you look at the picture I added, I don't think it looks more like a zero at all. The result is even smaller than a normal lowercase o, so what you get looks less like a zero that what you get without the new ligature.

kshetline avatar Jun 11 '20 10:06 kshetline

Sorry, I replied via email where I can't see pictures.

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

I guess it works, personally I'd make the B uppercase but that would be really confusing

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

Here's what it looks like as-is in JavaScript, without a special ligature: image

kshetline avatar Jun 11 '20 10:06 kshetline

I can for some reason now see the image via mail?

RubenVerg avatar Jun 11 '20 10:06 RubenVerg

In general, I’m not against the idea. Let me think about it, maybe there’s a way to make it look better

tonsky avatar Jun 11 '20 14:06 tonsky

I'm working on a programming language which will use 0c to denote octal simply because 0o is ugly and hard to read. Perhaps that idea can be swiped here?

Seltyk avatar Aug 28 '20 18:08 Seltyk

How about using something the music flat sign: (0x266d) and armenian small letter oh: օ (0x0585)?

image

(Although the latter breaks the monospace)

Corbie-42 avatar Sep 19 '23 13:09 Corbie-42