Solved

Setting a font to a specific size...

Posted on 1997-07-11
1
247 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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…

772 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

10 Experts available now in Live!

Get 1:1 Help Now