I have a CRhinoUiFontComboBox and handle the ON_CBN_SELCHANGE messages to get user selected fonts. As I scroll through all the various fonts, my text is displayed in a conduit. This works fine for a while but after continued scrolling, some of the displayed text begins to appear garbled as shown below.
The top font happens to be Copperplate Gothic Bold and the bottom is Copperplate Gothic Light. As I continue to scroll, some fonts will be fine and others are not. Once a font turns garbled, that particular font will always appear that way when I return to it after scrolling to other fonts. If I close the application and then launch it again, everthing works fine for a while, then repeats the problem. The text is not improved if I add it to the Rhino document.
This is my first attempt at using the new V6 text, so I may be creating it wrong. Here is how I do it:
//Create font from face name retrieved from ComboBox.
const ON_Font* font_ = ON_Font::GetManagedFont(face_name, b_bold, b_italic);
//Set my ON_DimStyle object.
style = doc->m_dimstyle_table.CurrentDimStyle().CreateOverrideCandidate();
//Create ON_Text object.
txt.Create(my_wchar, &style, plane);
//Display text in conduit or add text to document.
dp.DrawAnnotation(txt, Black, p_updater, &h_cache);
doc->AddTextObject(txt.RichText(), txt.Plane(), txt.Plane().Origin(), &style);
To assist the developer, who will look at this, in solving this issue, can you paste the results of Rhino’s SystemInfo command into a reply to this?
Also, in looking at your drawing code you are drawing annotation text in a depth-buffered channel. This is why you need to call CRhinoDoc::Regen to see the changes. For better performance, try drawing in the CSupportChannels::SC_DRAWOVERLAY channel. In doing this, you can then just call CRhinoDoc::Redraw.
I’ve attached a sample project that demonstrates this.
Thanks for the code. I tried several display channels and redraw functions to try and correct the problem but nothing worked. I am getting the same garbled text with your sample code. Scrolling through the font ComboBox, I leak about a GB of memory and closing the plug-in dialog doesn’t return the memory. Also, any text that I subsequently add to the document using Rhino commands is also bad.
In your example code you are using the ON_Text::BoundingBox() function in your conduit. This seems to work fine to get the basic text size but I notice that this won’t return the actual size of text with a modified style that changes the text size such as setting the text height or just using italic. Is this a bug or do we need to use ON_Text::GetAnnotationBoundingBox(), which does seem to return the correct size?