[fpc-devel] Re: TFreeTypeFont
Felipe Monteiro de Carvalho
felipemonteiro.carvalho at gmail.com
Tue Aug 10 17:00:42 CEST 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetype_char_spacing.PNG
Type: image/png
Size: 1856 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20100810/8bee4f37/attachment.png>
More information about the fpc-devel
mailing list