Short summary of bugs in Opengl_togl_begin_layer_mode.cxx and related

1) OSD_FontManager returns bad list of X11 fonts, at least in my system

2) Anyways, even with the patch I posted in another post, OSD_FontManager will grab just X11 fonts, not
user installed ones, which are usually many, many more, at least on Linux systems.

3) In Opengl_togl_begin_layer_mode.cxx, there are *many* bugs and side effects :

---- call_togl_textsize2d as a side effect changes current font height; it's not possible
to query for a text string size without having to re-set the font height after on if the
used is different.

---- call_togl_text2d don't use height parameter; so a call without textsize2d would take a random height.

There are other bugs there, but I guess it's enough for now :-)
I think all that module should be refactored completely; it's one of the worst coded piece I've ever seen....

Max

Forum supervisor's picture

Dear Massimo,
We cannot analyze this issue without additional information about the system configuration.
The font manager seems to work well on most systems supported by OCCT.
Regards

Forum supervisor's picture

Several words in addition.
We are open for any suggestions how to improve the font manager implementation so as to detect also the user fonts.
OSD_FontMgr currently relies on Xlib API (XGetFontPath() function call) in order to query the font directory. Knowing the font directory is mandatory for text rendering to work, because FTGL uses FreeType to create font glyph images, and the latter deals with font files directly.
Thus any ideas how to detect the font directories different from the system one are welcome!
Regards

Massimo Del Fedele's picture

Yep, sorry, the details are in another post of me.
My system is Ubuntu 11.10 (Natty), 64 bit.

In my other post (http://www.opencascade.org/org/forum/thread_22431/) I've dumped the font list
with original code and with a patch added; it seems to me that .dir file is parsed wrongly, at least for
my system. With the annexed patch the fonts are gathered correctly.

About the other fonts... I'll look at my toolkit, it seems to grab ALL fonts correctly both on windows and on Linux, so it could contain a good solution.

Max

Venugopal Gudimetla's picture

Hi Massimo,

Sometime back (OCC 6.3), I had problems making layering work on Linux (ubuntu 32 bit) work. I followed Roman's example which he had posted on his blog for windows. But I couldn't make it work, even though I used his code. Unfortunately, I had not much in that respect and left the problem there. I was able to display the layer where I wanted it, but never was able to display any kind of font in the layer.

Now since you are working on it and seem to have made some head way, albeit some bugs in OCC, is it possible for you to share your code to make layering with font work? if you want to help in pointing errors in my won code, I can post my code too. I appreciate any kind of help and thanks for your time.

Regards,
Venu

Massimo Del Fedele's picture

Hi,

in this post there's a patch that worked for me, to detect correctly fonts on my system.
It's for Linux, so if you've problems on windows it's useless.
About displaying fonts, it's not hard, but you should keep in mind a couple of bugs present.
The code I use is something like that :

recLayer->SetColor(SnapHintColor);
recLayer->SetTextAttributes(Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, SnapHintColor);
sw->recLayer->TextSize(hint, SnapHintSize, w, asc, desc);
sw->recLayer->DrawText(hint, tx, ty, SnapHintSize);

I guess variable names are self-explaining.
The SetColor() is used because the SetTextAttributes DON'T set correctly text color... I guess it's a bug.
The TextSize MUST be called before DrawText because of another bug, the Height parameter in DrawText is ignored, and the one in TextSize has as a side effect to setup text size.

As I said in another post, OCC layer code is a bit confused and needs refactoring; anyways with the hints above (and the patch if you're in Linux....) all should work.

Ciao

Max

Massimo Del Fedele's picture

Sorry, forgot the link to the post with patch :

http://www.opencascade.org/org/forum/thread_22431/

Venugopal Gudimetla's picture

Thanks Massimo, greatly appreciate your snippet and your patch.

Regards,
Venu