Added dpi specific font scaling

This commit is contained in:
2018-08-24 18:19:09 +02:00
parent 48b57ecb80
commit ac77ee67ea
6 changed files with 118 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
using RothenburgAR.Common;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RothenburgAR.UI
{
public class FontsizeManager : Singleton<FontsizeManager>
{
private Dictionary<FontsizeClass, float> factors = new Dictionary<FontsizeClass, float>
{
{
FontsizeClass.Header, 1f
},
{
FontsizeClass.Body, 0.4f
}
};
public float GetFontsize(FontsizeClass sizeClass)
{
return Screen.dpi * factors[sizeClass];
}
}
public enum FontsizeClass
{
Header,
Body
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 78b8d14800915e84694580fb0d241681
timeCreated: 1535122456
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RothenburgAR.UI
{
public class FontsizeSelector : MonoBehaviour
{
public FontsizeClass SizeClass = FontsizeClass.Body;
void Start()
{
var tmproText = gameObject.GetComponent<TMPro.TextMeshProUGUI>();
if (tmproText != null)
{
tmproText.enableAutoSizing = true;
tmproText.fontSizeMax = FontsizeManager.Instance.GetFontsize(this.SizeClass);
tmproText.fontSizeMin = tmproText.fontSizeMax * 0.8f;
}
}
void Update()
{
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8b136c9157840904ba79e96d50f494bc
timeCreated: 1535125739
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -179,7 +179,7 @@ namespace RothenburgAR.Updater
{
//TODO check existing file for creation/alteration date to see if download is necessary
var mediaIDs = exhibit.Pois.Select(p => p.MediaId).ToList();
var mediaIDs = exhibit.Pois.Select(p => p.MediaId).Except(new List<string> { null }).ToList();
foreach (var mediaId in mediaIDs)
{