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

Posted on 2007-10-13
Medium Priority
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 71

Expert Comment

ID: 20071752
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

mahesh1402 earned 2000 total points
ID: 20076124
You can use CDC::BeginPath and CDC::EndPath API function...
Refer Sample on :http://msdn2.microsoft.com/en-us/library/c8ezcwxf(VS.71).aspx

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

Author Comment

ID: 20076145
Damn Mahesh - you are good!

That is one sexy piece of code!

Many thanks - points well deserved!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

840 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