Re: Text Scaling in Metafile



I suggest the following changes:

Replace the following line:
SelectObject(LHDC, CreateFont(-1,0,0,0,400,0,0,0,0,0,0,0,0,'Arial'));

with the following lines:
int nHeight = -MulDiv( 1, GetDeviceCaps( LHDC, LOGPIXELSY, 72) ); // Use
point size of 1
SelectObject(LHDC, CreateFont(nHeight,0,0,0,400,0,0,0,0,0,0,0,0,'Arial'));


"Shine" <shine_babu@xxxxxxxxxxx> wrote in message
news:uQ49ny4QHHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
Hi All,

I am trying to do a text Scaling in Delphi using the following code
Snippet.
But the result is not as expected it is giving extra space between each
character. In the code I'm creating a font with size 1 and using
SetmapMode I'm scaling it to 10. My expected output is the string written
in Arial font with size 10. But the result is some overlapped text...I'm
not sure weather I'm doing something wrong. Please help me....
Following is the code snippet what i am using

****************************************
Delphi Code Snippet
****************************************
procedure TForm1.Button1Click(Sender: TObject);
var
LMetafile: TMetafile;
LMetafilecan: TMetafileCanvas;
LHDC: HDC;
LXFORM: XFORM;
begin
LMetafile := TMetafile.Create;
LMetafilecan := TMetafileCanvas.Create(LMetafile, 0);
LHDC := LMetafilecan.Handle;
SetGraphicsMode(LHDC,GM_ADVANCED);
SelectObject(LHDC, CreateFont(-1,0,0,0,400,0,0,0,0,0,0,0,0,'Arial'));
with LXFORM do
begin
eM11 := 10;
eM12 := 0;
eM21 := 0;
eM22 := 10;
eDx := 248.75999;
eDy := 128.20000;
end;
SetWorldTransform(LHDC, LXFORM);
TextOut(LHDC,0, 0, 'Hello World', 11);
LMetafilecan.Free;
LMetafile.SaveToFile('C:\EMF.emf');
end;
*******************************************

Any help would be most appreciated.

Regards,
Shine


.