Results 1 to 4 of 4

Thread: How to pad strings correctly..

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    How to pad strings correctly..

    In my app im iterating through a collection of linteitem objects

    These are very simple objects and are used to make lines for printing...

    objects has two properties text and offset

    text is the text to be printed and offset is the position from left marginal where the text is to begin. The printout will look something like this:


    YUYYU OIUYOI OYUOY OUYUYOU

    12we 9wewe iiiii232 wew

    etc etc


    As you notice I want the lines to match perfectly column-wise...
    But how do I do this?? In the string I can only count characters, and characters differ in width, like "O" and "i"... and I don't have a font-object... only a string to work with...


    How should I proceed?? I apply brush and font when I print the line to printer... But how should I line them up so I add enough space between them so it doesn't matter if the stirings are made of OOOO OOOO or iiiii iiiiii?


    kind regards
    Henrik

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Not sure exactly what you want.

    For printouts, a fixed-width font (like Courier) would solve that problem.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    I think I just wanted a fix width font Upon testing I used arial, and the width changed depending on what kind of characters the line contained, therefor it was impossible to maintain proper columns... since they differed in size depending on the character...
    I did a simple function that counted how many " " it should fill up with until the next column is to be written, but it counted only characters, not the actual width in pixels.... and Im not sure if the font character has a width, I think they only has height


    kind regards
    Henrik

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    Actually, it was Courier New which was fixed size, not Courier It works now, thanks



    /Henrik
    Last edited by MrNorth; Apr 21st, 2004 at 08:48 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width