Delphi 字体资源
我有一个应用程序,其中包含一个 TTF 资源作为“字体”。我希望在 FormCreate 事件中使用此字体作为 Fomr 字体。我不愿意将此字体提取到目录并从那里加载。我无法做到这一点,请帮助我。我是学习者,请不要询问我的代码。
我使用了“字体资源 ID 13”和“字体名称 AmarBangla.ttf”。我已尝试以下代码,但出现错误。这是这些代码:
第一个:
procedure TForm01.FormCreate(Sender: TObject);
begin
Form01.font[13] := AddFontResource (LPCTSTR lpszFontName));
Form01.font := 13;
end;
第二个:
procedure TForm01.FormCreate(Sender: TObject);
begin
Form01.font[13] := AddFontResource (Hinstance, MakeIntResource(13));
Form01.font := 13;
end;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AddFontMemResourceEx
函数可以帮助你,但它看起来像 如果违反字体许可,微软将禁止将其字体嵌入到应用程序中:字体嵌入可能会侵犯版权。您首先需要一种允许重新分发的字体,然后需要将其与应用程序一起安装在目标系统上。此外,字体的属性会告诉您它们是否允许嵌入。
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: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.