
Commas in big numbers everywhere: An OpenType adventure - lelf
https://blog.janestreet.com/commas-in-big-numbers-everywhere/
======
Mikhail_Edoshin
AFAIK general style guides don't recommend using thousand separators in
numbers below 10000, so "variable #1,234" is not quite good, it should've been
simply "variable #1234". "Variable 12,345" would've probably been OK, but then
there's another semantic issue: thousand separators are only used in numbers
that mean quantities, not identifiers. Long numeric identifiers like phone
number or SSN are usually separated differently.

Generally the issue should not be handled at the font level, it lacks
sufficient context to make intelligent decisions and can never handle all
possible cases. The font should just provide the required glyph variants and
means to use them.

~~~
pojntfx
Also, this is locale specific. Here in Germany we use dots instead of commas
for that.

~~~
weinzierl
Not just Germany. Comma vs dot is just a big mess with some countries using
both[1]. Even in Germany, which is _decimal comma_ country, the dot is
ubiquitous in science and technology publications. Best thing is to stick with
dot and us neither comma nor dot as thousands separator but a thin, fixed
space. This also what NIST recommends[2]:

> #16 Digit spacing

> The digits of numerical values having more than four digits on either side
> of the decimal marker are separated into groups of three using a thin, fixed
> space counting from both the left and right of the decimal marker. Commas
> are not used to separate digits into groups of three.

[1]
[https://en.wikipedia.org/wiki/Decimal_separator#/media/File:...](https://en.wikipedia.org/wiki/Decimal_separator#/media/File:DecimalSeparator.svg)

[2]
[https://physics.nist.gov/cuu/Units/checklist.html](https://physics.nist.gov/cuu/Units/checklist.html)

~~~
Mikhail_Edoshin
There are much more variants. E.g. Russia uses space for thousands and decimal
comma. And I may be mistaken, but I believe in Japan the grouping is by four
digits, not by three.

------
xvilka
Interesting article! Time to start a new crusade, I guess like I did for True
Colors[1], and BiDirectional[2] text. This time for a better font shaping
support. If you have ready tests it would help a lot. Personally, I am waiting
for ligatures support to be merged[3] in alacritty terminal emulator.

Update: I started a list[4] of terminal emulators supporting it and not.

[1]
[https://github.com/termstandard/colors](https://github.com/termstandard/colors)

[2]
[https://gist.github.com/XVilka/a0e49e1c65370ba11c17](https://gist.github.com/XVilka/a0e49e1c65370ba11c17)

[3]
[https://github.com/jwilm/alacritty/pull/2677](https://github.com/jwilm/alacritty/pull/2677)

[4]
[https://gist.github.com/XVilka/070ed8b1c1186097cad65ef492201...](https://gist.github.com/XVilka/070ed8b1c1186097cad65ef49220175a)

~~~
pimlottc
Regarding your list, I'm not sure what specifically you mean by "font
shaping", but VS Code definitely supports programming ligatures:

[https://github.com/tonsky/FiraCode/wiki/VS-Code-
Instructions](https://github.com/tonsky/FiraCode/wiki/VS-Code-Instructions)

~~~
xvilka
Yes, I know. I will extend the list with more information soon. Thanks for the
feedback!

------
linuseouyt
Brilliant.

This should be an opt-in feature in all programmers fonts.

~~~
trishume
You can use the patcher on Github to patch a font of your choice, although
underlining currently only works well with some fonts.

I also have some good fonts pre-patched on the download site at
[https://thume.ca/numderline](https://thume.ca/numderline)

------
mmazing
Could this be an potential avenue for some sort of exploit? I had no idea that
you could "execute" logic via fonts.

~~~
Animats
Uh oh. Are fonts now Turing-complete?

~~~
cperciva
Yes: [https://litherum.blogspot.com/2019/03/addition-
font.html](https://litherum.blogspot.com/2019/03/addition-font.html)

------
ghettoimp
Now I am really jealous, and want a hex version that introduces underscores
for every group of four...

~~~
trishume
If you want it should be reasonably straightforward to modify the code to do
that:
[https://github.com/trishume/numderline](https://github.com/trishume/numderline)

More advanced but totally doable would be switching to that mode for hex
strings after "0x" or "0X"

------
bla3
Probably cool, but the website disables zooming in phones so I can't tell. I
wish pages couldn't disable zooming -- that should be up to me. Does anyone
know browsers that always allow zoomi (If any Jane Street blog folks read
this, please fix your blog.)

~~~
trishume
Huh interesting. Zooming works fine for me on IOS. Maybe it's only blocked on
Android. If I remember I'll take a look on Monday.

~~~
klyrs
I'd start with this line:

    
    
      <meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'/>
    

(I also can't zoom, android/firefox)

------
ufo
Is there a way to make the font locale sensitive? Half of the planet uses dots
instead of commas

~~~
freddie_mercury
Make what locale sensitive?

There are no commas in his font.

"I realized that instead of inserting commas, I wanted to underline
alternating groups of 3 digits so that the font would work in monospace
contexts."

~~~
pimlottc
The author made multiple variants available, including bolding, grouping via
squashing, and commas. There are versions of each type published.

[https://thume.ca/numderline/](https://thume.ca/numderline/)

~~~
freddie_mercury
If you're downloading and installing a custom font, why do you need it to be
locale-aware? Just down the variant that uses whatever your locale needs. (Or
if there isn't one, fork it and change the commas to periods and the install
that.)

It seems like the only reason you'd need a locale-aware one is on a multi-user
system where you'd expect users to have different locales and you're
installing the font globally.

But that doesn't really seem like a likely use-case for this pretty niche font
that is almost exclusively going to installed on single-user machines by the
end-user.

~~~
Someone
A web page you visit might tell your browser to download the font
([https://developer.mozilla.org/en-
US/docs/Learn/CSS/Styling_t...](https://developer.mozilla.org/en-
US/docs/Learn/CSS/Styling_text/Web_fonts))

------
haolez
Kind of off topic, but the latencies in which they operate are out of this
world. Amazing stuff

------
abhikshah
Wow, that's an elegant solution!

I also have a difficult time reading large numbers without commas. Because I
use Alfred (mac command launcher) quite a bit, I wrote up a simple workflow to
re-display selected numbers with commas. Not as universal as the font-based
solution but might be useful to some:

[https://github.com/abhik/tres-commas](https://github.com/abhik/tres-commas)

------
OJFord
Presumable it handles text that already has a comma separator OK, since there
isn't a continuous group of >3 digits in '1,234'.

I suppose the same is true of continental Europe's '1.234', though it would be
very cool if it could be determined that the '.' was a thousand separator and
modified to ','.

What happens though if the text is using '.' separator and ',' decimal, such
as (roughly 123 and a half) '123,456789', is it going to determine there's a
missing ',' between '6' & '7' (making it roughly 123 and a half _million_ )?

------
gewa
I wonder why not to use scientific exponential notation. Once you get used to
it, it comes really handy to compare numbers of many magnitudes.

~~~
toolslive
yes, it counts the numbers for you.

------
zxcvgm
This is fantastic for command line output and whatever that doesn’t natively
support digit grouping. I have no idea how people live without enabling it.

I turn it on my Windows calculator, and I’m also happy that now programming
languages like JavaScript, Python and recently Go allows using underscores in
numeric literals for doing this in code to make it more readable.

------
edoo
My primary calculator in linux is speedcrunch which lets you do adjustable
squishing as it is referred to in the article which is pretty nice.

