Question about fonts and printing

This is a discussion on Question about fonts and printing within the Windows Programming forums, part of the Platform Specific Boards category; Hi. I'm working on a program that must print data and to have a printview. My question is: Is there ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    Question about fonts and printing

    Hi.

    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:
    Code:
    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
    Posts
    2,544
    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:
    Code:
    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 Cprogramming.com
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21