开发者

Platform independent way to locate fonts

I'm working on a multi-platform application in C where I need to load开发者_如何学Go fonts from disk and render messages with FreeType. However, I currently use full paths for locating fonts, and it's somewhat awkward to ask users for the full path of fonts since they are generally buried deep into system folders.

Is there a simple, platform-idependent way of just locating fonts? E.g. I can expect users to be able to provide something like "Sans" and have a library or something locate the full path of this font for me. I'm aware of the existence of fontconfig, but I found it quite hard to go through the documentation for it.

Clarification: This is a CLI driven application, which is configured through a config file.


As far as I am aware, fontconfig is the way. Keep at the docs, and find some tutorials. This pdf, while a little old, gives a very nice overview of how fontconfig does its amazingly useful job.


The only way you could get that information in a platform-independent way is to have a cross-platform package that conceals the differences from you. It would provide you with a platform-neutral interface and would itself deal with the complexities of each platform.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜