Results 1 to 5 of 5

Thread: Fonts

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    62

    Fonts

    Is there a way to change the "safe area" on the top and bottom of a font?

    What I want to do is this: I have a label that is multilined, but there is a lot of space between the lines since I am using a large font. I would like to trim off a little of the safe area at the top and bottom of the font so the words get 'squished' closer togeter.

    Any thoughts or suggestions?

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Fonts

    you could just print the text straight to the form in the position you want

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Line Spacing in RichTextBox

    You can use a RichTextBox and set custom LineSpacing.
    See the code below.
    (Note: This code most likely will NOT work on Windos98/Me)

    vb Code:
    1. ' add a RichTextBox, a Textbox and a CommandButton in a form.
    2. ' Type the line-spacing you want (in twips) in the textbox
    3. ' and hit the command button
    4. Option Explicit
    5.  
    6. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal HWND As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    7.  
    8. Const WM_USER = &H400
    9. Const EM_GETPARAFORMAT As Long = (WM_USER + 61)
    10. Const EM_SETPARAFORMAT = WM_USER + 71
    11. Const PFM_LINESPACING As Long = &H100
    12.  
    13. Const MAX_TAB_STOPS = 32
    14.  
    15. Private Type PARAFORMAT2
    16.     cbSize                     As Long
    17.     dwMask                     As Long
    18.     wNumbering                 As Integer
    19.     wEffects                   As Integer
    20.     dxStartIndent              As Long
    21.     dxRightIndent              As Long
    22.     dxOffset                   As Long
    23.     wAlignment                 As Integer
    24.     cTabCount                  As Integer
    25.     rgxTabs(MAX_TAB_STOPS - 1) As Long
    26.     dySpaceBefore              As Long
    27.     dySpaceAfter               As Long
    28.     dyLineSpacing              As Long
    29.     sStyle                     As Integer
    30.     bLineSpacingRule           As Byte
    31.     bOutlineLevel              As Byte
    32.     wShadingWeight             As Integer
    33.     wShadingStyle              As Integer
    34.     wNumberingStart            As Integer
    35.     wNumberingStyle            As Integer
    36.     wNumberingTab              As Integer
    37.     wBorderSpace               As Integer
    38.     wBorderWidth               As Integer
    39.     wBorders                   As Integer
    40. End Type
    41.  
    42. Private Function SetLineSpacing(lHwnd As Long, LineSpacingInTwips As Long)
    43.    
    44.     Dim pf2 As PARAFORMAT2
    45.     Dim lR As Long
    46.    
    47.     pf2.cbSize = Len(pf2)
    48.     SendMessage lHwnd, EM_GETPARAFORMAT, 0&, pf2
    49.     '
    50.     pf2.dwMask = PFM_LINESPACING
    51.     pf2.bLineSpacingRule = 4
    52.     pf2.dyLineSpacing = LineSpacingInTwips
    53.     pf2.cbSize = Len(pf2)
    54.     SendMessage lHwnd, EM_SETPARAFORMAT, 0, pf2
    55.    
    56. End Function
    57.  
    58. Private Sub Command1_Click()
    59.     RichTextBox1.SelStart = 0
    60.     RichTextBox1.SelLength = Len(RichTextBox1.Text)
    61.     SetLineSpacing RichTextBox1.HWND, Val(Text1.Text)
    62.     RichTextBox1.SelLength = 0
    63. End Sub
    64.  
    65. Private Sub Form_Load()
    66.     Text1.Text = 170 'this value looks good in my comp
    67. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Fonts

    If the label is going to have rather constant, unchanging text length, use two labels in transparent back color instead of one and divide the caption text. Then squeeze the position of the lower one up closer to the one above by adjusting the Top value. It's an old trick but it works.
    Doctor Ed

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Fonts

    Ahhh...I totally overlooked the 'label' part.
    Sorry for making things convoluted.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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