Mirrored Text in MetaCanvas


2008-03-16 10:15:43 PM
cppbuilder42
In the following code the Font draws mirrored.
Is there a function to undo this?
Second question
what is lfEscapement? and how does it relate to lfOrientation?
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
PaintBox1->Canvas->Brush->Color=BackGroundColor;
PaintBox1->Canvas->Brush->Style=bsSolid;
PaintBox1->Canvas->Rectangle(0,0,PaintBox1->Width-1,PaintBox1->Height-1);
if(!drawn)
return;
HDC hdc=PaintBox1->Canvas->Handle;
SetMapMode(hdc,MM_ISOTROPIC);
SetViewportOrgEx(hdc,PaintBox1->Width/2,PaintBox1->Height/2,NULL);
SetViewportExtEx(hdc,(PaintBox1->Width),-(PaintBox1->Height),NULL);
SetWindowOrgEx(hdc,Pan.x,Pan.y,NULL);
int
Xext=39.37*PaintBox1->Width*GetDeviceCaps(hdc,HORZSIZE)/(zoom*GetDeviceCaps(hdc,HORZRES));
int
Yext=39.37*PaintBox1->Height*GetDeviceCaps(hdc,VERTSIZE)/(zoom*GetDeviceCaps(hdc,VERTRES));
SetWindowExtEx(hdc,Xext,Yext,NULL);
{
HENHMETAFILE hemf=(HENHMETAFILE)pGMetaFile->Handle;
ENHMETAHEADER emh;
GetEnhMetaFileHeader(hemf,sizeof(emh),&emh);
RECT rect;
rect.left=(emh.rclFrame.left*GetDeviceCaps(hdc,HORZRES))/(100*GetDeviceCaps(hdc,HORZSIZE));
rect.top=(emh.rclFrame.top*GetDeviceCaps(hdc,VERTRES))/(100*GetDeviceCaps(hdc,VERTSIZE));
rect.right=(emh.rclFrame.right*GetDeviceCaps(hdc,HORZRES))/(100*GetDeviceCaps(hdc,HORZSIZE));
rect.bottom=(emh.rclFrame.bottom*GetDeviceCaps(hdc,VERTRES))/(100*GetDeviceCaps(hdc,VERTSIZE));
PlayEnhMetaFile(hdc,hemf,&rect);
//delete hemf;
// EnumEnhMetaFile(hdc,hemf,EnhMetaFuncPaint,NULL,&rect);
}
}
void Mystuff()
{
TLogFont lf;
HFONT OldFont;
HFONT NewFont;
pGMetaCanvas->Font->Name = "Arial";
pGMetaCanvas->Font->Size = 14;
pGMetaCanvas->Font->PixelsPerInch =
GetDeviceCaps(pGMetaCanvas->Handle, LOGPIXELSY);
GetObject(pGMetaCanvas->Font->Handle, sizeof(lf), &lf);
lf.lfEscapement = 1800;
lf.lfOrientation = 1800;
// Check here that lf is properly filled out!
NewFont = CreateFontIndirect(&lf);
OldFont = SelectObject(pGMetaCanvas->Handle, NewFont);
pGMetaCanvas->TextOut( (2.5*GetDeviceCaps(pGMetaCanvas->Handle,
LOGPIXELSY)),
(3.0*GetDeviceCaps(pGMetaCanvas->Handle,
LOGPIXELSY)),"Rotated Text!");
SelectObject(pGMetaCanvas->Handle, OldFont);
/*DeleteObject(NewFont);
.....
TextOut(pGMetaCanvas->Handle, x1int+w2, y1int+h2,
ptrpad->Name.c_str(),sizeof(ptrpad->Name.c_str()) -3 );
.....
}
regards Sarason