ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / TextProperties Class / Font Property
Example

In This Topic
    Font Property
    In This Topic
    Gets and sets the font name of the text element. When setting, use the string values the way they appear in the Text Symbol Font list located in the text element format tab.
    Syntax
    public string Font {get; set;}
    Public Property Font As String

    Property Value

    String
    Example
    Modify existing text element properties
    //Modify the text properties for an existing text element.
    
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout"));
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      //Reference and load the layout associated with the layout item
      Layout lyt = layoutItem.GetLayout();
    
      //Reference a text element by name
      TextElement txtElm = lyt.FindElement("Title") as TextElement;
    
      //Change placement
      txtElm.SetX(4.25);
      txtElm.SetY(8);
    
      //Change TextProperties
      TextProperties txt_prop = txtElm.TextProperties;
      txt_prop.FontSize = 48;
      txt_prop.Font = "Times New Roman";
      txt_prop.Text = "Some new text";
      txtElm.SetTextProperties(txt_prop);
    });
    Modify existing text properties
    //Modify the text properties for an existing text element.
    
    //Reference a layoutitem in a project by name
    LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("Layout"));
    
    //Perform on the worker thread
    await QueuedTask.Run(() =>
    {
      //Reference and load the layout associated with the layout item
      Layout lyt = layoutItem.GetLayout();
    
      //Reference a text element by name
      TextElement txtElm = lyt.FindElement("Title") as TextElement;
    
      //Change placement
      txtElm.SetX(4.25);
      txtElm.SetY(8);
    
      //Change TextProperties
      TextProperties txt_prop = txtElm.TextProperties;
      txt_prop.FontSize = 48;
      txt_prop.Font = "Times New Roman";
      txt_prop.Text = "Some new text";
      txtElm.SetTextProperties(txt_prop);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also