Arsip: Include Font with exe

 
user image
more 18 years ago

Starboard

:shock: aku mau bikin aplikasi yang membutuhkan font yang bukan standar windows (maksudnya biar sedikit aneh dan bikin unik) aku masukan font itu ke resource setelah aku contack paman google aku dapet artikel yang memberikan tips spt ini Include font from from a resource file You should include {$R MyNewFont.RES} line to the implementation section. For causing from a resource font is necessary to create an object of TResorceStream type and to add font with AddFontResource procedure. And for including font you should use the WM_FONTCHANGE message. There is a 'MYFONT' section which contents a font file in the resource file .

{$R MyNewFont.RES}
...
procedure TForm1.FormCreate(Sender: TObject);
var
  MyResStream: TResourceStream;
begin
  MyResStream:=TResourceStream.Create(hInstance, 'MYFONT', RT_RCDATA);
  MyResStream.SavetoFile('Gen4.ttf');
  AddFontResource(PChar('Gen4.ttf'));
  SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
  Label1.Font.Charset:=SYMBOL_CHARSET;
  Label1.Font.Size:=24;
  Label1.Font.Name:='Gen4';
end;
kok aku coba gak berhasil ya?? :shock: aku dah buat resource nya, dah bisa di panggil, dan di kenal. tp kok fonnta gak bisa nampil. :roll:
user image
more 18 years ago

deLogic

gimana kalo font-nya di-copy ke folder-nya windows\fonts ?
user image
more 18 years ago

Starboard

weheheh... kalo itu kan cara standar windows om :D maksudku biar manfaatin delphi dikit pake resource nya :) wehehehh
user image
more 18 years ago

amyra

coba yang ini... ....... MyResstream.savetofile('C:\fontku\gen4.ttf'); AddFontResource(PChar('C:\fontku\gen4.ttf')); .......
user image
more 18 years ago

Starboard

hmmmm oke oke.. kok tetep gak bisa ya?? apa aku yang salah buat resource nya bener gak misal nama file myres.rc di dalemnya myres RCDATA c:\digit.ttf trus aku brcc32 myres.res
user image
more 18 years ago

xerion

mungkin letak file-nya harus jelas ... var AppPath : string; {$R MyNewFont.RES} ... procedure TForm1.FormCreate(Sender: TObject); var MyResStream: TResourceStream; begin AppPath := extractfilepath(application.exename); MyResStream:=TResourceStream.Create(hInstance, 'MYFONT', RT_RCDATA); MyResStream.SavetoFile(AppPath+'Gen4.ttf'); AddFontResource(PChar(AppPath+'Gen4.ttf')); SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0); Label1.Font.Charset:=SYMBOL_CHARSET; Label1.Font.Size:=24; Label1.Font.Name:='Gen4'; end; mungkin. saya belum pernah make font sendiri
user image
more 18 years ago

xerion

adakah ini membantu ... Use TTF without installing Here's how to use a TTF (true type) font in your application without having to install it in Windows: {First load it in the OnCreate event of a form): procedure TForm1.FormCreate(Sender: TObject) ; begin AddFontResource('c:\FONTS\MyFont.TTF') ; SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ; end; {Before application terminates we must free it:} procedure TForm1.FormClose (Sender: TObject; var Action: TCloseAction) ; begin RemoveFontResource('C:\FONTS\MyFont.TTF') ; SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ; end;
more ...
  • Pages:
  • 1
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com