Jump to content
  • Advertisement
Sign in to follow this  
Deathlike

Draw a text

This topic is 729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by Deathlike

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Edited by vanka78bg

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

(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...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!