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>
|
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)
|
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.enableAutoSizing = true;
|
||||||
tmproText.fontSizeMax = FontsizeManager.Instance.GetFontsize(this.SizeClass);
|
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 DateTime downloadEndedTime = DateTime.Now.AddSeconds(1);
|
||||||
private float afterDownloadWaitTime = 3f;
|
private float afterDownloadWaitTime = 10f;
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1154,12 +1154,12 @@ MonoBehaviour:
|
|||||||
m_outlineColor:
|
m_outlineColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4278190080
|
rgba: 4278190080
|
||||||
m_fontSize: 185.6
|
m_fontSize: 120
|
||||||
m_fontSizeBase: 96
|
m_fontSizeBase: 120
|
||||||
m_fontWeight: 400
|
m_fontWeight: 400
|
||||||
m_enableAutoSizing: 1
|
m_enableAutoSizing: 0
|
||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 42
|
||||||
m_fontSizeMax: 1000
|
m_fontSizeMax: 420
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_textAlignment: 514
|
m_textAlignment: 514
|
||||||
m_isAlignmentEnumConverted: 1
|
m_isAlignmentEnumConverted: 1
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ GraphicsSettings:
|
|||||||
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 4800000, guid: 3a1c68c8292caf046bd21158886c5e40, type: 3}
|
- {fileID: 4800000, guid: 3a1c68c8292caf046bd21158886c5e40, type: 3}
|
||||||
- {fileID: 207, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 207, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_PreloadedShaders: []
|
m_PreloadedShaders: []
|
||||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||||
type: 0}
|
type: 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user