Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-08

TFreeTypeFont

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

hello,

I am using TFreeTypeFont to draw text to TLazIntfImage and it seams that it just draws char by char, without spacing them according to their sizes.

Anyone else using TFreeTypeFont?

thanks,

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Felipe Monteiro de Carvalho

Umm ... strange ... in the code it doesn't seam to draw them according to the width, but in my test some chars are drawn near and some are drawn far ...

Here is my code:

      // Now draw the avatar nickname and it's inplay amount
      try
        // initialize free type font manager
        ftfont.InitEngine;
        Str := GetSkins().GetFontPath();
        FontMgr.SearchPath := Str;
        AFont := TFreeTypeFont.Create;
        // create the canvas with the drawing operations
        ImgCanvas:=TFPImageCanvas.create(AIntfImage);
        // paint text
        ImgCanvas.Font:=AFont;
        ImgCanvas.Font.FPColor := colYellow;
        ImgCanvas.Font.Name := 'ARIALN';
        ImgCanvas.Font.Size := 10;
        lNickName := FModel^.Seats[i].Avatar.NickName;
        lTextWidth := AFont.GetTextWidth(lNickName);
        lTextPosX := lPos.X + (Image.Width div 2) - lTextWidth div 2;
        ImgCanvas.TextOut(lTextPosX, lPos.Y + 20, lNickName);
        lInplayAmount := FModel^.Seats[i].Avatar.InplayAmount;
        lTextWidth := AFont.GetTextWidth(lInplayAmount);
        lTextPosX := lPos.X + (Image.Width div 2) - lTextWidth div 2;
        ImgCanvas.TextOut(lTextPosX, lPos.Y + 35, lInplayAmount);
      finally
        if AFont  nil then AFont.Free;
        if ImgCanvas  nil then ImgCanvas.Free;
      end;

It should just draw "alfa" and "beta", there should be no such spaces.

Felipe Monteiro de Carvalho

Reply by email