How to render text documents with SDL_TTF? |
How to render text documents with SDL_TTF? |
javierecf
|
If you dont want to create a text editor, like editing and selecting, only display, you can keep the different fonts on a separate array and split the char* text of the whole thing according to its style, and then apply every font to each chunk of strings. You will need some kind of word wraper algorithm to go along this thing that works with the sizes of the surfaces that are gonna be rendered, you are talking about a RichText entitie. No sure what else to say.
2014-05-22 14:09 GMT-06:00 akastargazer:
-- Javier Flores |
|||||||||||||
|
Re: How to render text documents with SDL_TTF? |
akastargazer
|
|
|||||||||||||
|
How to render text documents with SDL_TTF? |
javierecf
|
Maybe the best will be to use bitmap files for the fonts and selecting each glyph from the image according the the words and its style.
2014-05-22 14:32 GMT-06:00 akastargazer:
-- Javier Flores |
|||||||||||||
|
How to render text documents with SDL_TTF? |
Juan Manuel Borges Caño
Guest
|
I wonder what is the status or worth working on, SDL_rtf Rich Text Format :-).
|
|||||||||||
|
mr_tawan
|
I think it's probably easier to go straigh to use freetype with SDL, rather than using SDL_ttf.
|
|||||||||||
|
How to render text documents with SDL_TTF? |
Jeffrey Carpenter
Guest
|
Hi there,
SDL_TTF is certainly powerful enough, and can be thought of as a lightweight wrapper for the FreeType2 API. If you can get away with simply caching every font used in the text document, I'd say that you can call it good there, but in any regard, the answer is yes to caching (loading) the fonts ahead of time. For high performance text rendering, you could create a texture atlas (think: sprite sheet) composed of every glyph in the font(s) loaded, and render text strings from the coordinates of the texture atlas. The performance is great (hundreds of FPS), and the only time that you incur performance hits is when the font's point size (text size) is changed -- you must regenerate the glyph atlas, but you can cache this, too, if necessary. (I don't since I can get away with it). Changing the font's style (bold, italics, underlined) can also incur a small performance penalty, but these can be cached as well. For an example of using SDL_TTF for generating a texture atlas, check out: 1. https://github.com/i8degrees/nomlib/blob/dev/src/graphics/fonts/TrueTypeFont.cpp#L229 2. https://github.com/i8degrees/nomlib/blob/dev/src/graphics/Text.cpp#L402 I wish you luck! :-) Cheers, Jeffrey Carpenter On 2014/05/ 22, at 15:09, akastargazer wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
How to render text documents with SDL_TTF? |
Leonardo
|
Hi. You said that you have wrapping algortihms in place already, but you may want to consider the _Wrapped versions of the usual TTF render calls. They return a single surface. Those methods are not on the docs (I wonder when they'll be documented
Creating a texture atlas of the glyphs may not be what you want if you're creating a text editor because there is a lot going on that is handled by freetype (and hence by SDL_ttf), such as hinting, kerning. For instance, in some fonts, you can see that the when you type the char V and A together (having VA), they may overlap each other (see http://en.wikipedia.org/wiki/Kerning). This is all done by freetype for you. If you're ok with not having kerning, then its ok to have an atlas, I guess. 2014-05-22 18:13 GMT-03:00 Jeffrey Carpenter:
|
|||||||||||||||||||
|
How to render text documents with SDL_TTF? |
Jeffrey Carpenter
Guest
|
Leonardo,
You remind me of a curious question I have with SDL_ttf. There exists a TTF_GetKerningSize function as of the last release, although I have yet to ever see a non-zero value from it, from any of the fonts that I've tried (admittedly, only Minion Pro, Arial and Times New Roman), with kerning explicitly enabled, rendering the whole ASCII glyph set. I suppose that my real question might be, what fonts should I expect to see a non-zero kerning value? Glancing through the SDL_ttf.c, it would lead me to believe that kerning *is* supported, but my tests seem to say otherwise. So, either my testing methodology is flawed, or SDL_ttf does not support kerning (possible bug within the API?) If the kerning API in SDL_ttf does work, then applying kerning to the rendered string of glyphs is trivial. Cheers, Jeffrey Carpenter _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
How to render text documents with SDL_TTF? |
Juan Manuel Borges Caño
Guest
|
The backend is FreeType, http://www.freetype.org/freetype2/docs/glyphs/glyphs-4.html , look at the BRAVO example. http://www.freetype.org/freetype2/docs/tutorial/step2.html , simple kerning, then, advaced. This corner of the Internet explains text composition very detailedly; from implentators.
Again, makes more sense to me to use SDL_rtf, else, for the work and benefits you might as well program a GTK or QT,... SDL backend . |
|||||||||||
|
It finally works! |
akastargazer
|
Look at this! I'm very happy to show results of work. SDL + SDL_TTF + BlackBox Component Builder.
And screencast here: http://youtu.be/Sn1rEmwHX5U |
|||||||||||
|
How to render text documents with SDL_TTF? |
Jeffrey Carpenter
Guest
|
Beautiful!
Cheers, Jeffrey Carpenter On 2014/09/ 23, at 8:02, akastargazer wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|