Article View: borland.public.cppbuilder.nativeapi
Article #11795Re: Pixel size of text
From: Malcolm Smith
Date: Wed, 14 Jan 2004 23:23
Date: Wed, 14 Jan 2004 23:23
81 lines
3645 bytes
3645 bytes
Bob,
This isn't exactly what I need, since I need to determine the height based
on the current font - as opposed to producing text at a given height.
I might pass this discussion over to the VCL list since my question is
probably more relevant there.
Thanks for replying.
--
---
Malcolm Smith
MJ Freelancing
http://www.mjfreelancing.com
Borland Technology Partner
"Bob Gonder" <notbg@notmindspring.invalid> wrote in message
news:es1b005mlgdh2ahu2k1641mdku5tuflukq@4ax.com...
> 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:
<4005cf4e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!pln-w!lotsanews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<400524f6$1@newsgroups.borland.com> <es1b005mlgdh2ahu2k1641mdku5tuflukq@4ax.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 15:40:25 PST Reply-To: "Malcolm Smith" <mjfreelancing@optusnet.com.au> From: "Malcolm Smith" <mjfreelancing@optusnet.com.au> Newsgroups: borland.public.cppbuilder.nativeapi References: <400524f6$1@newsgroups.borland.com> <es1b005mlgdh2ahu2k1641mdku5tuflukq@4ax.com> Subject: Re: Pixel size of text Date: Thu, 15 Jan 2004 10:23:09 +1100 Lines: 83 Organization: MJ Freelancing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 211.30.147.112 Message-ID: <4005cf4e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1074122574 211.30.147.112 (14 Jan 2004 15:22:54 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!pln-w!lotsanews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail