Použitie vlastného fontu
Použitie vlastného fontu v aplikácii bez nutnosti nainštalovať ho do systému.
var sAppDir: string; bLoadedFont: boolean; procedure TForm1.FormCreate(Sender: TObject); var sFontRes, sFont: string; begin sAppDir:=ExtractFileDir(Application.ExeName); sFontRes:=sAppDir+'MYFONT.FOT'; if not FileExists(sFontRes) then begin sFontRes:=sFontRes+#0; sFont:=sAppDir+'MYFONT.TTF'+#0; CreateScalableFontResource(0, @sFontRes[1], @sFont[1], nil); end; sFontRes:=sAppDir+'MYFONT.FOT'; if FileExists(sFontRes) then begin sFontRes:=sFontRes+#0; if AddFontResource(@sFontRes[1])=0 then bLoadedFont:=False else begin bLoadedFont:=True; SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); end; end; end; procedure TForm1.FormDestroy(Sender: TObject); var sFontRes: string; begin if bLoadedFont then begin sFontRes:=sAppDir+'MYFONT.FOT'+#0; RemoveFontResource(@sFontRes[1]); SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); end; end;