pass in font family to web reader

This commit is contained in:
Satindar Dhillon
2022-06-03 10:27:47 -07:00
parent f177262787
commit afd2acf302
5 changed files with 18 additions and 3 deletions

View File

@ -152,7 +152,8 @@ import WebKit
isDark: UITraitCollection.current.userInterfaceStyle == .dark,
fontSize: fontSize(),
lineHeight: lineHeight(),
margin: margin()
margin: margin(),
fontFamily: .merriweather
)
.styledContent,
baseURL: ViewsPackage.bundleURL

View File

@ -1,6 +1,7 @@
import Foundation
import Models
import Utils
import Views
struct WebReaderContent {
let textFontSize: Int
@ -10,6 +11,7 @@ struct WebReaderContent {
let highlightsJSONString: String
let item: LinkedItem
let themeKey: String
let fontFamily: WebFont
init(
htmlContent: String,
@ -18,7 +20,8 @@ struct WebReaderContent {
isDark: Bool,
fontSize: Int,
lineHeight: Int,
margin: Int
margin: Int,
fontFamily: WebFont
) {
self.textFontSize = fontSize
self.lineHeight = lineHeight
@ -27,6 +30,7 @@ struct WebReaderContent {
self.highlightsJSONString = highlightsJSONString
self.item = item
self.themeKey = isDark ? "Gray" : "LightGray"
self.fontFamily = fontFamily
}
// swiftlint:disable line_length
@ -77,6 +81,7 @@ struct WebReaderContent {
}
window.fontSize = \(textFontSize)
window.fontFamily = "\(fontFamily.rawValue)"
window.margin = \(margin)
window.lineHeight = \(lineHeight)
window.localStorage.setItem("theme", "\(themeKey)")

View File

@ -1,6 +1,14 @@
import SwiftUI
import Utils
public enum WebFont: String {
case inter = "Inter"
case merriweather = "Merriweather"
case lyon = "Lyon"
case sfmono = "SFMono"
case tisa = "Tisa"
}
public struct WebPreferencesPopoverView: View {
let increaseFontAction: () -> Void
let decreaseFontAction: () -> Void

File diff suppressed because one or more lines are too long

View File

@ -41,6 +41,7 @@ const App = () => {
highlightBarDisabled={true}
highlightsBaseURL="https://example.com"
fontSize={window.fontSize ?? 18}
fontFamily={window.fontFamily ?? 'merriweather'}
margin={window.margin}
lineHeight={window.lineHeight}
articleMutations={{