Board index » cppbuilder » Problem with Fonts in a TMetafile placed on an TImage

Problem with Fonts in a TMetafile placed on an TImage

Hi

I've got some problems with fonts that is prints very narrow and over each other when I show the Metafil on an Image.

The Metafile is made on an MetafileCanvas and has 1 to 3 other metafiles merge together with command "Canvas->Draw" and then I've put in some text with the command "Canvas->TextOut".

This merged metafile is printed out in two ways.

In the first I use Nevronas ReportPrinter (Rave). Both on paper and preview all looks good.

In the second I print the same metafile to a Bitmap wich is placed on an TImage. Here the letters in the text seem to be placed very narrow and printed above each other. Only the text put in the metafile with the command "Canvas->TextOut" is wrong printed. And It does not scale allright.

Someware Nevrona manages to get the print to a screen allright
Do someone knows that secret??

Magnus Fredriksson

 

Re:Problem with Fonts in a TMetafile placed on an TImage


Magnus Fredriksson<3c4d65a1$1_1@dnews>wrote

Quote
>I've got some problems with fonts that is prints very narrow and over each
>other when I show the Metafil on an Image.

>The Metafile is made on an MetafileCanvas and has 1 to 3 other metafiles
>merge together with command "Canvas->Draw" and then I've put in some text
>with the command "Canvas->TextOut".

Do you use NoteBook Computer with 2:1 LCD?
For Example, 1024 x 512 resolution.

--
Takuo Nakamura mailto:nakam...@asahi.email.ne.jp

Re:Problem with Fonts in a TMetafile placed on an TImage


Hi Takuo

I've got a Compac Armada M700 and  I'm working in the1024 x 768 resolution.
But why can the same picture get a different apperance on the same computer depending if I use the preview (to screen) in the Reportprinter component, or I print the picture on an TImage. Shouldn't be a difference.

Magnus Fredriksson

Quote
Takuo Nakamura <nakam...@asahi.email.ne.jp> wrote:
>Magnus Fredriksson<3c4d65a1$1_1@dnews>wrote
>>I've got some problems with fonts that is prints very narrow and over each
>>other when I show the Metafil on an Image.

>>The Metafile is made on an MetafileCanvas and has 1 to 3 other metafiles
>>merge together with command "Canvas->Draw" and then I've put in some text
>>with the command "Canvas->TextOut".

>Do you use NoteBook Computer with 2:1 LCD?
>For Example, 1024 x 512 resolution.

>--
>Takuo Nakamura mailto:nakam...@asahi.email.ne.jp

Re:Problem with Fonts in a TMetafile placed on an TImage


Magnus Fredriksson<3c4e9cc6$1_1@dnews>wrote

Quote
>I've got a Compac Armada M700 and  I'm working in the1024 x 768 resolution.
>But why can the same picture get a different apperance on the same computer
>depending if I use the preview (to screen) in the Reportprinter component, or
>I print the picture on an TImage. Shouldn't be a difference.

Hmm...  Possibly, the code below helps you.
This code calculate the width of the font of the Canvas,
and explicitly set Width of the Font.

Call AdjustFont immeidiately before calling Canvas.TextOut.

procedure AdjustFont(Canvas: TCanvas);
var
  tm: TTextMetric;
  lf: TLogFOnt;
begin
  GetObject(Canvas.Font.Handle, SizeOf(lf), @lf);
  if lf.lfWidth = 0 then
  begin
    GetTextMetrics(Canvas.Handle, tm);
    lf.lfWidth := -lf.lfHeight * tm.tmAveCharWidth div tm.tmHeight;
    Canvas.Font.Handle := CreateFontIndirect(lf);
  end;
end;

Metafile records Logical Font and Charcter Cell width seperately and
normally, lfWidth of the Logical font = 0. This sometimes cause
strange problems.

--
Takuo Nakamura mailto:nakam...@asahi.email.ne.jp

Other Threads