[GIS] change the font type in all Text_Elements in a page

arcgis-10.0arcpycartography

I want to change all the font styles in a number of mxd's from "Lucinda Sans" or whatever the current one is to "Arial" without changing the font size.

I wrote a simple script to find/replace text but can't figure out how to change the font except by adding html code as in the example below (see image as well). But this doesn't change the root font and also I want it to change the font of all text strings in the Text and Legend elements. No need to search/replace any text.

Thanks in advance. Screen capture and Code are below

enter image description here

import os, arcpy, arcpy.mapping
oldText = arcpy.GetParameterAsText(0)
newText = arcpy.GetParameterAsText(1)
pdf = arcpy.GetParameterAsText(2)
mxd=arcpy.mapping.MapDocument("Current")

# Loop through each text element in the map document
for textElement in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):

    # Check if the text element contains the out of date text
    if textElement.text == oldText:

    # If out of date text is found, replace it with the new text
        textElement.text = '<FNT name="Arial">' + newText + '</FNT>'

#while PDF = 1:
# Export the updated map to a PDF
#path = r'P:\2011\Job_031_TownPlanning_SeriesProduction\Working\draft_output\esri\2\wetland\'
#arcpy.mapping.ExportToPDF(mxd, newText + "-TownPlanning_Wetlands_Overlay_Ver2.pdf")

#arcpy.mapping.ExportToJPEG(mxd, outFile)
#outFile = newText + df.name + ".pdf"

# Clean up the MapDocument object by deleting it
del mxd

arcpy.RefreshActiveView()
arcpy.RefreshTOC()

Best Answer

The Text Element class of the Mapping Module has no font property. This leads me to believe that there is currently no method for changing the font type of text elements through arcpy's mapping module for now. The help even has a code sample for changing the font size of a given element, and its best idea is to do what essentially is a looping test of length edited by HTML code similar to what you use above. Perhaps this will be rectified in later iterations of the mapping module, but I do not have high hopes.