Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

# 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 + + ".pdf"

# Clean up the MapDocument object by deleting it
del mxd

share|improve this question
Would an answer showing how to do this with arcobjects add-in be acceptable? – Kirk Kuykendall Jun 1 '11 at 17:19
I haven't used arcobjhects before but if it's easy coding then yes, that would be fine. I have Arc Info 9.3 and 10. Thanks. – GeorgeC Jul 6 '11 at 22:39
up vote 4 down vote accepted

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.

share|improve this answer
Thanks Nathanus. This is really unfortunate. ESRI finally gave me the same answer as well. Hope they incorporate this into the next update as accessing this will be very useful. – GeorgeC Jul 15 '11 at 1:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.