Board index » cppbuilder » A problem with text on printer canvas

A problem with text on printer canvas


2004-01-15 07:55:48 AM
cppbuilder92
I'm attempting to calculate the height in pixels for any given text on the
current printer.
Using:
int TextHeight = Printer()->Canvas->TextHeight(AString);
reveals a value of 75 pixels for the default font on any printer I select.
I've tried this on 120, 600 and 1200 dpi printers.
Now 75 pixels on each of these printers are very different, yet the text is
printed the same size.
I can only come to the conclusion that TextHeight() works differently on a
printer canvas compared to a panel canvas.
I figure there must be a correlation between '75' and the page height and
dpi of the printer (obtained using GetDeviceCaps) but so far I have not been
able to correctly calculate the height.
Can anyone shed any further light.
--
---
Malcolm Smith
MJ Freelancing
www.mjfreelancing.com
Borland Technology Partner
 
 

Re:A problem with text on printer canvas

"Malcolm Smith" < XXXX@XXXXX.COM >wrote:
Quote
int TextHeight = Printer()->Canvas->TextHeight(AString);
If you really want to know the maximum height for a given font:
int TextHeight = Printer()->Canvas->TextHeight( "Wg" );
Quote
reveals a value of 75 pixels for the default font on any
printer I select. I've tried this on 120, 600 and 1200 dpi
printers.

Now 75 pixels on each of these printers are very different,
yet the text is printed the same size.

I can only come to the conclusion that TextHeight() works
differently on a printer canvas compared to a panel canvas.
A Canvas is a Canvas - period.
Quote
Can anyone shed any further light.
Did you first use BeginDoc() ? I have one project where I make
several passes calculating variouse font sizes and I can
assure you that TextHeight does work and thus far it's worked
on every printer I've encountered.
~ JD
 

Re:A problem with text on printer canvas

In one case I am not calling BeginDoc because I need to show a preview
first.
So does TextHeight (for the printer) only work when BeginDoc() is called.
[ My captions only include numbers hence I only used "0' ]
--
---
Malcolm Smith
MJ Freelancing
www.mjfreelancing.com
Borland Technology Partner
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Malcolm Smith" < XXXX@XXXXX.COM >wrote:
>int TextHeight = Printer()->Canvas->TextHeight(AString);

If you really want to know the maximum height for a given font:

int TextHeight = Printer()->Canvas->TextHeight( "Wg" );

>reveals a value of 75 pixels for the default font on any
>printer I select. I've tried this on 120, 600 and 1200 dpi
>printers.
>
>Now 75 pixels on each of these printers are very different,
>yet the text is printed the same size.
>
>I can only come to the conclusion that TextHeight() works
>differently on a printer canvas compared to a panel canvas.

A Canvas is a Canvas - period.

>Can anyone shed any further light.

Did you first use BeginDoc() ? I have one project where I make
several passes calculating variouse font sizes and I can
assure you that TextHeight does work and thus far it's worked
on every printer I've encountered.

~ JD

 

{smallsort}

Re:A problem with text on printer canvas

I came up with a intermediate solution that used a scaling factor when
previewing text since it worked fine when actually printed.
--
---
Malcolm Smith
MJ Freelancing
www.mjfreelancing.com
Borland Technology Partner
"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
In one case I am not calling BeginDoc because I need to show a preview
first.

So does TextHeight (for the printer) only work when BeginDoc() is called.

[ My captions only include numbers hence I only used "0' ]

--
---
Malcolm Smith
MJ Freelancing
www.mjfreelancing.com
Borland Technology Partner


"JD" < XXXX@XXXXX.COM >wrote in message
news:4005f8e1$ XXXX@XXXXX.COM ...
>
>"Malcolm Smith" < XXXX@XXXXX.COM >wrote:
>>int TextHeight = Printer()->Canvas->TextHeight(AString);
>
>If you really want to know the maximum height for a given font:
>
>int TextHeight = Printer()->Canvas->TextHeight( "Wg" );
>
>>reveals a value of 75 pixels for the default font on any
>>printer I select. I've tried this on 120, 600 and 1200 dpi
>>printers.
>>
>>Now 75 pixels on each of these printers are very different,
>>yet the text is printed the same size.
>>
>>I can only come to the conclusion that TextHeight() works
>>differently on a printer canvas compared to a panel canvas.
>
>A Canvas is a Canvas - period.
>
>>Can anyone shed any further light.
>
>Did you first use BeginDoc() ? I have one project where I make
>several passes calculating variouse font sizes and I can
>assure you that TextHeight does work and thus far it's worked
>on every printer I've encountered.
>
>~ JD
>