Arsip: Include Font with exe
more 19 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 19 years ago
Starboard
weheheh... kalo itu kan cara standar windows om :D
maksudku biar manfaatin delphi dikit pake resource nya :) wehehehh
more 19 years ago
amyra
coba yang ini...
.......
MyResstream.savetofile('C:\fontku\gen4.ttf');
AddFontResource(PChar('C:\fontku\gen4.ttf'));
.......
more 19 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 19 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 19 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
AI Forward
🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now:
https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 5 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 5 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 5 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 5 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 5 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 5 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 13 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 13 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 13 years ago
Random Topic
- aplikasi hemat memory
by dinox in OOT more 19 years ago - Bikin autorun program buat flasdisk?
by ianhade in Network, Files, I/O & System more 18 years ago - Bikin Kamus IT pake delphi ?
by hydenisama in Tip n Trik Pemrograman more 17 years ago - buka aplikasi delphi lewat web
by farhan_port in Hal umum tentang Pascal Indonesia more 18 years ago - dari Pascal ke Java
by simba in Enginering more 18 years ago - Aplikasi delphi berhubungan dengan nomor rekening
by boediman in Tip n Trik Pemrograman more 17 years ago - Sintaq SQL Sum dari Sum?
by adit4it in Paradox more 18 years ago - Pembayaran International - Paypal
by DelphiExpert in OOT more 18 years ago - [ask] Tentang penggunaan keybord atau key gan
by kepiss in Tutorial & Community Project more 13 years ago - model di client warnet
by lekmo in Tip n Trik Pemrograman more 18 years ago
