CFont CreateFont for an outline look (hollow on the inside)

Posted on 2007-10-13
Last Modified: 2013-11-20
Hi Experts,

I'm using Visual C++ 6.0 and I'm trying to call CFont::CreateFont so that my text appears to be hollow... i.e., I want just the outline (outside borders) to show up... How is this done?  In Microsoft Word, you select text, Format Font and choose 'outline'....  Hoping there's a way to do this programmatically with CreateFont...

Question by:thready
    LVL 67

    Expert Comment

    AFAIK there is no direct way to write with outlined fonts. One way is to use a outlined font itself, another (tricky) is to draw the outline yourself, by writing it +-1 pixel in height or width (= 8 combinations), and again with XOR on original position.
    LVL 22

    Accepted Solution

    You can use CDC::BeginPath and CDC::EndPath API function...
    Refer Sample on :

    In straight C something like :

    HFONT myFont = CreateFont(...);      //14 args
    HDC hdc = GetDC(hWnd);

    SelectObject(hdc, myFont);
    SelectObject(hdc, CreateSolidBrush(RGB(255, 0, 0)));  
    SetBkMode(hdc, TRANSPARENT);    
    TextOut(hdc, "Draw the text as a path");
    SetBkMode(hdc, OPAQUE);

    Hope this helps
    LVL 1

    Author Comment

    Damn Mahesh - you are good!

    That is one sexy piece of code!

    Many thanks - points well deserved!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
    Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now