LCL-CustomDrawn: Makes non-native ExtTextOut more resistent against the lack of a selected font

git-svn-id: trunk@35695 -
This commit is contained in:
sekelsenmat 2012-03-03 21:24:13 +00:00
parent 7bee287eb2
commit fdb5d3a508

View File

@ -2175,6 +2175,8 @@ var
FTDrawer: TIntfFreeTypeDrawer;
ftFont: TFreeTypeFont;
RealX, RealY: Integer;
FreeFTFont: Boolean = false;
lLogFont: TLogFont;
begin
{$ifdef VerboseCDText}
DebugLn(Format(':>[WinAPI ExtTextOut] DC=%x Str=%s X=%d Y=%d',
@ -2200,11 +2202,21 @@ begin
FTDrawer := TIntfFreeTypeDrawer.Create(lDestIntfImage);
ftFont := TFreeTypeFont(lDestCanvas.ExtraFontData);
if ftFont = nil then
begin
ftFont := TFreeTypeFont.Create;
ftFont.Name := BackendGetFontPath(lLogFont, '');
ftFont.Hinted := true;
ftFont.ClearType := true;
ftFont.Quality := grqHighQuality;
FreeFTFont := True;
end;
try
RealX := X + lDestCanvas.WindowOrg.X + lDestCanvas.BaseWindowOrg.X;
RealY := Y + lDestCanvas.WindowOrg.Y + lDestCanvas.BaseWindowOrg.Y + lFontSize;
FTDrawer.DrawText(Str, ftFont, RealX, RealY, colBlack, 255);
finally
if FreeFTFont then ftFont.Free;
FTDrawer.Free;
end;