• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

TTF File to TFont.

Is there any way to create a TFont variable, using some
system un-installed TTF file? I mean, i want to supply some fonts with my software, yet i don't want to install them... Any ideas?
0
fulg0re
Asked:
fulg0re
  • 2
1 Solution
 
fulg0reAuthor Commented:
listening...
0
 
rwilson032697Commented:
I think this should do - it installs the font dynamically...

{Font loading and unloading function.}
function LoadFont(sFontFileName: string; bLoadIt: boolean): boolean;
var
sFont, sAppDir, sFontRes: string;
begin
result := TRUE;

if bLoadIt then
begin
{Load the font.}
if FileExists( sFontFileName ) then
begin
sFontRes := sFontFileName + #0;
if AddFontResource( @sFontRes[ 1 ] ) = 0 then
result := FALSE
else
SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );
end;
end
else
begin
{Unload the font.}
sFontRes := sFontFileName + #0;
result := RemoveFontResource( @sFontRes[1] );
SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0 );
end;
end; {LoadFont}

And no, you can't otherwise create a TFont from a TTF file.

Cheers,

Raymond.
0
 
fulg0reAuthor Commented:
welp 10x, but i guess it's not what i looked for...
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now