Accessing iOS & Android accessibility system font scale values in Unity

In a project recently I needed to find the system font size a user had set in their system preferences, on both Android and iOS devices.

unity
ios
android
accessibility

Published 4 years ago

Finding the font scale value on iOS

This refers to the system value found on an iOS device by going to: Settings > Accessibility > Display & Text Size > Larger Text.

With iOS it took a bit of time to really find how it was set. I discovered preferredContentSizeCategory in the Apple developer documentation, and with a little bit of Objective C and creating an iOS Unity plugin, managed to return values we needed.

It returns constants on what the user has set in their system preferences, which will then allow you to set an appropriate scale.

Here's the full list of constants I found.

UICTContentSizeCategoryXS UICTContentSizeCategoryS UICTContentSizeCategoryM UICTContentSizeCategoryL UICTContentSizeCategoryXL UICTContentSizeCategoryXXL UICTContentSizeCategoryXXXL // (This is larger than UICTContentSizeCategoryXXXL) // and is when the "Larger Accessibility Sizes" button is toggled UICTContentSizeCategoryAccessibilityM UICTContentSizeCategoryAccessibilityL UICTContentSizeCategoryAccessibilityXL UICTContentSizeCategoryAccessibilityXXL UICTContentSizeCategoryAccessibilityXXXL

Finding the font scale value in Android

This refers to the Android system font size value.

For Android, there is something similar but it provided an actual scale value we could utilise as opposed to constants like in iOS.

Reading the documentation I was able to find fontScale which helped to provide a value back into Unity with another custom plugin.

Let's chat about your next project

Whether you're looking for a single contractor or a full team, I regularly collaborate with a trusted collective of designers and developers to deliver large-scale projects.

See also...

CnCNet - Website & App Development

Comprehensive design and development of responsive web and desktop apps for CnCNet, enhancing user experience and accessibility.

AR Configurator for E-Bikes

Bespoke augmented reality web configurator for E-Bikes, offering full customization options, including color choices and feature configurations.

Stock Investment App

Real-time stock investment app for web and mobile, built with TypeScript, React, and WebSockets, delivering fast, responsive, and data-driven experiences.

KickTown Football - Website

Custom-built website and API's for KickTown Football, integrating a merchandise store, booking system, and seamless user experience.

Tempest Rising - Official Website

Website development for Slipgate Ironworks' Tempest Rising, crafted to deliver a sleek, immersive experience for fans and players.

Facial Cosmetic Simulation - Web App

React and TypeScript-powered web app for visualizing facial cosmetic treatments, offering a cutting-edge, interactive user experience.

C&C Community Website

Command & Conquer Community platform with improved SEO, a sleek interface, and content integrations like Twitch and Steam, creating a hub for fans and creators.

React Native Health App

Custom Android and iOS health app developed with React Native and TypeScript, tailored for a health-tech startup, ensuring cross-platform compatibility.

Oriental Garden Restaurant - Website Redesign

Website redesign featuring an online ordering system that boosts sales and enhances customer engagement with a modern, intuitive interface.