ccposton

Setting the Color of a TextSymbol

Discussion created by ccposton on Nov 16, 2011
Latest reply on Nov 16, 2011 by jeffhamblin
  
public void DrawText( IActiveView view, string text, string fontName, int fontColor, float fontSize, IPoint point ) {          
    ITextSymbol textSymbol = new TextSymbol();          
    stdole.IFontDisp font = textSymbol.Font;         
    font.Name = fontName;         
    font.Size = (decimal)fontSize;         
    textSymbol.Font = font;          
    IColor color = textSymbol.Color;         
    color.RGB = fontColor;         
    textSymbol.Color = color;          
    ITextElement textElement = new TextElementClass();         
    textElement.Text = text;         
    textElement.Symbol = textSymbol;         
    textElement.ScaleText = true;          
    IElement element = textElement as IElement;         
    element.Geometry = point;          
    view.GraphicsContainer.AddElement( element, 0 );          
    view.PartialRefresh( esriViewDrawPhase.esriViewGraphics, element, null );     
}


Can anyone suggest to me why this code always sets the font and size correctly but sometimes fails to set the color correctly? I always see the correct color in the 'textSymbol.Color' property after the line that sets it to 'color.' On the map (within a layer) it sometimes appears to 'combine' with that layer's fill color and off the map it sometimes appears 'blue.'  Is this a bug? I am using ArcGIS 10, service pack 2.

Outcomes