Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25847] iOS: Accessibility support for Dynamic Type

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2020-01-07T14:41:44.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.0.0
ComponentsiOS
Labels2019-cl
ReporterVictor Vazquez Montero
AssigneeUnknown
Created2018-03-07T17:28:02.000+0000
Updated2020-01-07T14:41:44.000+0000

Description

Feature Request:

Trying to use the accessibility options in iOS: Specifically the option to use larger text (Dynamic Type) but the changes are not applied to the app. Setting the font size to use "sp" as unit identifier for the font size which works on Android but not in iOS. font: { fontSize: '16sp' } In the fontSize documentation it says: "iOS ignores any unit specifier after the size value." when changing font size in accessibility options the alert dialogs have the font size change but nothing else. Can we implement Dynamic Type support so that font size is also changed within the app?

Attachments

FileDateSize
app.zip2019-11-22T19:10:42.000+00005125641

Comments

  1. Victor Vazquez Montero 2018-03-07

    Hey [~nderzhak] would you be the write person to assign for this?
  2. Hans Knöchel 2018-03-08

    Some notes here: * We already support one portion of it - the [textStyle](http://docs.appcelerator.com/platform/latest/#!/api/Font-property-textStyle) properties that scale automatically * Since iOS, native developers can listen to the [UIContentSizeCategoryDidChangeNotification](https://developer.apple.com/documentation/uikit/uicontentsizecategorydidchangenotification) notification that notifies developers about font-size changes. We could expose the same on the Ti.UI.Label namespace, e.g. as an event like this:
       Ti.App.iOS.addEventListener('fontchange', function(e) {
         // See size-category with: e.sizeCategory, one of https://developer.apple.com/documentation/uikit/uicontentsizecategory
       });
       
    * For iOS 10+, iOS started to realize the dynamic font management is bad, so they came up with [adjustsFontForContentSizeCategory](https://developer.apple.com/documentation/uikit/uicontentsizecategoryadjusting/1771731-adjustsfontforcontentsizecategor?language=objc) which is a boolean that can be set for each label instead of globally. Read more about this [here](https://useyourloaf.com/blog/auto-adjusting-fonts-for-dynamic-type/) and let us know what of these should be implemented.
  3. Hans Knöchel 2018-03-09

    Side-note: It can already be used today, is the textStyle property in the font object is set to Ti.UI.TEXT_STYLE_BODY, e.g.:
       var label = Ti.UI.createLabel({
         text: 'Hello World!',
         font: {
           textStyle: Ti.UI.TEXT_STYLE_BODY
         }
       });
       
    After changing the accessibility size in the settings, it will adopt it automatically when reopening the app. And again, make sure to check the [other constants](http://docs.appcelerator.com/platform/latest/#!/api/Font-property-textStyle) as well - they are meant to cover all kind of native layout sizes, e.g. headline, subtitle, different title sizes, captions and callouts.
  4. Hans Knöchel 2018-03-14

    For using custom fonts with textStyles the iOS 11+ UIFontMetrics API can be used. If you use Hyperloop, the following could be done today:
       // Import the native classes
       var UILabel = require('UIKit/UILabel');
       var UIFont = require('UIKit/UIFont');
       var UIFontMetrics = require('UIKit/UIFontMetrics');
       var UIFontTextStyleBody = require('UIKit').UIFontTextStyleBody;
       
       // Cast your Ti.UI.Label to a UILabel
       var myLabel = Ti.UI.createLabel({ text: 'Hello World' });
       var nativeLabel = UILabel.cast(myLabel);
       
       // Create the iOS 11+ font-metrics
       var font = UIFont.fontWithNameSize('<custom-font-name>', 15);
       var fontMetrics = UIFontMetrics.metricsForTextStyle(UIFontTextStyleBody);
       
       // Assign the font-metrics to the native label
       nativeLabel.font = fontMetrics.scaledFontForFont(font);
       
    This could eventually also be done in Titanium, but please note that it would still be iOS 11+ due to the Apple limitations in earlier versions. Road more about the API [here](https://useyourloaf.com/blog/using-a-custom-font-with-dynamic-type/). Once approved by product management, we can scope and implement the change.
  5. Vijay Singh 2019-11-22

    PR - https://github.com/appcelerator/titanium_mobile/pull/11364 Test Case 1-
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       
       var label = Ti.UI.createLabel({
          text: 'Hello World!',
         font: {
         	fontFamily: 'American Typewriter',
           textStyle: Ti.UI.TEXT_STYLE_BODY
         }
       });
       
       win.add(label);
       win.open();
       
    Test Case 2 - Use attached app.zip with new alloy app. Steps to test - 1. Launch the app. See the font type and text size. 2. Close app. 3. Open Settings->Accessibility->Display & Text Size-> Large Text. Increase text size from slider. 4. Open app. See the font type and text size. It should vary.
  6. Satyam Sekhri 2019-12-16

    FR Passed. Waiting on Jenkins build.
  7. Christopher Williams 2019-12-18

    merged to master for 9.0.0
  8. Samir Mohammed 2020-01-07

    Closing ticket, fix verified in SDK version 9.0.0.v20200103081513. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11364

JSON Source