In the Paint Event of Canvas, a picture is created that matches the size of the text t.
'Paint Event
Var t as String = "-200008"
Var pic as Picture
Var textWidth as Double = g.TextWidth(t)
Var textHeight as Double = g.TextHeight
pic = new Picture(textWidth+1,textHeight+1) 'Picture mit den ausmassen des Textes erstellen
'copy parameters
pic.Graphics.FontName = g.FontName
pic.Graphics.FontSize = g.FontSize
pic.Graphics.FontUnit = g.FontUnit
pic.Graphics.Bold = g.Bold
pic.Graphics.Italic = g.Italic
pic.Graphics.CharacterSpacing = g.CharacterSpacing
Var w1 as Double = g.TextWidth(t)
Var w2 as Double = pic.Graphics.TextWidth(t)
break
But,
I don’t understand, why the values of w1 (Graphics from Paint Event) and w2 (Graphics from Picture) are different.
'Paint Event
Var t as String = "-200008"
Var pic as Picture
Var textWidth as Double = g.TextWidth(t)
Var textHeight as Double = g.TextHeight
pic = new Picture(textWidth+1,textHeight+1) 'Picture mit den ausmassen des Textes erstellen
pic.VerticalResolution = 96
pic.HorizontalResolution = 96
'copy parameters
pic.Graphics.FontName = g.FontName
pic.Graphics.FontSize = g.FontSize
pic.Graphics.FontUnit = g.FontUnit
pic.Graphics.Bold = g.Bold
pic.Graphics.Italic = g.Italic
pic.Graphics.CharacterSpacing = g.CharacterSpacing
Var w1 as Double = g.TextWidth(t)
Var w2 as Double = pic.Graphics.TextWidth(t)
'Var r1 as Double = g.
break
w1 and w2 have the same value as before at the break Point:
I try to draw the Text to the new created Picture, but the text is clipped because the new Piture is to small for the text because the TextWidth for the original Graphics is different.to the Picture.Graphic. Why?