I'd like to know if there is a way to change the text font for all layers and all label classes within a layer on a MXD.

I use a font not often found on all computers for created maps. I love the font, but it becomes an issue when publishing or sharing MXD's. Usually before I share or publish a MXD I need to go through all the layers and set the font to be something found everywhere.

Personally I'd like if the script auto found layers and label classes withing every layer in the TOC. I'm pretty good with python, but I haven't ever found a way to interact with the label's for a layer within ArcPy.

Does anyone have an idea of how to due this?


1 Answer 1


You cannot change font style using arcpy, your options are:

  1. using label expressions

    "<FNT name='Arial' size='18'>" & [LABELFIELD] & "</FNT>"
    "<FNT name='Arial' scale='200'>" & [LABELFIELD] & "</FNT>"
  2. ArcObjects - ITextSymbol Interface

I posted a question on this site before, ArcObjects add halo to label, dealing with labels which will give yoiu a general guild for accessing the ITextSymbol interface. You will just need to change the beginning portion of the code to loop through each layer within the map document and add the pFont.Font property.

  • Could you add an IF statement in there to test what PC the MXD is running on? As in if its my computer, run my font, if not run Arial?
    – Cody Brown
    Commented Jul 17, 2013 at 15:14
  • Yes, I have not tested this but you could add a conditional statement that checks the current username using this property, msdn.microsoft.com/en-us/library/…
    – artwork21
    Commented Jul 17, 2013 at 15:32
  • I've plumped together somethere here: def FindLabel ( [GEONAME] ): import os if str(os.getenv("COMPUTERNAME")) == 'GIS-HP': return ("<FNT name='Adobe Fan Heiti Std B' size='8'>" + [GEONAME] + "</FNT>") else: return ("<FNT name='Arial' size='8'>" + [GEONAME] + "</FNT>") What do you think? I dislike adding the import os, it will probably slow down my labeling like crazy.
    – Cody Brown
    Commented Jul 17, 2013 at 15:43
  • I could not get your os.getenv to work, but import getpass, str(getpass.getuser()) == 'username', worked for me.
    – artwork21
    Commented Jul 17, 2013 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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