Solved

Setting a font to a specific size...

Posted on 1997-07-11
1
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
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…

739 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