ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SymbolFactory Class / ConstructTextSymbol Method / ConstructTextSymbol(CIMPolygonSymbol,Double,String,String) Method
ArcGIS.Core.CIM.CIMPolygonSymbol
The size of the text symbol to construct.
The font family name of the text symbol to construct.
The font style name of the text symbol to construct.
Example

ConstructTextSymbol(CIMPolygonSymbol,Double,String,String) Method
Constructs a default text symbol given its polygon symbol, size, font family name and style. This method must be called on the MCT. Use QueuedTask.Run.
Syntax

Parameters

symbol
ArcGIS.Core.CIM.CIMPolygonSymbol
size
The size of the text symbol to construct.
fontFamilyName
The font family name of the text symbol to construct.
fontStyleName
The font style name of the text symbol to construct.

Return Value

Exceptions
ExceptionDescription
This method must be called within the lambda passed to QueuedTask.Run
Remarks
If the font family is null or does not exist the current default font family will be assigned. If the font style is null or does not exist, the default font style for the font family will be assigned.
Example
Create Point Text Element 1
//Create a simple point text element and assign basic symbology and text settings.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D point geometry
  Coordinate2D coord2D = new Coordinate2D(3.5, 10);

  //Set symbolology, create and add element to layout
  CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                ColorFactory.Instance.RedRGB, 32, "Arial", "Regular");
  string textString = "Point text";
  //At 2.x - GraphicElement ptTxtElm =
  //         LayoutElementFactory.Instance.CreatePointTextGraphicElement(
  //                           layout, coord2D, textString, sym);
  //ptTxtElm.SetName("New Point Text");
  //ptTxtElm.SetAnchor(Anchor.CenterPoint);
  //ptTxtElm.SetX(4.5);
  //ptTxtElm.SetY(9.5);
  //ptTxtElm.SetRotation(45);

  //use ElementInfo to set placement properties during create
  var elemInfo = new ElementInfo()
  {
    Anchor = Anchor.CenterPoint,
    Rotation = 45
  };
  var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
    container, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
                       "New Point Text", true, elemInfo);

  //Change additional text properties
  ptTxtElm.SetX(4.5);
  ptTxtElm.SetY(9.5);
});
Create Rectangle Paragraph Text Element 1
//Create rectangle text with background and border symbology.  

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D polygon geometry
  List<Coordinate2D> plyCoords = new List<Coordinate2D>();
  plyCoords.Add(new Coordinate2D(3.5, 7));
  plyCoords.Add(new Coordinate2D(4.5, 7));
  plyCoords.Add(new Coordinate2D(4.5, 6.7));
  plyCoords.Add(new Coordinate2D(5.5, 6.7));
  plyCoords.Add(new Coordinate2D(5.5, 6.1));
  plyCoords.Add(new Coordinate2D(3.5, 6.1));
  //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords);
  Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);

  //Set symbolology, create and add element to layout
  //Also notice how formatting tags are using within the text string.
  CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                    ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular");
  string text = "Some Text String that is really long and is " +
                "<BOL>forced to wrap to other lines</BOL> so that " +
                "we can see the effects." as String;
  //At 2.x - GraphicElement polyTxtElm =
  //           LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(
  //                                      layout, poly, text, sym);
  //         polyTxtElm.SetName("New Polygon Text");

  GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
    container, TextType.RectangleParagraph, poly, sym, text, "Polygon Paragraph");

  //(Optionally) Modify paragraph border 
  CIMGraphic polyTxtGra = polyTxtElm.GetGraphic();
  CIMParagraphTextGraphic cimPolyTxtGra = polyTxtGra as CIMParagraphTextGraphic;
  cimPolyTxtGra.Frame.BorderSymbol = new CIMSymbolReference();
  cimPolyTxtGra.Frame.BorderSymbol.Symbol =
               SymbolFactory.Instance.ConstructLineSymbol(
                          ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid);
  polyTxtElm.SetGraphic(polyTxtGra);
});
Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

ArcGIS Pro version: 2.0 or higher.
See Also