0

I am creating a CFont which is larger than usual :

font1.CreateFont(54, 0, 0, 0, FW_HEAVY, false, false, 0, ANSI_CHARSET, 
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH|FF_MODERN,
_T("Courier New"));

And set a CEdit control to use this :

m_cEditLimit.SetFont(&font1);

This font was showing ok on the laptop when I was writing the app, but now that I am testing on a regular pc it shows too big and won't fit :

enter image description here

How can I make the font look good on every pc the app is running on ?

Wartin
  • 1,965
  • 5
  • 25
  • 40
  • You need to use a font size that adapts to the system settings. See http://stackoverflow.com/questions/10268470/calculating-the-logical-font-size – Mark Ransom Aug 06 '12 at 19:12

1 Answers1

4

Instead of using a hard-coded 54 for the font size, try calculating the size based on points:

int points = 32;
pix = -MulDiv(points, GetDeviceCaps(hdc, LOGPIXELSY), 72);

Adjust points as necessary until the font fits. Now it should be consistent between systems.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622