Windows 8.1通用应用程序字体缩放,显示分辨率不断变化 [英] Windows 8.1 Universal app font scaling with changing display resolution

查看:113
本文介绍了Windows 8.1通用应用程序字体缩放,显示分辨率不断变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序UI在不同屏幕分辨率之间进行了很大的扩展,除了根本不进行缩放的字体大小。因此,例如,当我设置在768x1366看起来正确的字体大小并在1080x1920处显示应用程序时,UI重新缩放,但所有文本最终都很小。同样的效果适用于Windows Phone 8等设备。我尝试使用主题字体大小值并更改为Segoe UI字体,但没有区别。我可以编写一个iValueConverter来根据显示分辨率更改fontsize但这对于做一些肯定应该由框架处理的事情来说是一种笨拙的方法吗?



有没有人可以回答如何控制字体缩放?

My app UI scales great between different screen resolutions except for the font sizes which don't scale at all. So for example, when I set the font size that looks correct at 768x1366 and display the app at 1080x1920 the UI rescales but all the text ends up small. The same effect applies to devices such as the Windows Phone 8. I've tried using Theme font size values and changed to Segoe UI font but there's no difference. I could write an iValueConverter to change the fontsize based on display resolution but that would be a clumsy method for doing something that surely should be taken care of by the framework?

Has anyone an answer as to how font scaling can be controlled?

推荐答案

这是我目前使用的一个不完美的解决方案:



目前我已经使用了一个使用以下逻辑的FontSize的iValueConverter:



(FontSize在1366x768看起来很好分辨率)/(分辨率为1366×768的屏幕高度)×(运行时的屏幕高度)=> var newFontSize =(int)Math.Round((oldFontSize / 768.0)* screenHeight,0);



我使用VS的设计视图分辨率为1366x768。在我的笔记本电脑上以1920x1080分辨率运行应用程序使用iValueConverter放大它们的字体。今天,我发现在朋友的PC上测试应用程序的分辨率介于1366x768到1920x1080之间的字体太大了。所以看来,要么考虑到其他显示器分辨率的不同缩放或者iValueConverter方法不正确,我的逻辑需要更复杂!



有没有人得到了更好的解决方案?
Here's an imperfect solution I'm using at the moment:

For the moment I've resorted to an iValueConverter for the FontSize that uses the following logic:

(FontSize that looks Ok at 1366x768 resolution) / (Screen Height at 1366x768 resolution) x (Screen Height at Runtime) => var newFontSize = (int)Math.Round((oldFontSize / 768.0) * screenHeight, 0);

I'm using VS with the design view resolution or 1366x768. Running the App on my Laptop at 1920x1080 resolution the fonts where fine using the iValueConverter to enlarge them. Today, I found that on testing the app on a friends PC with a resolution somewhere between 1366x768 and 1920x1080 the fonts where much too large. So it seems, either my logic needs to be more complicated to take account of different scaling at other display resolutions or the iValueConverter approach is not the correct one!

Has anyone got a better solution?


这篇关于Windows 8.1通用应用程序字体缩放,显示分辨率不断变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆