3

I want to write a hardware accelerated text renderer using Free Type 2 to load the fonts, find the correct glyphs and their sizes etc.

My plan to do this is to have a large texture containing glyphs (for a given font,size,etc) in video memory, and a table for each texture defining information about the contents of the texture in system memory.

I can then use the table to build a vertex buffer to render the text.

The problem I'm facing is the construction of the texture, it is not practical to create a texture for every glyph in Unicode, there just too many. For Ascii in the past I just built the texture in an image editor and then filled out the table as needed myself in advance, however for this I will need some kind of dynamic system that will get the glyphs needed, but also efficently cache them to avoid repeated uploads of the same glyph to vram...(some sort of least commonly used system I guess)

Another problem is not all glyphs are the same size, I could split the texture up into a grid big enough for the largest glyphs (which I need some way to accurately work out) which makes fitting the glyphs onto the texture easy and replacing them with new glyphs (based on the least commonly used or something), however that leaves a lot of wasted space, but i'm not sure how to more efficiently pack them without running into problems with fragmentation as glyphs are swaped in and out...

Also I assume updating the texture could stall the graphics hardware if the texture is still being used for some previous text, is this a correct assumption and how can I avoid it if its the case?

4

2 回答 2

3

文本渲染是一个非常复杂的问题,然后“粘贴”一些字形......不仅非常复杂,而且非常复杂:字距调整、连字、间距、双向文本、元音等等......

为什么不使用像 Pango 这样的用于文本渲染的普通库创建文本,创建位图并将其显示为 3D 对象上的位图(如果我了解您的需要)。

编辑:类似标记的简单 HTML 也可以用 Pango 呈现:http: //library.gnome.org/devel/pango/unstable/PangoMarkupFormat.html

于 2009-07-27T10:53:34.377 回答
1

Cairo支持对多种表面类型进行硬件加速渲染

有一个名为FontForge的库正在使用 Cairo 进行渲染,但我自己没有尝试过。你应该检查一下,让我知道它是怎么回事:-)

于 2011-07-26T13:00:27.553 回答