ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ISymbolFactory Interface / 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

In This Topic
    ConstructTextSymbol(CIMPolygonSymbol,Double,String,String) Method
    In This Topic
    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
    Overloads Function ConstructTextSymbol( _
       ByVal symbol As CIMPolygonSymbol, _
       ByVal size As Double, _
       ByVal fontFamilyName As String, _
       ByVal fontStyleName As String _
    ) As CIMTextSymbol

    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
    Construct a Text Symbol With Options
    {
      await QueuedTask.Run(() =>
      {
        //using the default font
        var textSym1 = SymbolFactory.Instance.ConstructTextSymbol();
        var textSym2 = SymbolFactory.Instance.ConstructTextSymbol(
                           ColorFactory.Instance.BlueRGB, 14);
    
      //using a specific font
      var textSym3 = SymbolFactory.Instance.ConstructTextSymbol("Arial");
      var textSym4 = SymbolFactory.Instance.ConstructTextSymbol(
                        "Arial", "Narrow Bold");
    
      //or query available fonts to ensure the font is there
      var all_fonts = SymbolFactory.Instance.GetAvailableFonts();
      var font = all_fonts.FirstOrDefault(f => f.fontName == "Arial");
      if (!string.IsNullOrEmpty(font.fontName))
      {
        var textSym5 = SymbolFactory.Instance.ConstructTextSymbol(font.fontName);
        //or with a font+style
        var textSym6 = SymbolFactory.Instance.ConstructTextSymbol(
                                        font.fontName, font.fontStyles.First());
      }
    
      //overloads - font + color and size, etc
      var textSym7 = SymbolFactory.Instance.ConstructTextSymbol(
                      ColorFactory.Instance.BlueRGB, 14, "Times New Roman", "Italic");
    
      //custom symbol - black stroke, red fill
      var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol(
        SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.RedRGB),
        SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 1));
        var textSym8 = SymbolFactory.Instance.ConstructTextSymbol(
          poly_symbol, 14, "Georgia", "Bold");
      });
    }
    Snippet Creates a text symbol with a halo
    /// <summary>
    /// Creates a text symbol with a red halo
    /// ![halo](https://ArcGIS.github.io/arcgis-pro-sdk/images/Labeling/halo.png)
    /// </summary>
    {
      CIMTextSymbol textSymbolWithHalo = await QueuedTask.Run(() =>
      {
        //create a polygon symbol for the halo
        var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid);
        //create text symbol using the halo polygon
        return SymbolFactory.Instance.ConstructTextSymbol(haloPoly, 10, "Arial", "Bold");
      });
      //Refer to the snippet "How to apply a Text Symbol to labels of a layer" below to see how to apply this text symbol to a label class
    
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also