WKWebView extension to addScript for inject a custom font-face

webView.injectScript(fontFileName: "Pecita", type: .otf, fontFamilyName: "pecita")
webView.injectScript(fontFileName: "zagreb_underground", type: .ttf, fontFamilyName: "zagreb")

example screenshot


iOS 11

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Alamofire does support its use on supported platforms.

Once you have your Swift package set up, adding WebViewCustomFont as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ssauma/WebViewCustomFont.git", .upToNextMajor(from: "0.1.0"))


WebViewCustomFont is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'WebViewCustomFont'


Juyeon Lee, [email protected]


WebViewCustomFont is available under the MIT license. See the LICENSE file for more info.


View Github