什么是渲染复杂字体的最佳选择?

时间:2022-04-11 20:23:12

I'm working on a game (using Ruby) and planning to have it available in several languages. I was wondering what's the best option for rendering text. In particular, whatever I use should be able to render complex fonts (Arabic and Persian in particular).

我正在开发一个游戏(使用Ruby)并计划以多种语言提供它。我想知道什么是渲染文本的最佳选择。特别是,无论我使用什么,都应该能够渲染复杂的字体(特别是阿拉伯语和波斯语)。

I've been looking around and have stumbled upon freetype, graphite, and using windows native api functions (I'm fine with it being not cross-platform) to name a few. What should I go with and what are the different trade-offs?

我一直在环顾四周,偶然发现了freetype,石墨,以及使用windows native api函数(我很好,因为它不是跨平台的),仅举几例。我该怎么做,有什么不同的权衡取舍?

3 个解决方案

#1


1  

If you're looking for a way to rasterise fonts into bitmaps, both Freetype and the Windows API will handle this nicely.

如果您正在寻找一种将字体光栅化为位图的方法,那么Freetype和Windows API都可以很好地处理这个问题。

If you're looking for a way to draw text onscreen, go with Window's native APIs if you can; bidirectional text and accents and all that stuff are quite difficult and time-consuming to get right, so you ideally want an API that handles it for you. Whether or not this is viable for your game depends on what graphics APIs you're using, which you didn't specify.

如果您正在寻找一种在屏幕上绘制文本的方法,请尽可能使用Window的本机API;双向文本和重音以及所有这些内容非常困难且耗时,因此您理想地需要一个能够为您处理它的API。这是否适合您的游戏取决于您使用的图形API,您没有指定。

Edit: To rasterise entire strings of text, you need to use win32's DrawText, which means you need to get your hands slightly dirty.

编辑:要光栅化整个文本字符串,您需要使用win32的DrawText,这意味着您需要稍微弄脏手。

#2


2  

For a cross platform solution, check out Pango.

对于跨平台解决方案,请查看Pango。

#3


1  

Check out www.freetype.org It handles non-left-to-right fonts. It generates the glyphs for you, but you must render them to the device (OpenGL/DirectX, etc).

查看www.freetype.org它处理非从左到右的字体。它会为您生成字形,但您必须将它们渲染到设备(OpenGL / DirectX等)。

#1


1  

If you're looking for a way to rasterise fonts into bitmaps, both Freetype and the Windows API will handle this nicely.

如果您正在寻找一种将字体光栅化为位图的方法,那么Freetype和Windows API都可以很好地处理这个问题。

If you're looking for a way to draw text onscreen, go with Window's native APIs if you can; bidirectional text and accents and all that stuff are quite difficult and time-consuming to get right, so you ideally want an API that handles it for you. Whether or not this is viable for your game depends on what graphics APIs you're using, which you didn't specify.

如果您正在寻找一种在屏幕上绘制文本的方法,请尽可能使用Window的本机API;双向文本和重音以及所有这些内容非常困难且耗时,因此您理想地需要一个能够为您处理它的API。这是否适合您的游戏取决于您使用的图形API,您没有指定。

Edit: To rasterise entire strings of text, you need to use win32's DrawText, which means you need to get your hands slightly dirty.

编辑:要光栅化整个文本字符串,您需要使用win32的DrawText,这意味着您需要稍微弄脏手。

#2


2  

For a cross platform solution, check out Pango.

对于跨平台解决方案,请查看Pango。

#3


1  

Check out www.freetype.org It handles non-left-to-right fonts. It generates the glyphs for you, but you must render them to the device (OpenGL/DirectX, etc).

查看www.freetype.org它处理非从左到右的字体。它会为您生成字形,但您必须将它们渲染到设备(OpenGL / DirectX等)。