Loading a custom True Type font

只谈情不闲聊 提交于 2019-12-02 10:08:05

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/28996039/loading-a-custom-true-type-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!