• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
FireInDark

Show me a way to render text than FreeType..

9 posts in this topic

As shown in the topic , I've take a look at FreeType for text rendering in my project.
But it is not so easy to use thus some one has explained some thing of it for me at gamedev..

And just right now I searched out pango and cairo ..
I know nothing about them two except pango can be used to render texts in cairo (ofcuse FT)

Now I just need to rendering texts, get the pixel data and some info about the text's image (such as the position,the width,and the height of every text's bounding box)

I need to render the texts and need select the text by mouse ..

Question :
1.will the pango lib show me the pixels data poingter in memory and tell me the infos I need
2.any other lib for text renering rather than Pango and FreeType..

Any info you can tell is welcom ..thanks.
0

Share this post


Link to post
Share on other sites
You can also use non-monospace fonts with some of those exporters. I've currently been using [url="http://www.angelcode.com/products/bmfont/"]BMFont[/url], which allows you to export the width / height / kerning info for each character, as well as a few more things.

Writing a routine to use this info to blat out strings once you have your font 'texture atlas' is not-super complicated. However, once you start doing line wrapping and justification, and adding more than just the basics it gets a bit more tricky.

If you can bear it though, the effort integrating / learning freetype or similar is probably for the best, unless you want to do it for learning's sake.

On windows, using the latest MS api should give you the best quality, using their '[url="http://en.wikipedia.org/wiki/ClearType"]cleartype[/url]' system, which uses subpixel rendering. Freetype has subpixel rendering turned off by default I believe, to avoid the risks of MS patents.
0

Share this post


Link to post
Share on other sites
OK?
Thanks for all of you two..

If just for using in this project ,I can render text with GDI and FT simply ..
And I can make font bitmap myself.
But for a long time I used to find a way to render text ,it is so important - than any thing in all softwares needing GUI- I must have a right way ..

I've tried to use bitmap fonts ,and also to load TTF and other font files but I can't get how to use the data in those file to render it to text image..
Any help?
0

Share this post


Link to post
Share on other sites
I think both of us replied to this. Like I said, if you read a bit more about text and typography, it will be very helpful for you.

People coming from command-line background think that text is easy (e.g. printf/puts). In fact, it is quite the opposite. Dealing with text can be one of the more complicated things you will have to do. There is the multitude of ways to encode text, and the whole confusion that is called unicode (at least three ways to encode the same thing, really?).

Anyways, what concerns you is how to render text on the screen. You didn't mention neither language, nor graphics API except for GDI. Therefore, I will simply assume you use GDI and C++.

OK, so you can "load" a font. What is a font? Just a bunch of statistics (height, width, etc), mappings, and, overall, describes *how* and *what* to draw. It would be helpful for you to [url="http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08"]understand what True Type fonts are[/url]. On its own, loading a font doesn't enable you to render them.

Now, what you see on the screen is created by a renderer. Roughly speaking, it takes a font description, a sequence of characters, and draws them onto a surface. That surface may be an image. You can specify what is the format of that image. And therefore, you can obtain its pixels.

Since you said you have managed to load a font with GDI (with CreateFont* and SelectObject) rendering it is very simple. All you need to do is call one of the [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162499%28v=vs.85%29.aspx"]text drawing functions[/url]:[list]
[*][url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498%28v=vs.85%29.aspx"]DrawText[/url] or [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162499%28v=vs.85%29.aspx"]DrawTextOut[/url]
[*][url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd145133%28v=vs.85%29.aspx"]TextOut[/url] or [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162713%28v=vs.85%29.aspx"]ExtTextOut[/url]
[/list]
So far as metrics go, you can obtain [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd145132%28v=vs.85%29.aspx"]TEXTMETRIC[/url] via [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd144941%28v=vs.85%29.aspx"]GetTextMetrics[/url]for the currently [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162956%28v=vs.85%29.aspx"]selected font[/url]. The line height is roughly tmHeight + tmExternalLeading. The average character width would be tmAveCharWidth. For a monospace font, it will be OK to just use that metric. If you used proportional font, you will need to get [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162755%28v=vs.85%29.aspx"]OUTLINETEXTMETRIC[/url]via [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd144906%28v=vs.85%29.aspx"]GetOutlineTextMetrics[/url].

In order to get the "pixels" (what for?), you will need to render in memory on a bitmap. You do this by rendering on a [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd183489%28v=vs.85%29.aspx"]compatible[/url]DC, which has [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162957%28v=vs.85%29.aspx"]selected[/url] a [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd183488%28v=vs.85%29.aspx"]compatible bitmap[/url]. When you are done, you should be able to access to the pixels via GetPixel/SetPixel for individual pixels, and to the whole data via [url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd144879%28v=vs.85%29.aspx"]GetDIBits[/url].

And I don't know why you need this at all. If you said what you wanted to do in the first place, it would have been much easier to help.
0

Share this post


Link to post
Share on other sites
[quote name='dilyan_rusev' timestamp='1343492978' post='4964006']
And I don't know why you need this at all. If you said what you wanted to do in the first place, it would have been much easier to help.
[/quote]

It's sunday you know,I gone to fishing ,so I get your reply till now..

So what I meaned by "load font files" is :
We know that there are datas expressing Bezier curve and lines _maybe we can call them out lines ..OK don't consider about hint now.but how should I got the info about Bezier curve and lines ..and ofcause ,there are datas for layouting ....

Yes I want to render text by the font files myself instead of the work by FT..
I know it's a hard work .but I really want to do it my self..
To be honest I can't express my mind accurately in english.But I think you would know what I want to do by words above..

Thanks for your help... Edited by FireInDark
0

Share this post


Link to post
Share on other sites
[quote name='FireInDark' timestamp='1343572044' post='4964254']
Yes I want to render text by the font files myself instead of the work by FT..
I know it's a hard work .but I really want to do it my self..
To be honest I can't express my mind accurately in english.But I think you would know what I want to do by words above..[/quote]Are you really sure? Ok, perhaps you're sure. I hope you know what you're going to do and why. My current approach involves[list=1]
[*][url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd374091(v=vs.85).aspx"]Uniscribe[/url]. Maps char/wchar_t to glyphs and positions.
[*][url="http://www.cs.cmu.edu/~quake/triangle.html"]Triangle library[/url]. Produce triangles out of contours.
[*][url="http://research.microsoft.com/en-us/um/people/cloop/loopblinn05.pdf"]Resolution Independant Curve Rendering using Programmable Graphics Hardware[/url].
[/list]
This gives me a nice "fire and forget" text which, differently from freetype, can be zoomed and transformed without loosing too much detail. It required quite some work (warning) and quality isn't much of a big deal for the time being. Small character text is often a blurry mess. Think about it.
0

Share this post


Link to post
Share on other sites
Using bitmaps for rendering text is the easiest route, as long as you're limiting yourself to the kind of US English used by Jesus when he wrote the bible. Anything else, and you better brush up on typography. Trying to create a bitmap to support every single Unicode codepoint and being able to handle the metrics of combined characters and right-to-left or vertical scripts will reduce your productivity a bit. Add in multiple typefaces, pointsizes, and slant for added kerning fun.

The only library I've ever seen that comes close to doing proper typography is pango.
0

Share this post


Link to post
Share on other sites
Thank you very much ..
Replies above are helpful for me .
Text rendering is a hard work,I need to study about it for a long time .Then I can decide.

[quote name='Krohm' timestamp='1343634093' post='4964411']
This gives me a nice "fire and forget" text which, differently from freetype, can be zoomed and transformed without loosing too much detail. It required quite some work (warning) and quality isn't much of a big deal for the time being. Small character text is often a blurry mess. Think about it.
[/quote]

Infact ,I can draw images no matter with CPU or GPU ,no matter GLSL shaders or OpenCL .
If I know the path to draw pixels I can do it..
But now,the hardest for me is how to get the "path data" in font files..
Yes I know the inofmation in fonts files expresses where to draw pixels ,so want I want is getting the right infos ..

Such a charactor "A" there're infomation express the out lines if it in a font file ..

typedef struct _CharRenderingInfo
{
//what we need ?
}CharReneringInfo;

typedef unsigned int uint;
int getTextImage(wchar_t charactor,unsigned char font_size,char* font_file_path,char* out_bit_buffer,uint out_width,uint out_height)
{
fstream file(font_file_path);//First we open the font files .
//OK now we should find the right info data from the file.But :HOW
//We need a struct to express the need info for this our "A"
CharRenderingInfo CRINFO = findInfoFromFontFile(file);//how?
//Here we can render it by the CRINFO

}
If you know any links can explain the data structs in TTF files ,that'll be kind.. Edited by FireInDark
0

Share this post


Link to post
Share on other sites
[quote name='Bregma' timestamp='1343635287' post='4964415']
The only library I've ever seen that comes close to doing proper typography is pango.
[/quote]

I do have took a look at pango,and tried to use it but there are some problems when compile it.
AND that
"Client side fonts using the FreeType and fontconfig libraries. Rendering can be with with Cairo or Xft libraries, or directly to an in-memory buffer with no additional libraries.
Native fonts on Microsoft Windows using Uniscribe for complex-text handling. Rendering can be done via Cairo or directly using the native Win32 API.
Native fonts on MacOS X using ATSUI for complex-text handling, rendering via Cairo.
"

Cause words above I think it's not the right what I want..

Thank you ..
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0