The digits in the Arial font supplied with Windows are monospaced, in that they each take up the same horizontal space, but they seem to have neglected to provide a "monospaced" version of the space character. This means that you can't format a column of digits right-justified in (say) 12 spaces and have the right-hand edge be aligned. For example:

 1 12 123 1234 12345 1234567 12345678 123456789 1234567890 

works because the font used for code examples has spaces the same width as digits. This however doesn't work if the same text is displayed in Arial (I can't demonstrate because I can't figure out how to defeat SU's reformatting at the moment!).

It just so happens that with Tahoma 8 point you can cheat because a space is exactly half the number of pixels as a digit, but that is messy and very specific.

1

4 Answers

Try using a figure space which should be the same width as a digit even in a proportional font:

A figure space is a typographic unit equal to the size of a single typographic figure (numeral or letter), minus leading. Its size can fluctuate somewhat depending on which font is being used. In fonts with monospaced digits, it is equal to the width of one digit.

1

I used the figure space (as suggested by user1458424) to align numbers and the thin space to separate thousands.

In, say, JavaScript or C, you can type the corresponding unicode char codes anywhere in a string:

  • \u2007: Figure space.
  • \u202F: Thin space.

Using the thin space as a thousands separator has some significant advantages:

  • The intent is clear to both US and European readers, as opposed to using a , or ..
  • You can add it regardless of whether the value is >= 1000, since the space is invisible to the eye.
  • It is thinner than the regular space that separates the currency sign from the value, which makes it look better when there is only one space after the currency sign.

Below, I will describe what I did to get the following format (European decimal separator , in this ex.):

  • €       1,75
  • €     100,00
  • €     199,97
  • €  10 350,00
  • €  21 003,18
  • € 121 018,33

    1. Remove from input all non-digit characters: price.replace(/[^\d]+/g, '').
    2. Count the 'missing characters': missingDigits = maxDigits - price.length.
    3. Set the output value to '€'.
    4. For each missing digit, append a figure space to output: '\u2007'.
    5. Append all the input digits except for the last two, then a decimal separator, then the input's last two digits.
    6. Return all characters of the output except the last six, appended by a thin space '\u202F', appended by the last six characters.

The input can be any string representation of a number, with or without punctuation and illegal characters. The output will be as seen above. You have to choose the maximum number of digits allowed.

2

Yes, if you're willing to pay for it, monotype has a varient of arial for sale that's monospaced.

On the other hand, if you want a good, sans serif font that's free, and works well in many situations, i'd suggest looking at droid sans mono

1

Yes, you can try to get "Arial Monospaced for SAP" font. There exists in Normal and Bold types.

This font belongs to the Client GUI () of SAP R/3 which is an enterprise resource planning software created by German SAP AG Corporation.

Get the 1.2 version of the font in the normal and bold types. The files are called: arimon__.ttf and arimonbd.ttf

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy