ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMLabelClass Class / TextSymbol Property
Example Version

TextSymbol Property (CIMLabelClass)
Gets or sets the text symbol of the label class.
Syntax
public CIMSymbolReference TextSymbol {get; set;}
Example
Creating a new Annotation Feature in an Annotation FeatureClass using a RowBuffer
public async Task CreatingAnAnnotationFeature(Geodatabase geodatabase)
{
  await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
  {
    using (AnnotationFeatureClass annotationFeatureClass = geodatabase.OpenDataset<AnnotationFeatureClass>("Annotation // feature // class // name"))
    using (AnnotationFeatureClassDefinition annotationFeatureClassDefinition = annotationFeatureClass.GetDefinition())
    using (RowBuffer rowBuffer = annotationFeatureClass.CreateRowBuffer())
    using (AnnotationFeature annotationFeature = annotationFeatureClass.CreateRow(rowBuffer))
    {
      annotationFeature.SetAnnotationClassID(0);
      annotationFeature.SetStatus(AnnotationStatus.Placed);

      // Get the annotation labels from the label collection
      IReadOnlyList<CIMLabelClass> labelClasses =
        annotationFeatureClassDefinition.GetLabelClassCollection();

      // Setup the symbol reference with the symbol id and the text symbol
      CIMSymbolReference cimSymbolReference = new CIMSymbolReference();
      cimSymbolReference.Symbol = labelClasses[0].TextSymbol.Symbol;
      cimSymbolReference.SymbolName = labelClasses[0].TextSymbol.SymbolName;

      // Setup the text graphic
      CIMTextGraphic cimTextGraphic = new CIMTextGraphic();
      cimTextGraphic.Text = "Charlotte, North Carolina";
      cimTextGraphic.Shape = new MapPointBuilderEx(new Coordinate2D(-80.843, 35.234), SpatialReferences.WGS84).ToGeometry();
      cimTextGraphic.Symbol = cimSymbolReference;

      // Set the symbol reference on the graphic and store
      annotationFeature.SetGraphic(cimTextGraphic);
      annotationFeature.Store();
    }
  });
}
Apply text symbol to a feature layer
//Note: call within QueuedTask.Run()

//Get the layer's definition
var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer;
//Get the label classes - we need the first one
var listLabelClasses = lyrDefn.LabelClasses.ToList();
var theLabelClass = listLabelClasses.FirstOrDefault();
//Set the label classes' symbol to the custom text symbol
//Refer to the ProSnippets-TextSymbols wiki page for help with creating custom text symbols.
//Example: var textSymbol = await CreateTextSymbolWithHaloAsync();
theLabelClass.TextSymbol.Symbol = textSymbol;
lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back
featureLayer.SetDefinition(lyrDefn); //set the layer's definition
                                     //set the label's visiblity
featureLayer.SetLabelVisibility(true);
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also