Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(Font usage) How to proceed?

Status
Not open for further replies.

dex1123

Programmer
May 9, 2000
35
BG
Hello to you!<br><br>I've already posted a question on this topic but I got stuck again. Here's my code:<br><br>CreateScalableFontResource(0, PChar('c:\Windows\System\trn.fot'), PChar('c:\windows\System\trn.ttf'), nil);<br>AddFontResource(PChar('c:\Windows\System\trn.fot'));<br>SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);<br><br>I am trying to make trn.ttf work from within my own program directory. CreateScalableFontResource works. It really creates the .fot file but I can't work out why AddFontResource does nothing or it does something but I can't figure out how to use the font. If this code is OK, could you, please, give me an example of how to make use of the font after these lines have been executed. Thank you!
 
Hi!<br>Try this code ( I have Delphi4 sp3):<br>only problem is : font dont removes immediately.<br><br>function EnumFontsProc( lplf:pLOGFONT;lptm: PTEXTMETRIC;dwType:dword;lpData:pointer ):integer; stdcall;<br>begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TStrings(lpData).Add(lplf.lfFaceName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result:=1;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var s:AnsiString;<br>&nbsp;&nbsp;&nbsp;&nbsp;sdc: HDC;<br>begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CreateScalableFontResource(0,'c:\windows\fonts\mssong.fot','c:\mssong.ttf',nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AddFontResource('c:\windows\fonts\mssong.fot');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ListBox1.Items.Clear;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sdc:=GetDC(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EnumFonts(sdc,nil,@EnumFontsProc,pointer(ListBox1.Items));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReleaseDC(0,sdc);<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RemoveFontResource('c:\windows\fonts\mssong.fot');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var sdc: HDC;<br>begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sdc:=GetDC(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EnumFonts(sdc,nil,@EnumFontsProc,pointer(ListBox1.Items));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReleaseDC(0,sdc);<br>end;<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top