Announcement

Collapse
No announcement yet.

Fonts setup Macro

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

  • Fonts setup Macro

    Code:
    '
    ' *******************************************************
    '
    Macro Fonts_SetUp 
     Dim Font_Size(8 To 72)
      For ctr = LBound(Font_Size) To UBound(Font_Size)
         Font New "Consolas", ctr To Font_Size(ctr) 'for controls
      Next ctr
    End Macro 
    '
    ' For smaller/larger/different fonts than Dialog --- Example useage:
    ' For ctr = %Id_Spinner_1 To %Id_Exit_Btn
    '    Control Set Font hDlg, ctr, Font_Size(24)
    ' Next ctr
    ' 'Spinner labels
    ' ctr = %Id_Spinner_1_Label: Control Set Font hDlg, ctr, Font_Size(16)
    ' ctr = %Id_Spinner_2_Label: Control Set Font hDlg, ctr, Font_Size(12)
    ' end example
    '
    '*******************************************************
    '
    Last edited by Gösta H. Lovgren-2; 15 May 2009, 11:09 PM.
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

  • #2
    Code:
    ctr = %Id_Spinner_1_Label: Control Set Font hDlg, ctr, Font_Size(16)
    ctr = %Id_Spinner_2_Label: Control Set Font hDlg, ctr, Font_Size(12)
    Using the inline numeric literals equal to font size in points is handy, but I tend to forget what size I used where, and I also have clients who change their mind about what font they want where.

    I find equates very very handy for this

    This is not from DDT statements, it is from a statement of account application using the HARU PDF library, but it should give you the idea.
    Code:
    .....
    
    ' there are a limited number of fonts built into Adobe... they must be registered
    ' to documents by the internal name
    $FONT_PROP_SANS_SERIF_NORMAL  =  "Helvetica"
    $FONT_PROP_SANS_SERIF_BOLD    =  "Helvetica-Bold"
    $FONT_MONO_NORMAL             =  "Courier"
    $FONT_MONO_BOLD               =  "Courier-Bold"
    $FONT_PROP_SERIF_NORMAL       =  "Times-Roman"
    $FONT_PROP_SERIF_BOLD         =  "Times-Bold"
    $FONT_PROP_SERIF_ITALIC       =  "Times-Italic"
     ' no sans_serif italic in 'standard' Adobe PDF set. What is Helvetica-Oblique  (oblique=italic?)
     ' gotta be there is courier oblique, too.
    
    ' ---------------------------------------
    ' FONT SUBSCRIPTS for symbolic Access
    ' NUST BE zero to %FONT_MAX
    ' ---------------------------------------
    %FONT_PROP_SANS_SERIF_NORMAL  =  0
    %FONT_PROP_SANS_SERIF_BOLD    =  1
    %FONT_MONO_NORMAL             =  2
    %FONT_MONO_BOLD               =  3
    %FONT_PROP_SERIF_NORMAL       =  4
    %FONT_PROP_SERIF_BOLD         =  5
    %FONT_PROP_SERIF_ITALIC       =  6
    
    %FONT_MAX                     =  6
    
    
    
    
    ' Statement Literal and Selling Entity name on page header
    %FONT_SUB_STMT_LIT       = %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_STMT_LIT      = 18
    ' selling/remit entity phone, fax and web address
    %FONT_SUB_COMPANYINFO       = %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_COMPANYINFO      = 10
    
    ' Sold to literals in statement header (BOLD)
    %FONT_SUB_SOLDTO_LIT       = %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_SOLDTO_LIT       = 12
    
    ' Sold to data in statement header (NORMAL)
    %FONT_SUB_SOLDTO_DATA       = %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_SOLDTO_DATA      = 12  ' In points. Note that font size MAY be decimal (eg "10.5")
                                      ' in which case we will change these equates to MACROs since
                                      ' equates are restricted to integers.
    
    ' make the page X of Y the same as the other literal data:
    ' the "Page" is now its own literal (hard coded 'page' should language specific)
    %FONT_SUB_PAGEOFPAGES       = %FONT_SUB_SOLDTO_DATA
    %FONT_SIZE_PAGEOFPAGES      = %FONT_SIZE_SOLDTO_DATA
    ' we also have Statement date (literal and data), amount now due (literal, currency code and amount)
    
    %FONT_SUB_OTHERHEADER_LIT   =  %FONT_SUB_SOLDTO_LIT
    %FONT_SIZE_OTHERHEADER_LIT  =  %FONT_SIZE_SOLDTO_LIT
    
    %FONT_SUB_OTHERHEADER_DATA  =  %FONT_SUB_SOLDTO_DATA
    %FONT_SIZE_OTHERHEADER_DATA =  %FONT_SIZE_SOLDTO_DATA
    
    ' for lineitem (detail) header
    %FONT_SUB_LINEITEM_HEADER   = %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_LINEITEM_HEADER  =  10
    
    ' line items
    %FONT_SUB_LINEITEM          = %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_LINEITEM         =  9
    
    ' line item comments (regular) This includes the "last payment message"
    %FONT_SUB_LINEITEM_COMMENT  = %FONT_PROP_SERIF_ITALIC
    %FONT_SIZE_LINEITEM_COMMENT = %FONT_SIZE_LINEITEM
    
    ' line item comments, past due only. Goes after all detail.
    %FONT_SUB_LINEITEM_PD_COMMENT  = %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_LINEITEM_PD_COMMENT = %FONT_SIZE_LINEITEM
    
    ' ---  Customer summary "Statement summary" following detail, before remittance slip
    %FONT_SUB_SUMMARY_BUCKET     =  %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_SUMMARY_BUCKET   =  10
    
    ' Statement Summary summary legend and data
    %FONT_SUB_STMT_SUMMARY    =  %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_STMT_SUMMARY   =  10
    ' statement summary standing Finance charge  (tiny font)
    %FONT_SUB_SUMMARY_FCMSG    =  %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_SUMMARY_FCMSG   =  8
    
    ' -------------------------------
    ' **** REMITTANCE SLIP FONTS ****
    ' -------------------------------
    %FONT_SUB_RA_LITERAL        = %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_RA_LITERAL       =  12
    
    %FONT_SUB_RA_INFO           = %FONT_PROP_SERIF_NORMAL
    %FONT_SIZE_RA_INFO          = 10
    
    %FONT_SUB_RA_MESSAGE        = %FONT_PROP_SERIF_ITALIC
    %FONT_SIZE_RA_MESSAGE       = 9    ' centered (maybe)
    
    %FONT_SUB_RA_AMTDUE         =  %FONT_PROP_SERIF_BOLD
    %FONT_SIZE_RA_AMTDUE        =  %FONT_SIZE_RA_INFO      ' same size as the other stuff
    Comes time to print, say, the "lineitem header" you just call the "Set font command" in use with its style and size as an equate:
    Code:
     
        Set_Font  %FONT_SUB_LINEITEMHEADER, %FONT_SIZE_LINEITEM_HEADER
    Want to change the font used for the "Past Due Comment?"

    Change one line of code...
    Code:
    %FONT_SUB_LINEITEM_PD_COMMENT  =   {whatever floats your boat}
    .. and recompile and you're ready to see how it looks.

    This of course has nothing to do with fonts per se, but I think it provides a good example of how equates may be used to make development and maintenance easier.

    You can only look at the %NUMKIDS and "%KING, %PAWN" examples in the help file so many times. (Those examples in the 9x help files made their debuts in the PB/DOS 2.1 manual. That was a long time ago).

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      You can only look at the %NUMKIDS and "%KING, %PAWN" examples in the help file so many times. (Those examples in the 9x help files made their debuts in the PB/DOS 2.1 manual. That was a long time ago).
      At that, it was a great improvement over Turbo Basic's explanation, back when Equates were called NAMED CONSTANTS, the example consisted of three lines:
      Code:
      %debug = -1               'a named constant, value -1
      debug% = 21409            'an integer variable
      Print %debug, debug%      'they are separate entities......
      This is the same place where I first encountered the term 'magic numbers'.
      Rod
      I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

      Comment


      • #4
        One thing I do a lot of is create equates which are other equates... eg
        Code:
        %SUB_OPTION1  =  1
        %SUB_OPTION2  =  2
        %SUB_OPTION3  =  3
        ...
        %SUB_OPTIONn  =  n
        
        %SUB_OPTION_MIN =  1 
        %SUB_OPTION_MAX =  n 
        ...
        
          FOR Z = %SUB_OPTION_MIN TO SUB_OPTION_MAX 
             ....
          NEXT Z
        Makes it really easy to 'add an option' and not worry that you missed changing a loop bound somewhere.

        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X