Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting a font to a specific size...

Posted on 1997-07-11
1
Medium Priority
?
259 Views
Last Modified: 2013-12-03
I'm trying to set up a font to use in printing.  I'm running into a problem when I change the printer's dpi.  It seems the smaller I make the dpi, the larger the font I've declared gets.  Is there any way to force a font to be of a specific size at all times, so that it will be uneffected by these different resolutions?  I'm also using MM_TWIPS as a mapping mode if that helps any.

Much appreciated,
   Adina
0
Comment
Question by:adina
1 Comment
 
LVL 3

Accepted Solution

by:
Melange earned 100 total points
ID: 1302537
If you're not doing this already, make sure that you call pDC->SetMapMode(MM_TWIPS) BEFORE you call pDC->SelectObject(&FontObject). Otherwise, the logical size of the font will be incorrect when drawing. You also want to reset the mapping mode and reselect the font for every page (early in OnPrint is good).

If this isn't it, then exactly how are you creating the font? Since you're using MM_TWIPS, you shouldn't have to care about the current dimensions of the printer. No need for calculating the size based on LOGPIXELSY.

Your create font should look something like this (for 10 pt Arial font):

LOGFONT   logFont;
CFont            MyFont;
CClientDC   dc(this);
TEXTMETRIC tm;
int                  FontHeight;

memset(&logFont, 0, sizeof(LOGFONT));
logFont.lfHeight = -(10*20);
logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
lstrcpy(logFont.lfFaceName, _T("Arial"));
MyFont.CreateFontIndirect(&logFont);
dc.SetMappingMode(MM_TWIPS);
pOldFont = dc.SelectObject(&MyFont);
dc.GetTextMetrics(&tm);
FontHeight = tm.tmHeight - tm.tmInternalLeading;
dc.SelectObject(pOldFont);

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

916 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