🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11794

Re: Pixel size of text

#11794
From: Bob Gonder
Date: Wed, 14 Jan 2004 18:40
58 lines
2946 bytes
Malcolm Smith wrote:

>I need to know the number of pixels text will be rendered on a printer.
>Is there a more reliable way to test the printer canvas ?

You probably want to use GetDeviceCaps() to get the capabilities for
each printer.

You could use PHYSICALHEIGHT to get the paper height in DUs. Looks
like DUs are DPI * height.

VERTREZ for vertical pixels per page or
LOGPIXELSY for pixels per inch vertical.

>    Printer()->Canvas->TextHeight("0");
>
>but this reveals 75 pixels for both physical printers on my system (laser
>and deskjet).
>
>On the 600dpi laser printer this is fine, but on the 120dpi deskjet (draft
>mode) it is WAY OFF.

Yeah, depends on the font, doesn't it?

>I'm printing thumbnail images with captions and a 2mm gap. On my deskjet
>this becomes a 16mm gap.

So, select the font/size that you want to use:

	printerDy =GetDeviceCaps(printerDC, VERTRES)/lpp;
	printerDx =GetDeviceCaps(printerDC, HORZRES)/cpl;

	printerFont= CreateFont(
		printerDy,printerDx,
		0,			// angle of escapement
		0,			// base-line orientation angle
		FW_THIN,
		FALSE,			// italic attribute flag
		FALSE,			// underline attribute flag
		FALSE,			// strikeout attribute flag
		OEM_CHARSET,		// character set identifier
		OUT_TT_PRECIS,		// output precision
		CLIP_DEFAULT_PRECIS,	// clipping precision
		PROOF_QUALITY,
		FIXED_PITCH+FF_MODERN,	// pitch and family
		NULL );		 	// pointer to typeface name 
	DeleteObject( SelectObject(printerDC,(HGDIOBJ)printerFont) );
Use it:
	ExtTextOut(printerDC,printerDx*x,printerDy*y,
		0,	// text-output options
		(RECT*)NULL,	// optional clipping and/or opaquing 
		str,		// points to string
		z,		// number of characters in string 
		(INT *)NULL ); 	// pointer to array of intercharacter 

Set lpp to 110, and you will get about 0.1 inch high letters.
Print a thumbnail that is 1/10 the page, and print the image at y=12,
and it should be right under it.
Technical Details
Message-ID: <es1b005mlgdh2ahu2k1641mdku5tuflukq@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <400524f6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,68caf32dd13ae34
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-14 11:10:45 PST
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Pixel size of text
Date: Wed, 14 Jan 2004 10:40:40 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <es1b005mlgdh2ahu2k1641mdku5tuflukq@4ax.com>
References: <400524f6$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.31.165.139
X-Trace: newsgroups.borland.com 1074105645 67.31.165.139 (14 Jan 2004 10:40:45 -0700)
Lines: 61
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail