Thread: [UFO-devel] Can't set a font
Status: Beta
Brought to you by:
schmidtjf
From: Mark R. <ma...@gm...> - 2005-07-06 20:00:39
|
Hi there, I am very impressed with the quality of this library, but very unimpressed with the quality of the documentation. Specifically, there is no overview as to how to use the library generally - although the examples helped, it seems they did not call every thing. I don't understand how the garbage collection works - I'll assume for the time being that it just does. Anyway, I'm trying to set the font of a widget (ULabel) to something other than the default, but it crashes almost immediately afterwards. I've modified the "layouts" example, and I've tried putting the ->setFont in various different places, but it makes little difference. I'm doing something like label->setFont(new UFont(UFontInfo::SansSerif, 16)); at about line 151 of layouts.cpp And it's crashing somewhere like: Program received signal SIGSEGV, Segmentation fault. 0xb7f01b5c in ufo::UGL_Graphics::setFont (this=3D0x80c6e38, font=3D0xb7d618a0) at ucollectable.hpp:80 80 UCollectable::reference() const { m_refCount++; } (gdb) bt #0 0xb7f01b5c in ufo::UGL_Graphics::setFont (this=3D0x80c6e38, font=3D0xb7d618a0) at ucollectable.hpp:80 #1 0xb7f92076 in ufo::UWidget::paint (this=3D0x812d1f8, g=3D0x80c6e38) at widgets/uwidget.cpp:543 #2 0xb7f922e9 in ufo::UWidget::paintChildren (this=3D0x812ac88, g=3D0x80c6e38) at stl_iterator.h:149 #3 0xb7f92094 in ufo::UWidget::paint (this=3D0x812ac88, g=3D0x80c6e38) at widgets/uwidget.cpp:546 #4 0xb7f922e9 in ufo::UWidget::paintChildren (this=3D0x81080a8, g=3D0x80c6e38) at stl_iterator.h:149 #5 0xb7f92094 in ufo::UWidget::paint (this=3D0x81080a8, g=3D0x80c6e38) at widgets/uwidget.cpp:546 #6 0xb7f922e9 in ufo::UWidget::paintChildren (this=3D0x8107f10, g=3D0x80c6e38) at stl_iterator.h:149 #7 0xb7f92094 in ufo::UWidget::paint (this=3D0x8107f10, g=3D0x80c6e38) at widgets/uwidget.cpp:546 #8 0xb7f922e9 in ufo::UWidget::paintChildren (this=3D0x80e3ea0, g=3D0x80c6e38) at stl_iterator.h:149 #9 0xb7f92094 in ufo::UWidget::paint (this=3D0x80e3ea0, g=3D0x80c6e38) at widgets/uwidget.cpp:546 #10 0xb7f5f619 in ufo::UXContext::repaint (this=3D0x80cf1c8) at ux/uxcontext.cpp:128 #11 0xb7f63347 in ufo::UXFrame::repaint (this=3D0x80574a8, force=3Dfalse) at ux/uxframe.cpp:115 #12 0x0804a98e in main (argc=3D1, argv=3D0xbffffb84) at layouts.cpp:52 HOWEVER, the funny thing is, just before it crashes, it does actually appear to render that label in a different font from the rest of the app (this is only visible if it's stopped in the debugger after the crash, otherwise the window vanishes immediately) What am I doing wrong? I am using libufo 0.7.4 on Linux with OpenGL and the Nvidia drivers - other opengl applications work fine. Mark |
From: Johannes S. <sch...@us...> - 2005-07-07 08:17:57
|
Hi, Am Mittwoch 06 Juli 2005 22:00 schrieb Mark Robson: > I am very impressed with the quality of this library, but very > unimpressed with the quality of the documentation. > > Specifically, there is no overview as to how to use the library > generally - although the examples helped, it seems they did not call > every thing. > > I don't understand how the garbage collection works - I'll assume for > the time being that it just does. > > Anyway, I'm trying to set the font of a widget (ULabel) to something > other than the default, but it crashes almost immediately afterwards. > > I've modified the "layouts" example, and I've tried putting the > ->setFont in various different places, but it makes little difference. > > I'm doing something like > > label->setFont(new UFont(UFontInfo::SansSerif, 16)); > > at about line 151 of layouts.cpp [...] > What am I doing wrong? I am using libufo 0.7.4 on Linux with OpenGL > and the Nvidia drivers - other opengl applications work fine. There seems to be a serious bug with setting fonts in 0.7.4. Possibly the font is destructed by the graphics object ...? Well, I haven't used 0.7.4 for weeks, as I am working on the new 0.8.0 release. Setting fonts with this release should work (it uses objects created on the stack, no pointers). Unfortunately, this release is delayed until the end of the semester (have to write several exams) which is ca. Mid July. Perhaps you want to try one of the snapshots from http://libufo.sourceforge.net/snapshots/ Regards, Johannes |
From: Mark R. <ma...@gm...> - 2005-07-08 17:40:49
|
I've got a CVS snapshot, ufo-20050621.tar.gz This seems to work a lot better, at least I can set the font without it crashing. However, no font settings I make seem to make any difference. Could you suggest a method to determine what fonts are available. Also, I tried to use texture fonts setting UFO_FONT and UFO_FONT_DIR, but the appearance is very poor (labels don't work at all, and buttons appear with the text displaced and off-centre). Is this a known bug? Is there any reasonable way which I can set a custom font without writing my own font renderer? You have provided three font files, Arial_10.tga etc. Have you got the source code of the program which created these? Did it use Freetype or something to convert Truetype fonts? If so, can I have it so that I can use custom fonts in my app? Cheers Mark |
From: Johannes S. <sch...@us...> - 2005-07-09 10:24:07
|
On Friday 08 July 2005 19:39, Mark Robson wrote: > I've got a CVS snapshot, ufo-20050621.tar.gz > > This seems to work a lot better, at least I can set the font without > it crashing. However, no font settings I make seem to make any > difference. Well, there aren't many fonts you can actually select. There is only the builtin font renderer which has: sans-serif font with point size 10,12 serif font with point size 10 mono spaced font with point size 8 and three textured fonts. Furthermore, in older releases there was an X11/GLX font renderer which can use all fonts visible to your X server. If you are interested, I can fix it for current releases. > Could you suggest a method to determine what fonts are available. UToolkit->listFonts() should work ... ATM, I am making some internal changes to font handling so it might be broken ... > Also, I tried to use texture fonts setting UFO_FONT and UFO_FONT_DIR, > but the appearance is very poor (labels don't work at all, and buttons > appear with the text displaced and off-centre). Is this a known bug? Hmm, I thought that I have already fixed this ... Possible values for UFO_FONT are: builtin_font gl_texture_font texture_font > Is there any reasonable way which I can set a custom font without > writing my own font renderer? > > You have provided three font files, Arial_10.tga etc. Have you got the > source code of the program which created these? Did it use Freetype or > something to convert Truetype fonts? If so, can I have it so that I > can use custom fonts in my app? The texture fonts are created via UFO, SDL_ttf and truetype fonts. The builtin fonts are created using plain X11. I can give you source code and binaries. Please be patient for one or two weeks as I have to pass some important exams next week. Regards, Johannes |
From: Mark R. <ma...@gm...> - 2005-07-09 10:33:29
|
> Well, there aren't many fonts you can actually select. > There is only the builtin font renderer which has: > sans-serif font with point size 10,12 > serif font with point size 10 > mono spaced font with point size 8 I have seen this in the source now. > Furthermore, in older releases there was an X11/GLX font renderer > which can use all fonts visible to your X server. > If you are interested, I can fix it for current releases. No, that is not important. I am more interested in the textured fonts, especially if I have the program to create custom ones. This will enable me to use fonts not present on the user's machine. It would also be nice if my program uses the same fonts on Windows and Linux. > > Also, I tried to use texture fonts setting UFO_FONT and UFO_FONT_DIR, > > but the appearance is very poor (labels don't work at all, and buttons > > appear with the text displaced and off-centre). Is this a known bug? >=20 > Hmm, I thought that I have already fixed this ... You may have already fixed this. I'm now using a different version of UFO, the cvs snapshot 20050707. I can't get texture fonts to work at all with this version, setting UFO_FONT and UFO_FONT_DIR appears to have no effect whatsoever (it still uses built in fonts). Good luck with your exams. I am going to make a game which uses UFO - it will have an opengl part rendered in (almost) 3d, and some popup windows (UInternalFrame probably) which can be rendered using UFO. I've done some experiments, and I've now got that to work, provided I can perusade UFO to stop drawing the background over my opengl graphics (which now works) Mark |
From: Johannes S. <sch...@us...> - 2005-07-16 14:04:20
Attachments:
ugentgafont.cpp
|
On Saturday 09 July 2005 12:33, Mark Robson wrote: [...] > > Furthermore, in older releases there was an X11/GLX font renderer > > which can use all fonts visible to your X server. > > If you are interested, I can fix it for current releases. > > No, that is not important. I am more interested in the textured > fonts, especially if I have the program to create custom ones. > > This will enable me to use fonts not present on the user's machine. It > would also be nice if my program uses the same fonts on Windows and > Linux. I have attached a prerelease of the source code with which I created the distributed font files. You'll need SDL, SDL_ttf and libUFO. Compiling should work via g++ ugentgafont.cpp -o ugentgafont `sdl-config --cflags --libs` `pkg-config --cflags --libs ufo` -lSDL_ttf To create a font file, call it with the ttf file and optionally the point size as arguments. [...] > Good luck with your exams. Thanks. I assume the results will turn out satisfactory. Regards, Johannes |