Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting a font to a specific size...

Posted on 1997-07-11
1
Medium Priority
?
258 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 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…

715 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