Select to view content in your preferred language

Label Expression - set font size

2559
2
03-24-2017 04:03 AM
AndrewIngall1
Occasional Contributor

I am trying to set the font size of my label pragmatically and currently have the following, however all of the labels appear to be being drawn with a font size of 8, which is set in the label settings:-

Function FindLabel ( [TextString], [FontSize] )

FindLabel = "<FNT Size = '([FontSize]/354)'>" + [TextString] + "</FNT>"

End Function

Any ideas how to set the font size using an expression.

Thanks

0 Kudos
2 Replies
TedKowal
Honored Contributor

I am assuming you want this in VB Script......  so something like  below would work..... my Font Size is based upon the Bridge Width while I am labeling the Bridge Number ....

Function FindLabel ( [BRIDGE_NUM],[Width])
  myFontSize = int([Width]/10)
  myFormat = "<FNT name='Arial' size = '" & myFontSize & "'>"
  FindLabel = myFormat & [BRIDGE_NUM] & "</FNT>"
End Function

GISAdmin4
New Contributor

Here is my working sample with ArcPro in 2023.  

Function FindLabel ( [STREET_NUMBER], [notes] )
If IsNull([notes]) Then
  FindLabel = [STREET_NUMBER]
Else
 FindLabel = [STREET_NUMBER] +   vbcrlf + "<FNT size='2'>" + [notes] + "</FNT>"
End If

End Function

 

label_font_size_1.pnglabel_font_size_2.png

 

 

 

 

0 Kudos