Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Dynamic Type #90

Closed
deeje opened this issue Jun 3, 2018 · 4 comments
Closed

Support for Dynamic Type #90

deeje opened this issue Jun 3, 2018 · 4 comments
Labels
DownView Issues specific to DownView, the webview renderer feature request

Comments

@deeje
Copy link

deeje commented Jun 3, 2018

Report

What did you do?

change the current Text Size (either in Settings > Display & Brightness > Text Size, or in Control Center)

What did you expect to happen?

the size of text in DownView should change appropriately

What happened instead?

the size of text doesn't change relative to the Dynamic Type text size setting

@iwasrobbed
Copy link
Collaborator

In the spirit of open source code, I'm happy to accept a pull request for this (especially since it's an easy change). Thanks!

@Fenrikur
Copy link

Fenrikur commented Aug 9, 2018

Dynamic Type can already be used with Down e.g. by supplying a Down.toAttributedString(options: DownOptions, stylesheet: String?) with an appropriate stylesheet. The main issue here is that by setting the font attribute on all HTML elements, you will automatically strip clear any other changes to their style made via font-* attributes like font-weight or font-size, which results in <strong> and other elements that by default affect font-* attributes being rendered like any other unstyled part of the input.
While you can therefore easily support Dynamic Type by supplying * { font: -apple-system-body; } for the stylesheet parameter, you would need to apply additional styles (e.g. h1, h2, h3, h4, h5, h6, strong { font-weight: bold; } em { font-style: italic; } h1 { font-size: 175%; } h2 { font-size: 150%; } h3 { font-size: 130%; } h4 { font-size: 115%; } h5 { font-style: italic; }) alongside that rule to retain styling for headings etc.

iainsmith added a commit to iainsmith/ios that referenced this issue Oct 9, 2018
Down safely passes through the font property to WebKit.
This may result in issues for some tags. See this issue
for more detail. johnxnguyen/Down#90

Webkit dynamic text guide: http://www.interactiveaccessibility.com/blog/text-resizing-web-pages-ios-using-dynamic-type#.W70ePS-ZPUI
@iwasrobbed
Copy link
Collaborator

iwasrobbed commented Nov 10, 2018

It looks like a workaround has been provided, so I'm going to close this issue. I'm also open to accepting a pull request in the future to add support 👍

As an FYI, DownView is controlled by the HTML and CSS in this bundle: https://github.com/iwasrobbed/Down/blob/master/Resources/DownView.bundle and you can pass in your own bundle if you need more customizations: https://github.com/iwasrobbed/Down/blob/master/Source/Views/DownView.swift#L26

See workarounds:

@iwasrobbed iwasrobbed added the DownView Issues specific to DownView, the webview renderer label Nov 10, 2018
@iwasrobbed
Copy link
Collaborator

FYI: this is now possible via the default Styler via #177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DownView Issues specific to DownView, the webview renderer feature request
Projects
None yet
Development

No branches or pull requests

3 participants