The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

... about spaces, digits and alignment

I've got aligning problems and I hope somebody can help me.

in Courier New, 1 space = 1 digit width
in proportional fonts, 2 spaces = 1 digit width

Due to this, when typing I have a disturbing flow of the typed numbers... (one space becomes a digit and occupies more space....)

Question:
does a special char exist that is a blank when assigned to an editbox and occupies the width of a digit ?
Francesco Send private email
Monday, July 14, 2008
 
 
What is the problem that you're trying to solve?
John Topley Send private email
Monday, July 14, 2008
 
 
I know, it's not clear... let's try with a sample.

Imagine an editbox right-aligned with this data "    .  " (4 dot 2 spaces). put the cursor at the right of the point and type "99". Now 2 spaces became 2 digits, occupy more space and the point "moves" to the left.

Unfortunately, at the moment I MUST use an editbox and I MUST populate the editbox with a SetDlgText() call..... I should change all the code handling the data input but I can't now !

I was looking for an hack: find a character that looks like a space but has the width of a digit. Underscore is ok, but it doesn't look like a space :-)
Francesco Send private email
Monday, July 14, 2008
 
 
Unicode defines a figure space (U+2007) which matches the width of a digit, but many fonts don't bother to include such "esoteric" characters.

I just checked with Adobe's Minion Pro, a font ostensibly designed for fine typesetting with many special characters for that purpose, but even that font doesn't define any of the extra-width spaces.

So I'm afraid you'll either have to use a fixed-width font, or manual pixel alignment, or a visible character such as underscore or en-dash (Alt+150).
Chris Nahr
Monday, July 14, 2008
 
 
In many proportional fonts, a "1" is narrower than a "9", making it impossible to define a single whitespace character that is the same width as a digit.

Monday, July 14, 2008
 
 
I think you can't use the stock textbox for this, because the behavior you want is really two textboxes in one: The numbers to the left of the decimal, and those to the right.

IOW, the decimal should not 'float' around.
xampl
Monday, July 14, 2008
 
 
Many (most?) proportional fonts define all digits to be the same width, since the type designers realize that it is common to want columns of numbers to line up.

As far as space goes, though, I really don't know.  Try playing with character map and see if you can come up with something that works.
BillAtHRST
Monday, July 14, 2008
 
 
Can you set the font of the text box to use something like Courier?
Doug
Monday, July 14, 2008
 
 
I think I now have 4 possibilities:

1) use a non-proportional font (but I should use it for all input fields and redesign all the forms....)
2) split the field in two, integer and decimals
3) use an underscore instead of space
4) subclass the editbox class to correctly handle all the cases (codeguru and codeproject have some samples)

Thank you for your ideas.
Francesco Send private email
Monday, July 14, 2008
 
 
Can you used a masked edit control instead? Then the control will put in the decimal point and leave it in place.
Chris Tavares Send private email
Tuesday, July 15, 2008
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz