🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Draw a text

Started by
8 comments, last by yaronct 7 years, 11 months ago

Hello,

I have my own game engine written in C++, I'm looking for an APi or an external library that allows me to write a lot of text on specific scenes of my game.

The DrawText API looks just horrible, I could use bitmaps, but.... meh.

Any suggestions? Portability is not a concern.

Thanks in advance.

Advertisement
HarfBuzz with cairo is one way to go. HarfBuzz will shape the text with a very high quality, including ligatures. For purely English texts with most fonts it is likely to be completely overkill though. Just the FreeType text rendering functions will probably be good enough. That still leaves significant parts of the layout work in your hands though. I have also heard good things of Pango but never used it myself.

HarfBuzz with cairo is one way to go. HarfBuzz will shape the text with a very high quality, including ligatures. For purely English texts with most fonts it is likely to be completely overkill though. Just the FreeType text rendering functions will probably be good enough. That still leaves significant parts of the layout work in your hands though. I have also heard good things of Pango but never used it myself.

Sorry, either I don't get it or I haven't explained myself enough.

I'm using DirectX, and what I need is: after rendering my whole game scene, I need something that renderers text on top of my rendered geometries, models, textures or whatever.

I don't get what are those libraries doing, could you explain further please?

They render (or assist in preparing to render) text into some form of image buffer which you then can upload to a texture and use in a suitable way for your scene. Either by using them to render your objects or in some kind UI overlay.

Could the DirectWrite API get the job done for you? It can use Direct2D internally to take advantage of hardware acceleration. You can cache the rendered text to a texture if performance is a concern, as BitMaster have already suggested.

I could use bitmaps, but.... meh.

Using bitmaps to store font glyphs has another disadvantage - most of the popular fonts are copyrighted, so distributing them in any form without an explicit permission can lead to legal issues, unless I am mistaken.

HarfBuzz with cairo is one way to go. HarfBuzz will shape the text with a very high quality, including ligatures. For purely English texts with most fonts it is likely to be completely overkill though. Just the FreeType text rendering functions will probably be good enough. That still leaves significant parts of the layout work in your hands though. I have also heard good things of Pango but never used it myself.

Sorry, either I don't get it or I haven't explained myself enough.

I'm using DirectX, and what I need is: after rendering my whole game scene, I need something that renderers text on top of my rendered geometries, models, textures or whatever.

I don't get what are those libraries doing, could you explain further please?

Harfbuzz is opentype shaping engine, which basically it takes your string then return a list of glyph index along with the position they should be. Pango is text layout engine, which would do things like justification (left, mid, right) or breaking lines for you. FreeType is Rendering engine that takes font and glyph index and return the bitmap that you can use to render to texture and such.

I haven't tried Pango myself though.... it looks too heavyweight to me.

If you're using DirectX, however, as mentioned by @vanka78bg you should use DirectWrite API instead of those libraries (I believe it covers almost all functions provided by those 3 lib).

Could the DirectWrite API get the job done for you? It can use Direct2D internally to take advantage of hardware acceleration. You can cache the rendered text to a texture if performance is a concern, as BitMaster have already suggested.

I could use bitmaps, but.... meh.

Using bitmaps to store font glyphs has another disadvantage - most of the popular fonts are copyrighted, so distributing them in any form without an explicit permission can lead to legal issues, unless I am mistaken.

One major disadvantage of bitmap fonts is, internationalization is a pain. I mean imagine how many CJK characters there are. Of cause if you don't care about this then it would be ok for you.

Personally I'd use SIL Open Font License (OFL) fonts as it permit all kind of uses if I don't dissect them. Many of them are surprisingly good.

http://9tawan.net/en/

(Sorry for late reply).

I've found this library: http://fw1.codeplex.com what about it? Anyone knows it?

Raqm seems to b an attempt to take care of everything for u. Haven't tried it though.

(Sorry for late reply).

I've found this library: http://fw1.codeplex.com what about it? Anyone knows it?


The first thing I notice when I look at that is the complete absence of anything like license information. Sure, for my own personal use I could probably use it but why go through the trouble of binding to a library which I would have to replace as soon as I wan to distribute my program in any way...

Of course, u could also use a GUI library, although if used just for text it's a bit overkill..

This topic is closed to new replies.

Advertisement