Re:Fonts On-The-Fly ?
Quote
P.S.Ryan wrote:
> I read recently on one of the Delphi Newsgroups that there was a way of
> adding a font to windows whilst windows is already running.
> Unfortunately, I cannot find the file I saved with the info in it.
> I now need this info for an ongoing project. :-(
> Could anyone help me by re-posting the info, please?
> please send to the list and to Email... our email server is a bit flaky
> sometimes.
> P.S.R...@NOSPAMais.salford.ac.uk
I sent this procedure to another person who was helping me with fonts after
I found the answer in one of my books:
What I did was: I created the following two procedures in the unit of the
main form, which was form1, then from the project file, before the forms
are created, I called the CreateFont procedure and it worked. The font was
usable while the program ran, but it didn't get installed to the user's
machine. You might want to just determine the user's windows\fonts
directory and copy the font files there. Just copying the files there will
install the font to the user's system.
Anyway, here is the code for on-the-fly fonts:
procedure CreateFont;
var
sAppDir: string;
sFontRes: string;
sFont: string;
rc : integer;
begin
sAppDir := ExtractFilePath(Application.ExeName);
sFontRes := sAppDir + 'NOTEPAD_.FOT';
sFont := sAppDir + 'NOTEPAD_.TTF';
if FileExists(sFontRes) and FileExists(sFont) then
begin
rc := integer(CreateScalableFontResource(0,@sFontRes[1], @sFont[1],
nil));
rc := AddFontResource(@sFont[1]);
end;
end;
I hope this is helpful for you.
Brian Richmond
lxbr...@lincolnnet.net
http://www.ecnet.net/users/grichmon