ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SymbolFactory Class / GetAvailableFonts Method
Example

In This Topic
    GetAvailableFonts Method (SymbolFactory)
    In This Topic
    Gets the list of available fonts in the application for the Pro session. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Return Value

    A list of tuples where tuple.fontName is the font family name and tuple.fontStyles is a list of available styles for the given font family
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Get a List of Available Fonts
    //Must use QueuedTask.Run(...)
    //returns a tuple per font: (string fontName, List<string> fontStyles)
    var fonts = SymbolFactory.Instance.GetAvailableFonts();
    foreach(var font in fonts)
          {
      var styles = string.Join(",", font.fontStyles);
      System.Diagnostics.Debug.WriteLine($"{font.fontName}, styles: {styles}");
          }
    
    Construct a Text Symbol With Options
    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");
    
    });
    
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also