Text spacing problem with Interface Builder

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

  1. swimlikehell macrumors member

    Joined:
    Aug 31, 2006
    #1
    Hello.

    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.

    Thanks
     
  2. stadidas macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #2
    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:

    Code:
    [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