Gemini/GeminiRenderer/Fonts.swift

42 lines
888 B
Swift

//
// Fonts.swift
// GeminiRenderer
//
// Created by Shadowfacts on 7/13/20.
//
import SwiftUI
import GeminiFormat
extension Document.HeadingLevel {
var font: Font {
let style: Font.TextStyle
switch self {
case .h1:
style = .title
case .h2:
if #available(macOS 10.16, iOS 14.0, *) {
style = .title2
} else {
style = .headline
}
case .h3:
if #available(macOS 10.16, iOS 14.0, *) {
style = .title3
} else {
style = .subheadline
}
}
return .system(style, design: .serif)
}
}
extension Font {
static var documentBody: Font {
.system(.body, design: .serif)
}
static var documentBodyPreformatted: Font {
.system(.body, design: .monospaced)
}
}