Private Sub AdjustTextOverlayFont
If xTextOverlay.IsInitialized = False Then Return
'Calculate font's size equal to button's size
Dim baseSize As Float = Min(mBase.Width, mBase.Height) / 8
If baseSize < 10 Then baseSize = 10.0
If baseSize > 24 Then baseSize = 24.0
'Create B4XFont
If mCustomFontFile <> "" Then
Log(mCustomFontFile)
Try
#If B4A
Dim tf As Typeface
tf = Typeface.LoadFromAssets(mCustomFontFile)
xTextOverlay.Font = xui.CreateFont2(tf, baseSize)
#Else If B4i
xTextOverlay.Font = xui.CreateFont(mCustomFontFile, baseSize)
#Else If B4J
xTextOverlay.Font = xui.CreateFont2(xui.LoadFont(File.DirAssets, mCustomFontFile, baseSize), baseSize)
#End If
Catch
xTextOverlay.Font = xui.CreateDefaultFont(baseSize)
End Try
Else
xTextOverlay.Font = xui.CreateDefaultFont(baseSize)
End If
End Sub