Koushik Halder
Koushik Halder

Reputation: 455

Delphi Font Resource

I have an application having with one TTF resource as "Font" included. I wish to use this font as Fomr Font on FormCreate event. I am not willing to extract this font to a directory and load from there. I am unable to this please help me. I am learner please do not ask for my codes.

I have used "Font Resource ID 13" and "Font Name AmarBangla.ttf". I have tried the following codes but gerting error. Here is those codes:

First One :

procedure TForm01.FormCreate(Sender: TObject);
 begin
    Form01.font[13] := AddFontResource (LPCTSTR lpszFontName));
    Form01.font := 13;
end;

Second One :

 procedure TForm01.FormCreate(Sender: TObject);
 begin
    Form01.font[13] := AddFontResource (Hinstance, MakeIntResource(13));
    Form01.font := 13;
 end;

Upvotes: 0

Views: 2499

Answers (1)

user160694
user160694

Reputation:

The AddFontMemResourceEx function could help you, but it looks like Microsoft forbids embedding their fonts into applications if it violates the license of the font:

An application cannot be distributed along with documents that contain embedded fonts, nor can an application itself contain an embedded font.

Font embedding may violate copyrights. You first need a font that allows for redistribution, and then you will need to install it on the target system along with your application. Moreover, the font's properties will tell you if they allow for embedding.

Upvotes: 6

Related Questions