Arsip: Include Font with exe
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:
more 18 years ago
Starboard
weheheh... kalo itu kan cara standar windows om :D
maksudku biar manfaatin delphi dikit pake resource nya :) wehehehh
more 18 years ago
amyra
coba yang ini...
.......
MyResstream.savetofile('C:\fontku\gen4.ttf');
AddFontResource(PChar('C:\fontku\gen4.ttf'));
.......
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
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
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
reply |
Report Obsolete
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- cross tab tanggal
by delphi1st in Tip n Trik Pemrograman more 17 years ago - About Databse using TQuery?
by mohawk in MySQL more 19 years ago - about TLCDLabel.....
by ImanD in Tip n Trik Pemrograman more 17 years ago - Tanya, cara untuk mencari data?
by denih in Hal umum tentang Pascal Indonesia more 18 years ago - Setup Dependencies.
by langithitam in Tip n Trik Pemrograman more 17 years ago - Error buka form
by idhiel in MySQL more 12 years ago - My Free Component
by Starboard in Hal umum tentang Pascal Indonesia more 19 years ago - Nanya buat program faktorial di Delphi...?
by denih in Hal umum tentang Pascal Indonesia more 18 years ago - deteksi paper
by asiyrob in Tip n Trik Pemrograman more 17 years ago - sortir data di tabel DSQLTable
by mas_kofa in Hal umum tentang Pascal Indonesia more 18 years ago