mastodon.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
The original server operated by the Mastodon gGmbH non-profit

Administered by:

Server stats:

348K
active users

Has anyone figured out how to get a custom font in a WKWebView to match the dynamic type settings of a UIKit/SwiftUI view?

`font: -apple-system-body` will match .body in the view with the San Francisco system font, but I can't find something similar if I'm using `font: “Custom”`

I _really_ don't want to start sniffing around in font metrics (especially in SwiftUI where they are essentially unavailable).

Joseph Duffy

@chockenberry bugs.webkit.org/show_bug.cgi?i seems to show that you can set `font: -apple-system-body` on e.g. the `html` element and then use `font-size: 1.2rem` to be 20% larger than that base font. Presumably you can also then update the font on a per-element basis (or for the whole page with `body`).

bugs.webkit.org260880 – WebKit does not respect system font size for rem units

@josephduffy Thanks! This looks promising:

html {
font: -apple-system-title;
font-family: "Custom";
font-variant-emoji: emoji;
}

Gets the metrics with `font` and overrides system font with `font-family`.