Added first version of dpi dependant font size calculation
This commit is contained in:
@@ -7,19 +7,37 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
public class FontsizeManager : Singleton<FontsizeManager>
|
||||
{
|
||||
private Dictionary<FontsizeClass, float> factors = new Dictionary<FontsizeClass, float>
|
||||
private Dictionary<FontsizeClass, float> sizes = new Dictionary<FontsizeClass, float>
|
||||
{
|
||||
{
|
||||
FontsizeClass.Header, 1f
|
||||
FontsizeClass.Header, 0.5f
|
||||
},
|
||||
{
|
||||
FontsizeClass.Body, 0.4f
|
||||
FontsizeClass.Body, 0.2f
|
||||
}
|
||||
};
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("Screen dpi: " + Screen.dpi);
|
||||
}
|
||||
|
||||
public float GetFontsize(FontsizeClass sizeClass)
|
||||
{
|
||||
return Screen.dpi * factors[sizeClass];
|
||||
var dpi = 420;//Screen.dpi;
|
||||
var res = Screen.currentResolution;
|
||||
|
||||
// Screen diagonal in px
|
||||
var diagonal = Mathf.Sqrt(Mathf.Pow(res.height, 2) + Mathf.Pow(res.width, 2));
|
||||
|
||||
// Screen diagonal in logical inches
|
||||
var diagonalIn = diagonal / dpi;
|
||||
|
||||
var ratio = diagonalIn * sizes[sizeClass];
|
||||
var fontsizePx = diagonal * ratio;
|
||||
var fontsizePt = fontsizePx * 0.75f;
|
||||
|
||||
return dpi * sizes[sizeClass];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace RothenburgAR.UI
|
||||
{
|
||||
tmproText.enableAutoSizing = true;
|
||||
tmproText.fontSizeMax = FontsizeManager.Instance.GetFontsize(this.SizeClass);
|
||||
tmproText.fontSizeMin = tmproText.fontSizeMax * 0.8f;
|
||||
tmproText.fontSizeMin = tmproText.fontSizeMax * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace RothenburgAR.Updater
|
||||
}
|
||||
|
||||
private DateTime downloadEndedTime = DateTime.Now.AddSeconds(1);
|
||||
private float afterDownloadWaitTime = 3f;
|
||||
private float afterDownloadWaitTime = 10f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
@@ -1154,12 +1154,12 @@ MonoBehaviour:
|
||||
m_outlineColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4278190080
|
||||
m_fontSize: 185.6
|
||||
m_fontSizeBase: 96
|
||||
m_fontSize: 120
|
||||
m_fontSizeBase: 120
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 1
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 1000
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 42
|
||||
m_fontSizeMax: 420
|
||||
m_fontStyle: 0
|
||||
m_textAlignment: 514
|
||||
m_isAlignmentEnumConverted: 1
|
||||
|
||||
Reference in New Issue
Block a user