trishume / numderline

Font patcher to using shaping tricks to make it easier to pick out digit groups in numbers without commas
https://thume.ca/numderline
MIT License
115 stars 9 forks source link

Option for which characters to return? #2

Open thedamon opened 4 years ago

thedamon commented 4 years ago

First of all this is an amazing idea.

I am intrigued by the notion of using this for UI facing inputs. There are many potential ways to solve thousands separators with javascript, but they pose many complications that a font-based solution completely and utterly removes. The added complication of managing what font is being used is many orders of magnitude more straightforward.

However... in a case where we're using a licensed font, running a fontfile through a patcher is potentially illegal! I was thinking an alternative would be to bake a custom font with similar numbers based on an open source font into a component, but ideally JUST a subset of characters that will be needed. An option to specify characters would allow this while using the patcher would be awesome so that a frontend component could bundle with it a much lighterweight font (There is probably a way to do it separately as well, but I have very little experience with open type fonts)

trishume commented 4 years ago

Yah this is totally possible, and shouldn't be too hard to do just by looking at what the patcher does and maybe also what the powerline font patcher does, it should be possible to only copy a subset of characters. I don't plan on implementing this though, but you can if you want to.

If you are making a Javascript component and using underlines, I recommend just inserting underline tags since that will be slightly more seamless and lightweight, and work with any font. But if you specifically want fake commas that aren't part of the text when copy-pasted then you may need a font.

thedamon commented 4 years ago

Yes I am more concerned with commas than underlines. This approach would solve a few issues really nicely:

  1. Can use native number inputs which means far fewer accessibility issues and less complicated code (arrows up and down works by default, can rely on input value being a number, automatic masking)
  2. Live formatting as you type without any js overhead
  3. Copy would give the literal number and copy/paste would work with no issues
  4. With locale settings in the font it could handle languages that separate thousands with spaces out of the box