Thread: Text size

  1. #1
    Registered User morbuz's Avatar
    Join Date
    Aug 2001
    Posts
    35

    Question Text size

    I'm using TextOut() to print text on a window.
    Is there any way to set the size of the text?
    (Just like you can set color, background mode...)
    [Signature here. (Remove this!)]

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You can use CreateFont() and SelectObject().
    zen

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Use
    Code:
    		nHeight = -MulDiv(iTitleSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
    		hFont=CreateFont(nHeight,0,0,0,FW_BOLD,0,1,0,1,
    OUT_DEFAULT_PRECIS,0,PROOF_QUALITY,0,FONT);
    		hSystemFont = SelectObject(hdc,hFont);
    to create the font

    Use
    GetTextExtentPoint32(hdc, sTitle1,lstrlen(sTitle1), &Size);

    and use the Size.cx and Size.cy to get the actual size of the string.


    catch the system font returned from select object so when you are finished with the font you can call selectobject() to return the system font and deleteobject() the created one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  3. How to Change Text File Font Size
    By space in forum Windows Programming
    Replies: 3
    Last Post: 08-07-2006, 11:42 PM
  4. Text size in C
    By adminravi in forum C Programming
    Replies: 16
    Last Post: 07-19-2006, 03:13 PM
  5. Changing text size in a program
    By RedTroja in forum C++ Programming
    Replies: 3
    Last Post: 10-12-2003, 03:53 AM