Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Printer character width

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Printer character width

    Using XP/PBCC 4.04/HP LaserJet 1200/600 dpi, each is functioning just fine.

    Consider: XPRINT FONT ("Arial",12)
    The characters: 0,1,2,...,8,9 are 56 points in length
    - is 33 points in length
    + is 58 points in length

    The above was determined with hardcopy/ruler/pencil/arithmetic. Using these values with some PBCC code, right justifying a column numbers works perfect. The effort to determine the length of each character/font/size is way too labor intensive.

    Someplace/somewhere the width of each character must be stored, like a formula/table.

    Given Arial, 12, how will PBCC determine the character width?

    Sample code/suggestions/referral/push in the right direction is most appreciated. Past assistance/help have been very helpful.

    Thanks, Jack

  • #2
    Jack,

    For any font, but especially a proportional font, you could create your own table, or just use the return from XPRINT TEXT SIZE. The following code snip shows the same numbers here on a LaserJet 8000, as you said you measured.
    Code:
    #COMPILE EXE
    #DIM ALL
    
    FUNCTION PBMAIN () AS LONG
        LOCAL  nWidth!, nHeight!, i&
        XPRINT ATTACH DEFAULT
        XPRINT FONT "Arial",12,0
        FOR i& = 0 TO 9
            XPRINT TEXT SIZE FORMAT$(i&) TO nWidth!, nHeight!
            XPRINT FORMAT$(i&) + "  " + FORMAT$(nWidth!) + "  " + FORMAT$(nHeight!)
        NEXT i&
        XPRINT TEXT SIZE "-" TO nWidth!, nHeight!
        XPRINT "-" + "  " + FORMAT$(nWidth!) + "  " + FORMAT$(nHeight!)
        XPRINT TEXT SIZE "+" TO nWidth!, nHeight!
        XPRINT "+" + "  " + FORMAT$(nWidth!) + "  " + FORMAT$(nHeight!)
        
        XPRINT FORMFEED
        XPRINT CLOSE
    
    END FUNCTION
    Note that XPRINT CHR SIZE is not going to help for proportional fonts, so the above XPRINT TEXT SIZE is what you are looking for.

    If you want right alligned columns, then format the numbers accordingly, use XPRINT TEXT SIZE 's returned nWidth to find the adjused location form the columns right margin where you will ant to print the number, something like:

    PrintLocationX = ColumnRightMagin - nWidth


    Does this help?
    Last edited by Richard Angell; 17 Oct 2007, 08:17 AM.
    Rick Angell

    Comment


    • #3
      This is exactly what I've been looking for. It functions just great.

      These PB forums are loaded with talented folks and their responses are FREE. What a deal!

      Thank You, Jack

      Comment

      Working...
      X