Added first version of dpi dependant font size calculation

This commit is contained in:
2018-08-24 21:21:55 +02:00
parent ac77ee67ea
commit cfcfb4b5b9
5 changed files with 31 additions and 11 deletions

View File

@@ -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];
}
}

View File

@@ -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;
}
}

View File

@@ -234,7 +234,7 @@ namespace RothenburgAR.Updater
}
private DateTime downloadEndedTime = DateTime.Now.AddSeconds(1);
private float afterDownloadWaitTime = 3f;
private float afterDownloadWaitTime = 10f;
void Update()
{