Text rendering / text layout / utf8

Hi,

Yesterday I was playing with utf8 and nice word wrapper features using FTGL as that seemed to be the best option available. Though after trying some things with FTGL I had to hack the code to get the positioning of the text right.

As FTGL seems a bit outdated, so I asked Google for other projects and found the pango project which can be used together with Cairo to get some advanced text rendering. I’m wondering if someone tried to get pango working OR knows an alternative solution to get
text rendering, with wordwrapping, alingment, etc… working in openFrameworks.

Kind regards,
Roxlu

Hi Roxlu,

I wrote this addon last year. I looked at the solutions you mentioned and found them a bit heavy so I wrote this instead. Might help in some way.

http://code.google.com/p/ofxtextsuite/

Release notes on OF Forum:
http://forum.openframeworks.cc/t/ofxtextsuite—text-wrapping-and-aligning/2967/0

I’m going to be doing a major update on it in the next 6 months, but it’s a little way off yet.

Regards,

Luke

Hi lukemalcolm,

Ah nice! Though I created a ofxPango addon last week which uses Pango and Cairo for text rendering with all the awesomeness of Pango. It has some really advanced font loading and text redering capabilities, including ltr, rtl, font-config, atsui, word wrapping, unicode, simple markup parsing, export to postscript,svg, pdf, opengl surfaces etc…

It’s too early to release though I’ve to reshape it a bit for an upcoming project after which I’ll
fix it for both Mac, Windows and Linux.

Example render:

Greetings,

Hi roxlu, I would love to play with your addon even if it’s not complete, if not could you give me some pointers in getting it to play with openframeworks?

Got Pango working on Windows as well! It’s not really clean as it needs lots and lots of separate .dll files (gtk+), but the good thing is that it works and I need some nice text rendering for an upcoming project. I’ve to fine tune the addon and after that I’ll post it on the forum.

hi diederick,

is this addon been released anywhere yet?
im in need of some advanced text rendering for a project and exploring options atm.

thanks,
L.

Hi Julapy,

Check it out at: http://github.com/roxlu/ofxPango

Best regards,
Roxlu

hey roxlu,thank you for the ofxpango. after some tweaks i got this working with vs2008. but it can’t display chinese letters somehow. i’m not familiar with pango&gtk stuff,any hints would be great, or should i change some settings?

thanks!

hi liquid!

great you got it working in VS2008! i would love to add your project as an example to the examples of the addon.

Did you use a font which has all the unicode characters? I used the “Arial Unicode” font.

Hope this helps!
Roxlu

thxs for the reply,yes, i tried that one too without success,only renderin out english letters,also the pango gave me warning sayin that “invalid utf-8 string passed to pango_layout_set_text()”

do i need recompiled the pango lib? b’coz i’m just using the dev-lib from
here http://www.gtk.org/download-windows.html

any help much appreciated! btw,check your pm please,i’ll send vs example to you.

here’s the vs2008 project file,http://rapidshare.com/files/429980859/pangoVS2008.rar anyone had a chance to help me on this, many thxs! btw,i haven’t try it with codeblock yet.maybe that works.

i’m having trouble getting this up and running in xcode.

i’ve included “…/…/…/addons/ofxPango/libs/” w/ recursive to both “header search paths” as well as trying “user header search paths” and I still keep getting an error

Pango/pangocairo.h: No such file or directory

when i try the #include <pango/pangocairo.h> call…

am i missing something fundamental in how im setting up my paths? thanks!

ah! nvm. figured it out. simple folder mismanagement on my part…

Hey,

thanks for the addon!

Works with linux 64bit and some additional lib-files.

hi,
I trying to play with some chinese font, but I cannot compile roxlu’s ofxPango on mac osx 10.6.
And I get below errors.

Undefined symbols for architecture i386:
“_iconv”, referenced from:
__nl_find_msg in libintl.a(dcigettext.o)
(maybe you meant: _g_iconv_close, _g_iconv_open , _g_iconv , _g_convert_with_iconv , _iconv_canonicalize )
“_iconv_open”, referenced from:
__nl_find_msg in libintl.a(dcigettext.o)
(maybe you meant: _g_iconv_open)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

if I hide some code in example file these bugs will not appear.

ofBackground(255,255,255);

pango = new ofxPango();
context = pango->createContextWithSurface(450.0f, 800.0f);
context->color4f(1.0f, 1.0f, 0.0f, 1.0f);
context->paint();

//layout = context->createPangoLayout();
//layout->setText("???6???2???7???\n\n ??? ??? PS3?3?? ??? ??? PS3? ??? ?? ??? ??? ??? ? ??? HDD(??? ???)? ?? ??? ??. ???HDD? ??? PS3??? ??? ??? ??? ??? “PLAYSTATION®Network”? ??? ? ??? ??? ??? ??? ??? ?? ? ??? ??? ?? ??? ??? ? ??? ???.\n\nHovedgruppen må være på minimum 10 personer, men deltakere kan knytte seg til hovedgruppen fra forskjellige destinasjoner. Tilknytningsbillett er gyldig inntil 24 timer før avreise hovedgruppe.\n\nUnicef said 3m people had been affected and more than 1,400 had been killed. The government said some 27,000 people remained trapped and awaiting help.");
//layout->setWidth(450.0f);
//layout->setJustify(true);

context->color4f(0.1f, 0.1f, 0.1f, 1.0f);

ofxPCPangoFontDescription* fd = new ofxPCPangoFontDescription();
//fd->createFromString(“Arial 11”);
//layout->setFontDescription(*fd);
//layout->show();

text_image.allocate(context->getSurface()->getWidth(), context->getSurface()->getHeight(), OF_IMAGE_COLOR_ALPHA);
text_image.setFromPixels(context->getSurface()->getPixels(), text_image.width, text_image.height, OF_IMAGE_COLOR_ALPHA, true);

please give me some advice
Thanks ^^

Kit

I found that when I using xcode 3.2.4, these error does not appear.
There error seems only appear in xcode 4.

Thank

I am having problems compiling too

in XCode 2.3.6 and 10.6 I get this error

Undefined symbols:
“_libintl_setlocale”, referenced from:
__g_dgettext_should_translate in libglib-2.0.a(gstrfuncs.o)
“_fopen$UNIX2003”, referenced from:
_read_aliases in libglib-2.0.a(gutils.o)
__g_locale_get_charset_aliases in libglib-2.0.a(localcharset.o)
_read_alias_file in libpango-1.0.a(pango-utils.o)
_pango_find_map in libpango-1.0.a(modules.o)
“_posix_memalign”, referenced from:
_allocator_memalign in libglib-2.0.a(gslice.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

I got back to this project I was working. I fixed all the Paths and tried to compile the example and I get 54 errors in the

System/Library/Frameworks/Carbon.framework/Headers/Carbon.h

file

I am by no means an openFrameWorks expert but wtf ??

what am I doing wrong ?

I just ran into the same problem with Xcode 4 and I found a solution for the libiconv problem:

I installed libiconv manually (from here:http://www.gnu.org/software/libiconv/#downloading) and excluded and deleted the file libiconv.a from ofxPango/src/libs/mac/static. Compiles like a charm now after some frustrating hours of research.

Btw, roxlu, I see that the library hasn’t been updated for a long time, but I included this function in my project, which makes it easy to clear the canvas (as i need to update text elements). Maybe in case you ever get back to ofxPango, you might want to include it:

  
  
void ofxPCContext::clear(float fR, float fG, float fB, float fA) {  
    cairo_paint(cr_context);  
    cairo_set_source_rgba (cr_context, fR, fG, fB, fA);  
    cairo_set_operator (cr_context, CAIRO_OPERATOR_SOURCE);  
    cairo_paint (cr_context);  
}