Text spacing problem with Interface Builder

Discussion in 'Mac Programming' started by swimlikehell, May 14, 2008.

  1. swimlikehell macrumors member

    Aug 31, 2006

    I am trying to display some information in a floating window which has a NSTextView in it. I stream the data out using for example is << setw(40) <<string with tree columns in a line. This displays it correctly in the console but the text edges are not even when I look at them in the NSTextView. If anyone has any suggestions on how I can display correctly they would be much appreciated.

  2. stadidas macrumors regular

    Feb 27, 2006
    Kent, United Kingdom
    I'm not entirely sure I know what you mean, but it sounds like it has something to do with font spacing. The default font on OS X is proportionally spaced i.e a thin letter like an i does not take up as much space as a large letter like M. The console uses a fixed-width character set, so that all characters take up the same amount of space.
    You may therefore just need to change the typeface used in your NSTextField to a fixed-width font. You can do this by calling setFont: on your text field, which it inherits from NSControl. This could be done like this:

    [myTextField setFont:[NSFont fontWithName:@"Courier" size:10.0]];
    This would set the font to courier (fixed-wdith) with a size of ten.

Share This Page