Thread: Question about fonts and printing

  1. #1
    Registered User
    Join Date
    Sep 2003

    Question about fonts and printing


    I'm working on a program that must print data and to have a printview. My question is: Is there any straight way to create fonts which are at the same size both on the screen and on the printer or I must use the ratio between the values which I get throught this calls:
    int MaxX=GetDeviceCaps(hDC,PHYSICALWIDTH);
    int MaxY=GetDeviceCaps(hDC,PHYSICALHEIGHT);
    for a printer hDC and a screen hDC?

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    For fonts, I think you can use the same point size for each device. Converting point size to logical units for a device which can then be passed to CreateFont is performed with the following formula:
    Quote Originally Posted by MSDN
    For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a specified point size:
    nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
    For images, your approach is spot on. See this MSDN printing example.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. using fonts in program?
    By godhand in forum C Programming
    Replies: 1
    Last Post: 10-04-2003, 10:56 PM
  3. graphics printing in tc 3.0 in dos
    By satyendra in forum A Brief History of
    Replies: 1
    Last Post: 07-22-2003, 07:08 AM
  4. My CPrint library... quality printing made easy
    By LuckY in forum Windows Programming
    Replies: 6
    Last Post: 05-17-2003, 02:18 AM