News for hackers. Stuff that matters.
Re:Commas in big numbers everywhere: An OpenType adventure by Mikhail_Edoshin on Saturday October 26, 2019 @03:26AM (#21362269)
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.

Re:Commas in big numbers everywhere: An OpenType adventure by trishume on Saturday October 26, 2019 @03:26PM (#21365660)
Not touching 4 digit numbers is a good variant idea, I might do that, it would only be a one line of code change.

I also still think an alternative world where we decided to use font shaping for digit grouping would work out better, it would just maybe have different conventions. Numbers that you manually separated wouldn't be touched anyways unless you use any group longer than say 4 digits.

For contexts with long identifiers that don't represent quantities like database IDs there could be a stylistic convention of prefixing them with a @ or something instead of a manual stylistic convention for quantities. Then maybe your font could do something cool to make it easier to tell when two big ten digit random numbers in a column are the same, like a pattern of underscores based on hashing. Also having digit grouping in your meaningless IDs is way less of a problem than not having digit grouping in your quantities.

Re:Commas in big numbers everywhere: An OpenType adventure by pojntfx on Saturday October 26, 2019 @04:01AM (#21362402)
Also, this is locale specific. Here in Germany we use dots instead of commas for that.
Re:Commas in big numbers everywhere: An OpenType adventure by weinzierl on Saturday October 26, 2019 @07:42AM (#21363095)
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:...

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

Re:Commas in big numbers everywhere: An OpenType adventure by Mikhail_Edoshin on Sunday October 27, 2019 @07:48AM (#21369147)
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.
Re:Commas in big numbers everywhere: An OpenType adventure by jfk13 on Saturday October 26, 2019 @05:17AM (#21362664)
Fortunately, OpenType fonts can have locale-specific behavior, so as long as your content is appropriately lang-tagged, that shouldn't be a problem.

(Though I still don't think doing this in the font is a good idea, in general.)

Re:Commas in big numbers everywhere: An OpenType adventure by Someone on Saturday October 26, 2019 @08:07AM (#21363154)
So, one could have a font that, say, hides the flag of Taiwan in a Chinese locale? (Yes, there are multiple ‘Chinese’ locales:

  zh-CN Chinese (Simplified, PRC)
  zh-SG Chinese (Simplified, Singapore)
  zh-TW Chinese (Traditional, Taiwan)
  zh-HK Chinese (Traditional, Hong Kong S.A.R.)
  zh-MO Chinese (Traditional, Macao S.A.R.)

)
Re:Commas in big numbers everywhere: An OpenType adventure by yorwba on Saturday October 26, 2019 @08:43AM (#21363294)
Yes, but OpenType only supports 4 different Chinese locales (Chinese, Hong Kong SAR 'ZHH', Chinese Phonetic 'ZHP', Chinese Simplified 'ZHS', Chinese Traditional 'ZHT') https://docs.microsoft.com/en-us/typography/opentype/spec/la...

ZHP seems like it's unlikely to be used in the wild.

Re:Commas in big numbers everywhere: An OpenType adventure by xvilka on Friday October 25, 2019 @09:38PM (#21361027)
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

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

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

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

Re:Commas in big numbers everywhere: An OpenType adventure by pimlottc on Friday October 25, 2019 @11:35PM (#21361540)
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

Re:Commas in big numbers everywhere: An OpenType adventure by xvilka on Friday October 25, 2019 @11:45PM (#21361586)
Yes, I know. I will extend the list with more information soon. Thanks for the feedback!
Re:Commas in big numbers everywhere: An OpenType adventure by linuseouyt on Friday October 25, 2019 @06:34PM (#21359908)
Brilliant.

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

Re:Commas in big numbers everywhere: An OpenType adventure by trishume on Friday October 25, 2019 @06:38PM (#21359928)
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

Re:Commas in big numbers everywhere: An OpenType adventure by mmazing on Saturday October 26, 2019 @12:15AM (#21361673)
Could this be an potential avenue for some sort of exploit? I had no idea that you could "execute" logic via fonts.
Re:Commas in big numbers everywhere: An OpenType adventure by Thorrez on Saturday October 26, 2019 @12:54AM (#21361806)
Previously bugs in how iOS with how it handles certain unicode combining characters meant that an attacker could crash someone's iPhone just by sending a text. I'm not sure if it was buggy logic in the font.

https://news.ycombinator.com/item?id=16386444

Re:Commas in big numbers everywhere: An OpenType adventure by chatmasta on Saturday October 26, 2019 @04:25PM (#21365967)
Definitely. Project Zero had a multi-part series on this subject: https://googleprojectzero.blogspot.com/2015/07/one-font-vuln...
Re:Commas in big numbers everywhere: An OpenType adventure by Animats on Saturday October 26, 2019 @04:00AM (#21362397)
Uh oh. Are fonts now Turing-complete?
Re:Commas in big numbers everywhere: An OpenType adventure by cperciva on Saturday October 26, 2019 @04:17AM (#21362464)
Re:Commas in big numbers everywhere: An OpenType adventure by ghettoimp on Friday October 25, 2019 @10:16PM (#21361223)
Now I am really jealous, and want a hex version that introduces underscores for every group of four...
Re:Commas in big numbers everywhere: An OpenType adventure by trishume on Friday October 25, 2019 @11:12PM (#21361465)
If you want it should be reasonably straightforward to modify the code to do that: https://github.com/trishume/numderline

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

Re:Commas in big numbers everywhere: An OpenType adventure by bla3 on Friday October 25, 2019 @08:37PM (#21360668)
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.)
Re:Commas in big numbers everywhere: An OpenType adventure by michaelvanham on Friday October 25, 2019 @09:01PM (#21360813)
Firefox on Android has an accessibility setting named "Always enable zoom".

With this feature enabled, I can zoom in on this site.

With this feature disabled, I can not zoom in on this site.

Re:Commas in big numbers everywhere: An OpenType adventure by michaelvanham on Friday October 25, 2019 @09:40PM (#21361049)
Chrome on Android has a similar accessibility setting named "Force enable zoom".
Re:Commas in big numbers everywhere: An OpenType adventure by trishume on Friday October 25, 2019 @08:42PM (#21360698)
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.
Re:Commas in big numbers everywhere: An OpenType adventure by klyrs on Friday October 25, 2019 @09:15PM (#21360899)
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)
Re:Commas in big numbers everywhere: An OpenType adventure by duckqlz on Saturday October 26, 2019 @01:34AM (#21361916)
Second that the very first thing I did was zoom. I had no idea this was a privilege. I shall try not to take it for granted lol
Re:Commas in big numbers everywhere: An OpenType adventure by RenRav on Friday October 25, 2019 @08:46PM (#21360723)
Zooms fine with Brave on Android.
Re:Commas in big numbers everywhere: An OpenType adventure by freddie_mercury on Friday October 25, 2019 @11:50PM (#21361599)
Click on a picture. Zoom in all you want. Works just fine on my phone.
Re:Commas in big numbers everywhere: An OpenType adventure by adfkbuvasdas on Saturday October 26, 2019 @05:12AM (#21362648)
I just rotated my phone to landscape.
Re:Commas in big numbers everywhere: An OpenType adventure by ufo on Friday October 25, 2019 @08:08PM (#21360481)
Is there a way to make the font locale sensitive? Half of the planet uses dots instead of commas
Re:Commas in big numbers everywhere: An OpenType adventure by kulpreet on Friday October 25, 2019 @09:23PM (#21360951)
In most cases, you'd want this to be handled at the OS-level by setting your locale preferences to match your region. However, this would require the app to be properly internationalized (using number formatters, etc.) to work correctly.

So you bring up a neat idea. I'm not sure which OSs support it, but OpenType does have a `locale` feature, primarily for glyph variants (ex: same codepoint, but different glyph for Chinese vs. Japanese). I'm guessing it could be abused to accomplish what you want and not require an app to adopt i18n APIs.

Re:Commas in big numbers everywhere: An OpenType adventure by freddie_mercury on Friday October 25, 2019 @11:49PM (#21361598)
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."

Re:Commas in big numbers everywhere: An OpenType adventure by pimlottc on Saturday October 26, 2019 @01:04AM (#21361835)
The author made multiple variants available, including bolding, grouping via squashing, and commas. There are versions of each type published.

https://thume.ca/numderline/

Re:Commas in big numbers everywhere: An OpenType adventure by freddie_mercury on Saturday October 26, 2019 @02:16AM (#21362043)
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.

Re:Commas in big numbers everywhere: An OpenType adventure by Someone on Saturday October 26, 2019 @03:00AM (#21362188)
A web page you visit might tell your browser to download the font (https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_t...)
Re:Commas in big numbers everywhere: An OpenType adventure by haolez on Friday October 25, 2019 @09:06PM (#21360843)
Kind of off topic, but the latencies in which they operate are out of this world. Amazing stuff
Re:Commas in big numbers everywhere: An OpenType adventure by abhikshah on Friday October 25, 2019 @07:35PM (#21360271)
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

Re:Commas in big numbers everywhere: An OpenType adventure by OJFord on Saturday October 26, 2019 @09:38AM (#21363587)
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)?

Re:Commas in big numbers everywhere: An OpenType adventure by gewa on Saturday October 26, 2019 @03:11AM (#21362220)
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.
Re:Commas in big numbers everywhere: An OpenType adventure by toolslive on Saturday October 26, 2019 @08:30AM (#21363232)
yes, it counts the numbers for you.
Re:Commas in big numbers everywhere: An OpenType adventure by zxcvgm on Saturday October 26, 2019 @05:48AM (#21362788)
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.

Re:Commas in big numbers everywhere: An OpenType adventure by edoo on Friday October 25, 2019 @09:49PM (#21361096)
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.