Cannot Set Font Size to Below 13 (C# .NET)

464
2
10-11-2011 10:48 PM
HenryColgate
Occasional Contributor
When I use the following script I cannot set the font size to below 13.  This works when I try font sizes 13 and above (converts 13 to 12.75). The data comes in as a string but this should not make a difference otherwise it would fail the conversion to Decimal.  The exception I get is the "value not within expected range".

ESRI.ArcGIS.Carto.IElement element = new ESRI.ArcGIS.Carto.TextElementClass();
ESRI.ArcGIS.Carto.ITextElement textElement = (ESRI.ArcGIS.Carto.ITextElement)element;
textElement.Text = elementString;

stdole.IFontDisp font = (stdole.IFontDisp)new stdole.StdFontClass();
font.Size = System.Convert.ToDecimal(textSize);
ESRI.ArcGIS.Display.ITextSymbol symbol = textElement.Symbol;
       
symbol.Font = font; //FAILS HERE if textSize > 12
           
textElement.Symbol = symbol;

This seems to be a bug as the lowest value in ArcMap is 5 but more importantly the default value is 12 which I cannot set either.

I am also not sure why I must explicilty set "textElement.Symbol = symbol" as I assumed it was referencing it anyway.
0 Kudos
2 Replies
HenryColgate
Occasional Contributor
Awesome,  this had already been answered on the old forum but using the new search did not pull it up.

http://forums.esri.com/Thread.asp?c=93&f=1170&t=193441

For those of you who couldn't be bothered clicking you just have to set the Font to something.  for example: Font.Name = "Arial";

It is still a bug as far as I am concerned because I don't want to change the font or have to account for this when I write the script.

Plans to migrate old information to the new forum?
0 Kudos
JamesCrandall
MVP Frequent Contributor
Plans to migrate old information to the new forum?


I am not sure of that, but I do know that the old forums is the first place I run searches!  Tons of info there.
0 Kudos