Solved

Setting a font to a specific size...

Posted on 1997-07-11
1
248 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 58
Font install problem 9 41
sameEnds challenge 3 133
lucky13 challenge 11 120
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: 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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

911 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

19 Experts available now in Live!

Get 1:1 Help Now