Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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'm working in ArcGIS 10.0 and Python 2.6.5. I have a string, say 'mMx', that I want to enter into a TextElement (in the data view). The lowercase letters are to be substituted with a graphical symbol through use of the usual html-style formatting tags. We'll assume that the regular font is Arial (specified in the TextSymbol) and that the sybolic font is Wingdings. So, I build a formatted string like so:

<FNT name="Wingdings" size="48">m</FNT>M<FNT name="Wingdings" size="48">x</FNT>

This string is what I set as text for my TextElement. Now, what I want to get is the bounds of the formatted text only, as it would appear on the screen with full symbology. The text appears fine -- with symbology -- on the screen. The problem is that the bounds of the text element include the length of the whole input string, formatting tags and all. In map units, the text is maybe 50' long, but the bounds are 1000'. I have tried QueryBounds and QueryOutline (both of which say they take symbology into account) and also ITextSymbol.GetTextSize. They all return the same crazy dimensions. ArcGIS is processing the formatting tags just fine as far as the text itself is concerned, but the bounds include the tags. I don't get it. This is a big concern, because I absolutely need to know the onscreen-text-only size of the TextElement for use in subsequent calculations.

Does anyone have any insights on this problem? Thank you all for the help ... and I apologize for asking such a specific ArcObjects question here, but I get exactly NO response from ESRI forums anymore.

Solution found:

Well, I just found the problem, and it has to do with the way the format string I show above was made in Python. I have been doing a lot of HTML code block output in Python lately, and I have been used to using triple quoted strings. That is what I did when building the format string. So the following is the actual line of code that builds the format string. (Lesson learned. I should always include a code snippet.)

fmtchar = """<FNT name="Wingdings" size="48">""" + eachChar + """</FNT>"""

It should be:

fmtchar = '<FNT name="Wingdings" size="48">' + eachChar + '</FNT>'

I find it interesing that ArcGIS would process the formatting tags and also count the tag characters as part of the text. Hmmm. BTW, let me know if I should put this solution in an answer to my own question.

share|improve this question
Did you try IQueryGeometry.GetGeometry ?… – Kirk Kuykendall Feb 11 '11 at 16:38
here is some code that Kirk posted back in 2002. might be of interest:… – Jakub Feb 12 '11 at 1:42
@Kirk - No I did not try that. In fact I had forgotten about that interface. I suspect, though, that it wouldn't make a difference: I found the problem, and it was a Python thing (see my edit to my question above.) BTW, I really hate to, but should I instead be submitting an answer to my own question in this case? I really don't have a good feel for proper protocol. – celticflute Feb 12 '11 at 15:39
@Jakub - Thank you. Kirk's 2002 code is indeed interesting, and it confirms that I am on the right track in the first place with the way I am going about things. – celticflute Feb 12 '11 at 16:11
@celticflute It looks like you found a solution so would you be able to transfer that to an Answer and then Accept it yourself, please? This is permissible to do. – PolyGeo Apr 19 '13 at 23:15

Your Answer


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

Browse other questions tagged or ask your own question.