Created
January 12, 2016 17:38
-
-
Save helix84/f4f3e388a10cf04a0fe2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
procedure ShowText(Canvas: TCanvas; Text: string) | |
var | |
LogFont: TLogFont; | |
begin | |
GetObject(Canvas.Font.Handle, SizeOf(LogFont), Addr(LogFont)); | |
with LogFont do | |
begin | |
lfQuality := ANTIALIASED_QUALITY; | |
lfOutPrecision := Out_TT_Only_Precis; | |
end; | |
Canvas.Font.Handle := CreateFontIndirect(LogFont); | |
end; | |
function GetTextWidth(Canvasowner: TForm; Text: string; TextFint: TFont): integer; | |
var OldFont: TFont; | |
begin | |
OldFont := TFont.Create; | |
try | |
OldFont.Assign(CanvasOwner.Font); | |
CanvasOwner.Font.Assign(TextFont); | |
Result := CanvasOwner.Font.TextWidth(Text); | |
CanvasOwner.Font.Assign(OldFont); | |
finally | |
OldFont.Free; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment