If you call super.drawLocal it will also render standard TextComponent's graphics along with text, and drawStyledText will draw over the already rendered unformatted text. You could avoid that by setting component's TextColor to transparent, but then you wouldn't have much use for the hosted components.
In order to change font attributes for all text of a TextComponent, you could assign them through its Font property. E.g. you could specify it in XML definition in format that can be parsed by Java's Font.decode method:
<Text Name="Text" Font="Arial-italic-4" TextAlignment="Near" />"...
If you prefer more-varied formatting via HTML tags, better override TextComponent.draw method in custom class:
package com.myorg;
import java.awt.Graphics2D;
import com.mindfusion.diagramming.*;
import com.mindfusion.diagramming.components.*;
public class StyledTextComponent
extends TextComponent
{
@Override
public void draw(Graphics2D g2d, RenderOptions options)
{
Brush textBrush = new SolidBrush(getTextColor());
textBrush.applyTo(g2d, getBounds());
if (options.getTargetView() instanceof DiagramView)
{
DiagramView view = (DiagramView) options.getTargetView();
view.getDiagram().drawStyledText(
g2d, getText(), getFont(), getBounds(), getTextFormat(), textBrush);
}
}
}
and then load the custom component from XML template by specifying its full name:
<com.myorg.StyledTextComponent ... />
I hope that helps,
Stoyan