{"id":108680,"date":"2023-08-30T07:00:00","date_gmt":"2023-08-30T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=108680"},"modified":"2023-08-30T07:49:44","modified_gmt":"2023-08-30T14:49:44","slug":"20230830-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20230830-00\/?p=108680","title":{"rendered":"How can I programmatically obtain the value of the &#8220;Make text bigger&#8221; slider?"},"content":{"rendered":"<p>The XAML UI framework automatically honors the Windows &#8220;Make text bigger&#8221; setting, but what if you&#8217;re using some other framework and want to respect the text scale factor?<\/p>\n<p>You can query the value of the &#8220;Make text bigger&#8221; slider from the <code>Windows.<wbr \/>UI.<wbr \/>ViewManagement.<wbr \/>UISettings.<wbr \/>TextScaleFactor<\/code> property, and then incorporate that value into your font size calculations.\u00b9<\/p>\n<pre>\/\/ C#\r\ndouble GetTextScaleFactor()\r\n{\r\n    return (new Windows.UI.\r\n                ViewManagement.UISettings()).TextScaleFactor;\r\n}\r\n\r\n\/\/ C++\/WinRT\r\n#include &lt;winrt\/Windows.UI.ViewManagement.h&gt;\r\n\r\ndouble GetTextScaleFactor()\r\n{\r\n    return winrt::Windows::UI::\r\n           ViewManagement::UISettings().TextScaleFactor();\r\n}\r\n\r\n\/\/ C++\/CX\r\n\r\ndouble GetTextScaleFactor()\r\n{\r\n    return (ref new Windows::UI::\r\n        ViewManagement::UISettings())-&gt;TextScaleFactor;\r\n}\r\n\r\n\/\/ C++\/WRL\r\n#include &lt;Windows.UI.ViewManagement.h&gt;\r\n\r\nHRESULT GetTextScaleFactor(double* value)\r\n{\r\n    *value = 1.0;\r\n\r\n    using namespace Microsoft::WRL;\r\n    using namespace Microsoft::WRL::Wrappers;\r\n\r\n    ComPtr&lt;IInspectable&gt; instance;\r\n    HRESULT hr = RoActivateInstance(HStringReference(\r\n        RuntimeClass_Windows_UI_ViewManagement_UISettings).Get(),\r\n        &amp;instance);\r\n    if (FAILED(hr)) return hr;\r\n\r\n    ComPtr&lt;ABI::Windows::UI::ViewManagement::IUISettings2&gt;\r\n        settings2;\r\n    hr = instance.As(&amp;settings2);\r\n    if (FAILED(hr)) return hr;\r\n\r\n    hr = settings2-&gt;get_TextScaleFactor(value);\r\n    if (FAILED(hr)) return hr;\r\n\r\n    return S_OK;\r\n}\r\n<\/pre>\n<p>You can also subscribe to the <code>Text\u00adScale\u00adFactor\u00adChanged<\/code> event to be notified when the text scale factor changes.<\/p>\n<p>\u00b9 Note that the text scale factor is not a blind scaling applied to all fonts. It generally applies to your main body font, and the scaling applied to other fonts diminishes based on the distance of those other fonts from the body font. For example, chapter headings should not be magnified by as large a factor as body text.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The text scale factor property.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-108680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>The text scale factor property.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/108680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=108680"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/108680\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=108680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=108680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=108680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}