Hi all,
I have some code like this:
When the font is Serif, the label misses off the last word. When the font is Sans-Serif, the label shows all the words, but the background colour continues to the right of the last word in the label. This suggests to me that in the first instance the measured width is shorter than the actual label width required to contain all the text when the font is Serif, and longer than required for a Serif font.
Any ideas what i am doing wrong?
I have some code like this:
B4X:
If TestNo = 1 Then
lblTestText(i).TextColor = Colors.Black
lblTestText(i).Typeface = Typeface.CreateNew(Typeface.SERIF, Typeface.STYLE_NORMAL)
Else
lblTestText(i).TextColor = Colors.ARGB(255,0,128, 128)
lblTestText(i).Typeface = Typeface.CreateNew(Typeface.SANS_SERIF, Typeface.STYLE_NORMAL)
End If
lblTestText(i).Height = LabelHeight
lblTestText(i).TextSize = FontSize
lblTestText(i).Width = Canvas1.MeasureStringWidth(lblTestText(i).Text, lblTestText(i).Typeface, FontSize)
lblTestText(i).Color = Colors.LightGray
When the font is Serif, the label misses off the last word. When the font is Sans-Serif, the label shows all the words, but the background colour continues to the right of the last word in the label. This suggests to me that in the first instance the measured width is shorter than the actual label width required to contain all the text when the font is Serif, and longer than required for a Serif font.
Any ideas what i am doing wrong?