C语言中的TrueType字体解析 [英] TrueType Font Parsing in C

查看:434
本文介绍了C语言中的TrueType字体解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想阅读ttf并在缓冲区上绘制带有该字体的文本.即使有诸如freetype,gd之类的库来执行此任务,我仍要编写自己的代码.您能建议我如何完成这项任务吗?

I want to read a ttf and draw a text with that font on a buffer. Even though there are libraries such as freetype, gd to do this task, I want to write my own code. Can you advice me on how to accomplish this task?

推荐答案

除非您是字体,排版和书写系统的全球顶尖专家,否则答案很简单:不要 >. TrueType/OpenType有很多表需要您支持,以便正确渲染,即使使用FreeType(这是一个非常低级的库),大多数人也会弄错它.

Unless you're one of the world's top experts on fonts, typography, and writing systems, the answer is simple: DON'T. TrueType/OpenType has a lot of tables you need to support for correct rendering, and even when using FreeType (which is an extremely low-level library), most people get it wrong.

如果需要进行低级,确定性跨平台字体处理,则至少应使用FreeType和libotf.这将为您提供对字形和轮廓的访问,然后您可以根据自己的喜好进行渲染.在大多数情况下,尽管使用GUI系统的文本呈现例程将更加容易,而且不易出错.

If you need to do low-level, deterministic-across-platforms font handling, then at the very least, you should be using FreeType and libotf. This will provide you with access to the glyphs and outlines which you can then render however you like. In most cases though using your GUI system's text rendering routines will be a lot easier and less error-prone.

最后,如果您坚持不理我的建议,那么在FreeType上有一个不错的RTFS和Microsoft的在线资源,它们以TrueType/OpenType字体解释了这些表,可能是上手的最佳位置.

Finally, if you insist on ignoring my advice, a good RTFS on FreeType and Microsoft's online resources explaining the tables in TrueType/OpenType fonts are probably the best place to get started.

这篇关于C语言中的TrueType字体解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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