🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by JD Sat, 09 Jun 2007 17:11
Screen v/s Printer Fonts
#1946
Author: JD
Date: Sat, 09 Jun 2007 17:11
19 lines
1472 bytes
I'm at a bit of a loss with how to proceed with a print preview.

One can use TScreen::Fonts to get a list of screen fonts
and TPrinter::Fonts to get a list of fonts for the currently
selected printer. As I was looking at these, I noticed that my
HP did not have Courier and of course there were other fonts
as well that did not show up in both lists.

I can work with what ever screen font even if it's not
available to the printer because I can use a Bitmap that
I can convert to a DIB and print that when needed.

My problem is what to do when the user selects a printer font
that's not available to the screen.

Any suggestions?

~ JD
Re: Screen v/s Printer Fonts
#1799
Author: Bob Gonder
Date: Sat, 09 Jun 2007 23:17
95 lines
4222 bytes
JD wrote:

>I'm at a bit of a loss with how to proceed with a print preview.

Do you have the BDS or TCE?
Searching in the BDS help for preview, the #1 hit is for VC++ MFC
When selecting a printer font, an apropriate screen font is chosen to
match it.
This makes sense.
More under Print Preview Architecture
There are also several EnumFont* functions to help confuse matters.


Something along this line might work
Except display the BMP instead of saving to file.
If you have fancier printing requirements, the DC is available for
other functions as well.


struct CPBstruct{
        HDC			printerDC;
        HFONT		printerFont;
        unsigned long		printerDy;
        unsigned long		printerDx;
        Graphics::TBitmap	 * bmp;
};

extern "C"
CPBstruct* __declspec(dllexport) WINAPI CreatePrinterBitmap(
		DWORD	 paperheightX100,
		DWORD	 paperwidthX100,
		DWORD	 topmarginX100,
		DWORD	 leftmarginX100,
		DWORD	 vertdpi,
		DWORD	 horizdpi,
		DWORD	 rows,
		DWORD	 cols,
		char	 orientation,
		bool	 mono )
{
        CPBstruct*c = new CPBstruct;
        c->bmp = new Graphics::TBitmap();
        c->bmp->Monochrome = mono;

        unsigned long height = paperheightX100 - topmarginX100;
        unsigned long width = paperwidthX100 - leftmarginX100;
                c->bmp->Height = (vertdpi * height) / 100;
                c->bmp->Width = (horizdpi * width) / 100;

        c->printerDC = c->bmp->Canvas->Handle;
        c->printerDy = c->bmp->Height / rows;
        c->printerDx = c->bmp->Width / cols;

        c->printerFont= CreateFont(
                        c->printerDy-2, c->printerDx-2,
                        0,                  // angle
                        0,                  // base-
                        FW_THIN,         // font weight
                        FALSE,              // italic attrib
                        FALSE,             // underline att
                        FALSE,            // strikeout att
                        OEM_CHARSET,         // character set identif
                        OUT_TT_PRECIS,      // output precision
                        CLIP_DEFAULT_PRECIS,    // clipping precision
                        DRAFT_QUALITY,      // output quality
                        FIXED_PITCH+FF_MODERN,  // pitch and family
                        "Courier New"      // pointer to typeface name
        );
        return c;
}

extern "C"
void __declspec(dllexport) WINAPI PrintOnPrinterBitmap(
                                CPBstruct* c,
                                unsigned long y, unsigned long x,
                                char*str, unsigned long z)
{
        SetTextAlign( c->printerDC, TA_LEFT+TA_TOP+TA_NOUPDATECP );
        SetBkMode( c->printerDC, TRANSPARENT );

        ExtTextOut( c->printerDC, c->printerDx*x, c->printerDy*y,
                                0, 
                                (RECT*)NULL,
                                str,
                                z, 
                                (int*)NULL );
}

extern "C"
void __declspec(dllexport) WINAPI SavePrinterBitmap(
                                CPBstruct* c,
                                char*filename )
{
        c->bmp->SaveToFile( filename );
}
Re: Screen v/s Printer Fonts
#1804
Author: JD
Date: Sun, 10 Jun 2007 02:09
15 lines
1152 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote:
>
> Do you have the BDS or TCE?

BDS, but it's still in the box (much to my objection).

> [...] Something along this line might work

Actually, I had half expected some GDI solution but this looks
like exactly what I was hoping for. Time will tell <g>.

Thanks!

~ JD
Re: Screen v/s Printer Fonts
#1836
Author: JD
Date: Wed, 13 Jun 2007 02:20
19 lines
1513 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote:
>

Funny thing happened on the way ...

I misplaced a '**/' and the wrong block of code was executed!

End result is that when the user executes the font dialog and I
assign the resulting font to the TBitmap's Font, it appears
to work correctly. For example, when I select a printer font
not available to the screen, it appears that it has worked as
desired.

I understand that the OS will substitute when needed but I
simply can't tell the difference and I'm looking for it so
if I can't tell .... good enough for government work!

~ JD
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads