Wednesday, 26 October 2016

python - Programmitcally Change Text Font for all Labels on MXD


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?




Answer



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




  1. using label expressions


    "" & [LABELFIELD] & ""

    "" & [LABELFIELD] & ""



  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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...