Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
I've posted another question for a follow up to this issue: Do Label Expressions Slow Down Drawing Speed? –  Cody Brown Jul 17 '13 at 16:01

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 Jul 17 '13 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 Jul 17 '13 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 Jul 17 '13 at 15:43
    
I could not get your os.getenv to work, but import getpass, str(getpass.getuser()) == 'username', worked for me. –  artwork21 Jul 17 '13 at 16:03

Your Answer

 
discard

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.