Font size and screen size in Canvas

Fabrice La

Active Member
Licensed User
Longtime User
Hi
I woul like to know how to have font size different in different screen size (phone, tablette) in Canvas using drawtext or drawtextrotate ?
THX

Sub ecrit2 (Text As String, ax1 As Float, ay1 As Float, testes As Boolean, couleur As Int)
Dim haut, moitie As Float
haut = th.Height - 32dip
moitie = haut/2
Dim tailleL, espace As Float
tailleL = 100%y
'Log("Taille :" & tailleL)
If tailleL > 1150 Then
'tailleL = 30dip
espace = 0
Else
'tailleL = 10dip
espace = 0
End If
tailleL = IntToDIP((tailleL/100))
If testes Then
cvsTest.DrawTextRotated(Text, ax1+espace, ay1+moitie, Typeface.DEFAULT, tailleL, couleur, "RIGHT", 90)
Else
cvsTest.DrawTextRotated(Text, ax1+espace, ay1, Typeface.DEFAULT, tailleL, couleur, "RIGHT", 90)
End If
End Sub

Sub IntToDIP(Integer As Int) As Int
Dim r As Reflector
Dim scale As Float
r.Target = r.GetContext
r.Target = r.RunMethod("getResources")
r.Target = r.RunMethod("getDisplayMetrics")
scale = r.GetField("density")

Dim DIP As Int
DIP = Integer * scale + 0.5
Return DIP
End Sub
 

Fabrice La

Active Member
Licensed User
Longtime User
I read on Autoscale but I did see something about FontSize in Canvas.
I put AutoScaleAll in designer script and modify program :

If testes Then
cvsTest.DrawTextRotated(Text, ax1+espace, ay1+moitie, Typeface.DEFAULT, 14, couleur, "RIGHT", 90)
Else
cvsTest.DrawTextRotated(Text, ax1+espace, ay1, Typeface.DEFAULT, 14, couleur, "RIGHT", 90)
End If

The fonts have the same size in:
800 x 1232, scale = 1 (160 dpi) tablette 10' Galaxy tab
360 x 640, scale = 1 (160 dpi) Phone 4.3 ' Galaxy 3
 
Upvote 0

Fabrice La

Active Member
Licensed User
Longtime User
Ok

But if I specify the Text size in designer view (How for a Canvas ?)
I have to specify, anyway, the text size in DrawTextRotated in program ??!!
 
Upvote 0
Top