Currently, Fira Code only raises the _x_ in 0x123abc notation. #116 There are other conventions to mark up hexadecimal numbers and digits are usually case-independent:
0x123abc, 0x123ABC%1a, %1A URL encoding, usually fixed to 2 hexadecimal digits\123abc, \123ABC e.g. Unicode character in CSS\x123abc, \x123ABC may be limited to 1 or 2 hex digits\x{123abc}, \x{123ABC} may be limited to 1 to 6 hex digits\u12ab, \u12AB Unicode character in BMP\u{12ab}, \u{12AB} also Unicode character, but I'm not sure this is actually used anywhereU+12ab, U+12AB Unicode character in BMP in prose, not code (usually zero-padded to 4+ hex digits)\U0123abcd, \U00123ABC Unicode character including astral planes (exactly 8 hex digits)�, � SGML/XML/HTML numeric Unicode character references (uppercase _X_ might be supported in some markup languages)#123abc, #123ABC RGB color in CSS and elsewhere#12a, #12A short for #1122aa, #1122AA in CSS#12ab, #12AB short for #1122aabb, #1122AABB in CSS#1234abcd, #1234ABCD RGBA in CSS, ARGB in some other placesh123abc, h123ABC with letter prefix (cf. b binary and o octal)123abch, 123ABCh with letter suffix\n, \r ... letters beyond _f_ are often used for C0 control codesSome of them may be improved by optimizeing the prefix. I do believe, however, that all of them could benefit from improved numerals. Lowercase case letters (i.e. digits for 10 through 15) go better with old-style figits that have ascenders and descenders, whereas uppercase letters work better with lining figures. In a monospaced typeface, all of them should have a _tabular_ fixed width, of course.
Hi @Crissov! Thanks for the huge summary you鈥檝e made! I agree these are established conventions but can鈥檛 see what can be done in font to improve the rendering of those. The idea of having old-style figures is fine by itself, esp. if you鈥檙e typesetting a book/text/etc. I don鈥檛 think though that I can _program_ font to choose whether to use old-style or capital figures. I use contextual alternatives and they can only look up a couple of characters (and only a fixed number!) backwards or forwards.
It would still be possible to do something for \n, \r, etc., but I鈥檓 not sure what if anything should be done for that. Moving the x in hex constructions like \x12 might be a reasonable thing to do, though.
How about something like this?
This allows the font to enlarge the letter, which is the most important part of the escape sequence:
"foo堍nbar"
Also, the \u{...} format is used in JS.
Hexadecimal numbers usually are not that long. 10 digits would cover almost all use cases, probably. You would perhaps get reasonable results already if you didn't pay attention to the prefix, i.e. switch to old-style digits if a lowercase _a-f_ is nearby, otherwise use the default lining figures.
/(?:[\\#xuh+-{%]{1,3}[\da-f]*)((?:[a-f]\d*)\d|\d(?:\d*[a-f]))/i
\n could be rendered similar to U+2424 .
switch to old-style digits if a lowercase a-f is nearby, otherwise use the default lining figures
Nah. It鈥檒l be a mess. I don鈥檛 want to increase a mess. Better handled through fine-tuning your editor that has real parser
Fair enough. I haven't checked, does Fira Code already support onum vs. lnum?
@Crissov yes
If nothing else, I believe the _x_ in \x1234, \x{1234}, ሴ should look the same as in 0x1234.
Maybe I should have realized sooner that the letter _x_ is shown as a multiplication cross × whenever between any two digits. It's probably less about hexadecimal notation than sloppy typography as in 640x480, but surprisingly does not work for image file names like [email protected].