CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2000
    Location
    france
    Posts
    45

    is there a minimum for CFont height ?

    Hi
    I've created a CFont object like that :


    m_Font.CreateFont( 0, 0, 0, 0,
    FW_NORMAL,FALSE, FALSE, FALSE, ANSI_CHARSET,OUT_CHARACTER_PRECIS,
    CLIP_CHARACTER_PRECIS, PROOF_QUALITY,
    VARIABLE_PITCH, "MS Sans Serif" );




    And I'm displaying text in a CRect
    I want my text to have the height of the rect, so I do :



    LOGFONT lf;
    m_Font.GetLogFont(&lf);

    lf.lfHeight = m_rectTitreGraphique.Height();

    CFont fonteTitre;
    fonteTitre.CreateFontIndirect(&lf);

    pDC->SelectObject(&fonteTitre);

    pDC->DrawText(m_csTitreGraphique,m_rectTitreGraphique,DT_CENTER|DT_VCENTER);




    It works, but if the height of my CRect is too small, the text is not displayed correctly : it is cut and the bottom part is not visible.
    Does this depend on the font, and can i resolve my problem ?

    thanks



  2. #2
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: is there a minimum for CFont height ?

    After creating and selection of the font check its real height via LOGFONT structure. Certainly, that you can't to assign your own values for already existed fonts( See ChooseFont dialog ).
    The CreateFontIndirect function creates a logical font with the characteristics specified in the LOGFONT structure. When this font is selected by using the SelectObject function, GDI's font mapper attempts to match the logical font with an existing physical font. If it fails to find an exact match, it provides an alternative whose characteristics match as many of the requested characteristics as possible. Try to play with lfWidth too.




  3. #3
    Join Date
    Jul 2000
    Location
    france
    Posts
    45

    Re: is there a minimum for CFont height ?

    I can't tell why, but I have replaced


    m_Font.CreateFont( 0, 0, 0, 0, FW_NORMAL,
    FALSE, FALSE, FALSE, DEFAULT_CHARSET,
    OUT_STRING_PRECIS,CLIP_DEFAULT_PRECIS,
    PROOF_QUALITY,
    DEFAULT_PITCH|FF_DONTCARE, "MS Sans Serif");



    by

    m_Font.CreateFont( 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, "Arial" );



    and it works perfectly
    thanks for your help


  4. #4
    igbrus is offline Elite Member Power Poster
    Join Date
    Aug 2000
    Location
    Los Angeles
    Posts
    4,658

    Re: is there a minimum for CFont height ?

    Because Arial is TrueType


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

Featured