加载自定义的True Type字体 [英] Loading a custom True Type font

查看:281
本文介绍了加载自定义的True Type字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac Firemonkey应用程序(Delphi XE7)中,如何加载自定义的TrueType字体?

对于Windows,我的应用程序的安装程序会将我的字体添加到Windows本身.

解决方案

到目前为止,我已经使用FPC/Lazarus完成了此操作,但到目前为止尚未使用Delphi完成此操作.您只需要做两件事(即使有多种自定义字体,它也可以工作):

1)将自定义字体位置添加到info.plist(它指向Resources文件夹):

<key>ATSApplicationFontsPath</key>
    <string>Fonts</string>

2)将字体添加到应用程序束中的指定位置: \ Contents \ Resources \ Fonts

将这两个任务转换为Delphi XE7,将是:

1)转到项目选项,然后选择版本信息",并将目标设置为所有配置-OS X平台".右键单击键列表,然后选择添加键.然后添加值为"Fonts"的ATSApplicationFontsPath

2)转到项目">部署"页面,然后添加自定义字体.指定它们现在在Windows计算机上的位置,并将远程路径"设置为"Contents \ Resources \ Fonts".

现在,当您运行该程序时,字体"文件夹中的所有字体将由OS X自动加载,您可以从该程序中选择字体.

通知:您在Delphi代码中指定的字体名称不是文件名,而是在字体文件中指定的字体标题(尽管通常是相同的名称).

In a Mac Firemonkey app (Delphi XE7) how do I load my custom TrueType font?

For Windows, my app's installer adds my font to Windows itself.

解决方案

I have done this with FPC/Lazarus, but not with Delphi so far. You only need to do two things (it works even if you have multiple custom fonts):

1) Add the custom font location to info.plist (it refers to the Resources folder):

<key>ATSApplicationFontsPath</key>
    <string>Fonts</string>

2) Add the font(s) to the application bundle in the specified location: \Contents\Resources\Fonts

Translating these two tasks to Delphi XE7, it will be:

1) Go to Project options and choose "Version Info" and set target to "All configurations - OS X platform". Right-click in the list of keys and choose Add key. Then add ATSApplicationFontsPath with the value "Fonts"

2) Go to the Project > Deployment page and add the custom font(s). Specify the location where they are now on your Windows computer and set the Remote Path to "Contents\Resources\Fonts".

Now all fonts in the "Fonts" folder will be loaded automatically by OS X when you run the program and you can choose your font from the program.

Notice: the font name you specify in your Delphi code is NOT the file name, but the title of the font as specified inside the font file (often it the same name though).

这篇关于加载自定义的True Type字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆