I am attempting to place text within a certain space within a layout. I want the text to automatically wrap to fit within the space, and I want the font size to shrink automatically if the height of the text goes beyond that space.
I can specify an envelope and create texts that automatically wraps by creating a paragraph text element like this:
Coordinate2D lowerLeftPoint = new Coordinate2D(xPosition, yPosition);
Coordinate2D upperRightPoint = new Coordinate2D(xPosition + maxTextWidth, yPosition+maxTextHeight);
Envelope textEnvelope = EnvelopeBuilder.CreateEnvelope(lowerLeftPoint, upperRightPoint);
GraphicElement renderedText = LayoutElementFactory.Instance.CreateRectangleParagraphGraphicElement(_layout, textEnvelope, text, textSymbol);
However, as this link explains, paragraph text does not auto-size to fit its envelope. The link also points out that point text does automatically resize, but will not wrap automatically.
With the code above, I end up with text that will get cut off when it goes beyond the envelope. Pro will add an ellipsis graphic to the end of the text to indicate that it got cut off, but I'm not seeing any property that indicates whether or not the text was cut off.
Ideally, I could just set some property to tell the paragraph text to auto-size to fit within the envelope. If such a property does not exist, is there a way to programmatically check whether or not the text fit within the envelope or got cut off? If so, I could manually iterate through smaller and smaller font sizes until the text fits. I'm also open to trying a different approach entirely as long as the text will both wrap and shrink to fit within some specified space.
Thank you for your post Brennan. I can not think of a work around currently, I even evaluated CIM definitions for a possible property. You make two very good points: 1) we should at least expose a flag for paragraph text and other layout elements that show the red ellipses indicating something doesn't fit and 2) even the UI (and SDK) could benefit from having a fitting strategy on paragraph text similar to legends.
I will submit these ideas to the rest of the Layout team for consideration. Concerning number 1, I hope this is something we should be able to expose. I assume right now it is simply an internal property.
Jeff - Layout Team