oficina / docs Public

Docs for Mac and iOS: Carlito, sixteen fonts, never a flash

Both apps bundle the sixteen picker families and register them before
the first window, so the first frame is already Carlito and no text is
ever drawn in a fallback first. Font resolution matches the web and the
renderer; Sans is no longer the default; each picker entry is drawn in
its own face; pasted font stacks map in order against the shared
vectors; and a Font licences screen shows every family's OFL text.
Reviewed by GPT-6-Astra via Codex (#84).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from feat/fonts-native into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 35ffb28b8c73b535ee0b2185daed61cb28e571aa parent 5a951ba
118 files changed, +2,937 −112
  • native/BUILDING.md +9 −0
  • native/PARITY.md +1 −1
  • native/apple/Package.swift +1 −1
  • native/apple/Sources/DocsApp/DocsApp.swift +7 −0
  • native/apple/Sources/DocsApp/DocsWindowCommands.swift +3 −0
  • native/apple/Sources/DocsKit/DocsClipboardWriter.swift +5 −3
  • native/apple/Sources/DocsKit/DocsEditorCommands.swift +4 −2
  • native/apple/Sources/DocsKit/DocsFontLicences.swift +119 −0
  • native/apple/Sources/DocsKit/DocsFontPicker.swift +142 −0
  • native/apple/Sources/DocsKit/DocsFonts.swift +215 −15
  • native/apple/Sources/DocsKit/DocsHTMLClipboard.swift +9 −8
  • native/apple/Sources/DocsKit/DocsRichClipboard.swift +10 −4
  • native/apple/Sources/DocsKit/DocsWorkspace.swift +12 −1
  • native/apple/Sources/DocsKit/DocumentCommands.swift +18 −4
  • native/apple/Sources/DocsKit/DocumentToolbarSelection.swift +3 −2
  • native/apple/Sources/DocsKit/EditorToolbar.swift +5 −5
  • native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caladea/Caladea-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caladea/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/carlito/Carlito-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/carlito/OFL.txt +94 −0
  • native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/caveat/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/fonts.json +411 −0
  • native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/garamond/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/inter/Inter-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/inter/Inter-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/inter/Inter-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/inter/Inter-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/inter/LICENSE.txt +92 −0
  • native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/jetbrains/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LICENSE-OFL-1.1.txt +1 −0
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationMono-Bold.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationMono-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationMono-Italic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationMono-Regular.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSans-Bold.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSans-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSans-Italic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSans-Regular.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSerif-Bold.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSerif-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSerif-Italic.ttf binary
  • native/apple/Sources/DocsKit/{Resources/Fonts => Fonts/liberation}/LiberationSerif-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/literata/Literata-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/literata/Literata-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/literata/Literata-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/literata/Literata-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/literata/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/notosans/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/playfair/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/plexsans/LICENSE.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/sourcesans/LICENSE.md +93 −0
  • native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-BoldIt.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-It.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourceserif/LICENSE.md +93 −0
  • native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-BoldIt.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-It.ttf binary
  • native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Regular.ttf binary
  • native/apple/Sources/DocsKit/Fonts/zilla/OFL.txt +93 −0
  • native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Bold.ttf binary
  • native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-BoldItalic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Italic.ttf binary
  • native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Regular.ttf binary
  • native/apple/Sources/DocsKit/NativeDocumentTextView.swift +26 −0
  • native/apple/Sources/DocsKit/NativeTextProjection.swift +26 −4
  • native/apple/Sources/DocsKit/Resources/ThirdPartyNotices.txt +38 −0
  • native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings +3 −3
  • native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings +3 −3
  • native/apple/Tests/DocsKitTests/BrowserTypographyTests.swift +30 −7
  • native/apple/Tests/DocsKitTests/DocsFontLicencesTests.swift +50 −0
  • native/apple/Tests/DocsKitTests/DocsFontPickerTests.swift +175 −0
  • native/apple/Tests/DocsKitTests/DocsFontsTests.swift +259 −0
  • native/apple/Tests/DocsKitTests/DocumentAssetsTests.swift +4 −2
  • native/apple/Tests/DocsKitTests/DocumentTypographyTests.swift +18 −16
  • native/apple/Tests/DocsKitTests/RichClipboardTests.swift +2 −1
  • native/ios/Review/DocsReviewPhone.swift +2 −0
  • native/scripts/check-native.sh +2 −0
  • native/scripts/sync-fonts.py +85 −0

CI passed — run details

landed from feat/fonts-native

diff --git a/native/BUILDING.md b/native/BUILDING.md
index 7e873cd..6788229 100644
--- a/native/BUILDING.md
+++ b/native/BUILDING.md
@@ -23,6 +23,15 @@ server/web gate. `--mutations` additionally proves representative faulty changes
are caught, restoring every changed source and saving logs under
`native/build/mutation-logs`. Do not run mutations concurrently with builds.
+The apps bundle every font in Docs' shared list
+(`internal/fonts/fonts.json`): `native/apple/Sources/DocsKit/Fonts` is a
+copy of the manifest, each family's TTFs and its licence, made by
+`native/scripts/sync-fonts.py`. Rerun it whenever `internal/fonts` changes;
+the native gate runs it with `--check`, on Linux too, and fails on any
+drift. Git stores the identical files once. The apps register every face
+synchronously before their first window and draw each run from its bundled
+file, never from a copy of the same name installed on the machine.
+
`CARGO` can select a non-default Cargo executable; put its matching Rust toolchain
on `PATH`. If that toolchain needs an explicit LLVM runtime lookup path, set
`DOCS_LLVM_LIBRARY_PATH`. No generated native framework is committed.
diff --git a/native/PARITY.md b/native/PARITY.md
index 78d1e8f..9cccb3c 100644
--- a/native/PARITY.md
+++ b/native/PARITY.md
@@ -10,7 +10,7 @@ CRDT engine. No web editor or HTML rendering engine is embedded.
| Command-K jump to document | Native searchable sheet using server-ranked results, arrows/Enter/Escape | iPhone result-button navigation and iPad actual responder-command dispatch + software submit passed; physical keyboard/HID acceptance remains unverified |
| Paragraph editing and multiple paragraphs | Generation-bound UTF-16 operations, native IME buffering | Actual WASM rapid-newline/typeahead, cross-paragraph replacement, emoji and AppKit marked-text tests |
| Bold, italic, inline code, clear formatting | Native toolbar and keyboard commands | iPhone/iPad bold persisted through fresh server export; command tests |
-| Font family, size, headings, alignment, indentation | Bundled Liberation faces and native paragraph attributes | Projection/command tests; complete visual matrix still requires review |
+| Font family, size, headings, alignment, indentation | All sixteen families of `internal/fonts/fonts.json` bundled, Carlito the default; native paragraph attributes | DocsFontsTests, DocsFontPickerTests, WebKit line-break comparison per family; complete visual matrix still requires review |
| Bullet/ordered lists, nesting, range conversion, quote toggles | Scoped CRDT structural operations | Rust structural tests and actual Swift/WASM range-list tests |
| Typed heading/list/quote shortcuts and Backspace reversal | Native input-rule interception | Native AppKit and actual WASM rule/revert/typeahead tests; iPhone bullet rule, Backspace reversal and multiline typing passed with exact fresh server Markdown |
| Rich paste and copy, pasted links/images/rules/code/H4–6 | Native clipboard schema/HTML parser, attributed projection and attachments | Clipboard schema tests, actual WASM paste then immediate typing; newest UIKit clipboard flow pending |
diff --git a/native/apple/Package.swift b/native/apple/Package.swift
index ef9ac89..9575656 100644
--- a/native/apple/Package.swift
+++ b/native/apple/Package.swift
@@ -10,7 +10,7 @@ let package = Package(name: "DocsNative", defaultLocalization: "en", platforms:
dependencies: [sharedNative],
targets: [
.binaryTarget(name: "DocsCRDT", path: "Artifacts/DocsCRDT.xcframework"),
- .target(name: "DocsKit", dependencies: ["DocsCRDT", .product(name: "RastrilloApple", package: "native")], resources: [.process("Resources")]),
+ .target(name: "DocsKit", dependencies: ["DocsCRDT", .product(name: "RastrilloApple", package: "native")], resources: [.process("Resources"), .copy("Fonts")]),
.executableTarget(name: "DocsMac", dependencies: [.product(name: "RastrilloMacUpdates", package: "native", condition: .when(platforms: [.macOS])), "DocsKit", .product(name: "RastrilloApple", package: "native")], path: "Sources/DocsApp"),
.testTarget(name: "DocsKitTests", dependencies: ["DocsKit", .product(name: "RastrilloTestSupport", package: "native")]),
.testTarget(name: "DocsWindowTests", dependencies: ["DocsMac", .product(name: "RastrilloApple", package: "native")]),
diff --git a/native/apple/Sources/DocsApp/DocsApp.swift b/native/apple/Sources/DocsApp/DocsApp.swift
index e11d2f0..dccb484 100644
--- a/native/apple/Sources/DocsApp/DocsApp.swift
+++ b/native/apple/Sources/DocsApp/DocsApp.swift
@@ -12,6 +12,10 @@ import SwiftUI
@State private var windows = DocsWindows()
@NSApplicationDelegateAdaptor(DocsApplicationDelegate.self) private var appDelegate
#endif
+ /// Every bundled face is registered here, synchronously, before the
+ /// first window exists, so no text view ever lays out with a face
+ /// missing (polish-audit/fonts/NO-FOUT.md §7).
+ init() { DocsFonts.register() }
var body: some Scene {
#if os(macOS)
Window(docsMacString("Home"), id: "home") { DocsAccountWindow(windows: windows) }
@@ -28,6 +32,9 @@ import SwiftUI
}
.defaultSize(width: 1120, height: 820)
.restorationBehavior(.disabled)
+ // The bundled typefaces' licences, from the app menu under About.
+ Window(DocsFontLicencesView.title, id: "font-licences") { DocsFontLicencesView() }
+ .defaultSize(width: 640, height: 720)
#else
WindowGroup { DocsAccountWindow() }
#endif
diff --git a/native/apple/Sources/DocsApp/DocsWindowCommands.swift b/native/apple/Sources/DocsApp/DocsWindowCommands.swift
index 28ea9d7..fdbc26d 100644
--- a/native/apple/Sources/DocsApp/DocsWindowCommands.swift
+++ b/native/apple/Sources/DocsApp/DocsWindowCommands.swift
@@ -8,6 +8,9 @@ struct DocsWindowCommands: Commands {
@FocusedValue(\.docsAccountActions) private var accountActions
@Environment(\.openWindow) private var openWindow
var body: some Commands {
+ CommandGroup(after: .appInfo) {
+ Button(DocsFontLicencesView.title) { openWindow(id: "font-licences") }
+ }
CommandGroup(after: .appSettings) {
Button(docsMacString("Accounts")) {
if let action = accountActions?.accounts { action() }
diff --git a/native/apple/Sources/DocsKit/DocsClipboardWriter.swift b/native/apple/Sources/DocsKit/DocsClipboardWriter.swift
index 58c8632..bea3582 100644
--- a/native/apple/Sources/DocsKit/DocsClipboardWriter.swift
+++ b/native/apple/Sources/DocsKit/DocsClipboardWriter.swift
@@ -92,9 +92,11 @@ import UIKit
let title = link["title"].map { " title=\"\(escape(string($0)))\"" } ?? ""
output = "<a href=\"\(escape(string(link["href"])))\"\(title)>\(output)</a>"
}
- else if ["font_sans", "font_serif", "font_mono"].contains(key) {
- let family = key == "font_serif" ? "serif" : key == "font_mono" ? "monospace" : "sans-serif"
- output = "<span class=\"docs-\(key.replacingOccurrences(of: "_", with: "-"))\" style=\"font-family:\(family)\">\(output)</span>"
+ else if key.hasPrefix("font_"), let family = DocsFonts.family(key: String(key.dropFirst(5))) {
+ // The web editor parses the class; every other application
+ // reads the family's name and the faces the web stands in for it.
+ let stack = ([family.name] + family.fallback).map { ["serif", "sans-serif", "monospace", "cursive"].contains($0) ? $0 : "'\($0)'" }.joined(separator: ", ")
+ output = "<span class=\"docs-font-\(family.key)\" style=\"font-family:\(escape(stack))\">\(output)</span>"
} else if key.hasPrefix("size_") {
let suffix = String(key.dropFirst(5))
let size = ["sm": 10, "lg": 14, "xl": 18][suffix] ?? Int(suffix)
diff --git a/native/apple/Sources/DocsKit/DocsEditorCommands.swift b/native/apple/Sources/DocsKit/DocsEditorCommands.swift
index 91c1104..77a1c83 100644
--- a/native/apple/Sources/DocsKit/DocsEditorCommands.swift
+++ b/native/apple/Sources/DocsKit/DocsEditorCommands.swift
@@ -24,8 +24,10 @@ public struct DocsEditorCommands: Commands {
Button(docsMacString("Block quote")) { editor?.actions?.block("blockquote") }
}
Menu(docsMacString("Font")) {
- ForEach(["sans", "serif", "mono"], id: \.self) { family in
- Button(String(localized: String.LocalizationValue("docs.editor.toolbar.font." + family), bundle: DocsResources.bundle)) { editor?.actions?.format("font_" + family, exclusive: ["font_sans", "font_serif", "font_mono"]) }
+ // Each family's name in its own face; SwiftUI carries the
+ // font into the menu item's attributed title.
+ ForEach(DocsFontPicker.entries) { entry in
+ Button { editor?.actions?.setFont(entry.key) } label: { DocsFontPicker.label(entry) }
}
}
Menu(docsMacString("Size")) {
diff --git a/native/apple/Sources/DocsKit/DocsFontLicences.swift b/native/apple/Sources/DocsKit/DocsFontLicences.swift
new file mode 100644
index 0000000..7a7ac60
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsFontLicences.swift
@@ -0,0 +1,119 @@
+import CoreText
+import Foundation
+import SwiftUI
+
+/// The licences of the bundled typefaces, readable in the app: each family's
+/// name, the licence it is under, its copyright notice and the full licence
+/// text. The text is the file the app carries in Fonts/<directory>/, the same
+/// file the web serves under /static/fonts/.
+enum DocsFontLicences {
+ struct Entry: Identifiable, Hashable {
+ let key: String
+ let name: String
+ /// The licence's name: "SIL Open Font License 1.1" or "Apache License 2.0".
+ let licence: String
+ let copyright: String
+ let text: String
+ var id: String { key }
+ }
+
+ static var entries: [Entry] {
+ DocsFonts.families.map { family in
+ guard let url = DocsResources.bundle.url(forResource: family.licenceFile, withExtension: nil, subdirectory: "Fonts/" + family.directory),
+ let text = try? String(contentsOf: url, encoding: .utf8) else {
+ fatalError("DocsFontLicences: Fonts/\(family.directory)/\(family.licenceFile) is missing from the DocsKit bundle")
+ }
+ return Entry(key: family.key, name: family.name, licence: licenceName(text), copyright: copyright(text, family: family), text: text)
+ }
+ }
+
+ static func licenceName(_ text: String) -> String {
+ let lower = text.lowercased()
+ if lower.contains("sil open font license") && lower.contains("version 1.1") { return "SIL Open Font License 1.1" }
+ if lower.contains("apache license") && lower.contains("version 2.0") { return "Apache License 2.0" }
+ return text.split(whereSeparator: \.isNewline).first.map(String.init) ?? ""
+ }
+
+ /// The licence's own copyright lines; Liberation's licence carries none,
+ /// so for it the notice is the one in the font itself.
+ static func copyright(_ text: String, family: DocsFontFamily) -> String {
+ // isNewline, not "\n": a CRLF file's "\r\n" is one Character.
+ let lines = text.split(whereSeparator: \.isNewline).map { $0.trimmingCharacters(in: .whitespaces) }
+ // A notice starts "Copyright" or "©" and names a year; the
+ // licence's own prose ("the copyright statement(s)", "COPYRIGHT
+ // HOLDER BE LIABLE") does neither.
+ .filter { ($0.lowercased().hasPrefix("copyright") || $0.hasPrefix("©")) && $0.range(of: #"(19|20)\d\d"#, options: .regularExpression) != nil }
+ if !lines.isEmpty { return lines.joined(separator: "\n") }
+ let font = DocsFonts.font(family, bold: false, italic: false, size: 12) as CTFont
+ let notice = (CTFontCopyName(font, kCTFontCopyrightNameKey) as String?) ?? ""
+ return notice.split(whereSeparator: \.isNewline).map { $0.trimmingCharacters(in: .whitespaces) }.joined(separator: "\n")
+ }
+}
+
+/// The list of typefaces and their licences. Text styles throughout, so it
+/// follows Dynamic Type; every row and page is plain text to VoiceOver.
+public struct DocsFontLicencesView: View {
+ private let entries = DocsFontLicences.entries
+ private let close: (() -> Void)?
+ /// close adds a Close button, for the sheet that presents this on iOS.
+ public init(close: (() -> Void)? = nil) { self.close = close }
+ /// "Font licences", for the menu item and window that open this.
+ public static var title: String { String(localized: "native.licences.fonts", bundle: DocsResources.bundle) }
+ public var body: some View {
+ NavigationStack {
+ List {
+ Section {
+ ForEach(entries) { entry in
+ NavigationLink(value: entry) {
+ VStack(alignment: .leading, spacing: 2) {
+ Text(entry.name).font(.body)
+ Text(entry.licence).font(.subheadline).foregroundStyle(.secondary)
+ }
+ .accessibilityElement(children: .combine)
+ }
+ }
+ } footer: {
+ Text("native.licences.fonts.intro", bundle: DocsResources.bundle)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ .navigationTitle(Text("native.licences.fonts", bundle: DocsResources.bundle))
+ .navigationDestination(for: DocsFontLicences.Entry.self) { DocsFontLicenceDetail(entry: $0) }
+ .toolbar {
+ if let close {
+ ToolbarItem(placement: .confirmationAction) {
+ Button(action: close) { Text("native.close", bundle: DocsResources.bundle) }
+ }
+ }
+ }
+ }
+ .accessibilityIdentifier("docs.font-licences")
+ }
+}
+
+/// One family's licence: name, licence, copyright notice and full text.
+struct DocsFontLicenceDetail: View {
+ let entry: DocsFontLicences.Entry
+ var body: some View {
+ ScrollView { DocsFontLicenceDetailContent(entry: entry) }
+ .navigationTitle(entry.name)
+ }
+}
+
+/// The page's text, in text styles so it grows with Dynamic Type and wraps
+/// rather than truncating at accessibility sizes.
+struct DocsFontLicenceDetailContent: View {
+ let entry: DocsFontLicences.Entry
+ var body: some View {
+ VStack(alignment: .leading, spacing: 12) {
+ Text(entry.name).font(.title2.bold()).accessibilityAddTraits(.isHeader)
+ Text(entry.licence).font(.headline)
+ Text(entry.copyright).font(.body)
+ Divider()
+ Text(entry.text).font(.footnote).textSelection(.enabled)
+ }
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding()
+ }
+}
diff --git a/native/apple/Sources/DocsKit/DocsFontPicker.swift b/native/apple/Sources/DocsKit/DocsFontPicker.swift
new file mode 100644
index 0000000..a3b0943
--- /dev/null
+++ b/native/apple/Sources/DocsKit/DocsFontPicker.swift
@@ -0,0 +1,142 @@
+import SwiftUI
+#if os(macOS)
+import AppKit
+#else
+import UIKit
+#endif
+
+/// The font picker: the shared list's families in its order, each name drawn
+/// in its own face (Paul, 2026-10-24). Names are the families' own and are
+/// not translated; a metric twin says whose metrics it has, in the system
+/// face, as the web's row description does ("Calibri-compatible").
+///
+/// Every face is bundled and registered before the first window, so a row is
+/// never drawn in a face still arriving and needs no hold.
+///
+/// On the Mac the toolbar is a standard pop-up button and Format > Font is a
+/// menu; on iPhone and iPad it is a popover list, because UIKit menus draw
+/// every item in the system face.
+enum DocsFontPicker {
+ struct Entry: Identifiable {
+ let key: String
+ let name: String
+ let detail: String?
+ /// The family's regular face at the picker's size.
+ let font: DocsPlatformFont
+ var id: String { key }
+ }
+
+ #if os(macOS)
+ static var size: CGFloat { NSFont.systemFontSize }
+ #else
+ static var size: CGFloat { UIFont.preferredFont(forTextStyle: .body).pointSize }
+ #endif
+
+ @MainActor static var entries: [Entry] {
+ let compatible = String(localized: "docs.editor.toolbar.font.compatible", bundle: DocsResources.bundle)
+ return DocsFonts.families.map { family in
+ Entry(key: family.key, name: family.name, detail: family.twin.map { compatible.replacingOccurrences(of: "{name}", with: $0) },
+ font: DocsFonts.font(family, bold: false, italic: false, size: size))
+ }
+ }
+
+ /// One family's name in its own face, for a menu, and its description in
+ /// the system face.
+ @MainActor static func label(_ entry: Entry) -> Text {
+ let name = Text(entry.name).font(Font(entry.font as CTFont))
+ guard let detail = entry.detail else { return name }
+ return name + Text(" " + detail).font(.caption).foregroundStyle(.secondary)
+ }
+
+ #if os(macOS)
+ /// The pop-up button's menu: each item's title in its family's face, its
+ /// key as the represented object, the current family checked.
+ @MainActor static func menu(selected: String) -> NSMenu {
+ let menu = NSMenu()
+ for entry in entries {
+ let item = NSMenuItem(title: entry.name, action: nil, keyEquivalent: "")
+ item.representedObject = entry.key
+ let title = NSMutableAttributedString(string: entry.name, attributes: [.font: entry.font])
+ if let detail = entry.detail {
+ title.append(NSAttributedString(string: " " + detail, attributes: [
+ .font: NSFont.systemFont(ofSize: NSFont.smallSystemFontSize), .foregroundColor: NSColor.secondaryLabelColor,
+ ]))
+ }
+ item.attributedTitle = title
+ item.state = entry.key == selected ? .on : .off
+ menu.addItem(item)
+ }
+ return menu
+ }
+ #endif
+}
+
+#if os(macOS)
+/// The toolbar's font control: a standard NSPopUpButton, its closed face
+/// showing the current family in that family's face.
+struct DocsFontPopUp: NSViewRepresentable {
+ let selected: String
+ let choose: (String) -> Void
+ func makeCoordinator() -> Coordinator { Coordinator() }
+ func makeNSView(context: Context) -> NSPopUpButton {
+ let button = NSPopUpButton(frame: .zero, pullsDown: false)
+ button.menu = DocsFontPicker.menu(selected: selected)
+ button.target = context.coordinator
+ button.action = #selector(Coordinator.picked(_:))
+ button.setAccessibilityLabel(String(localized: "native.font", bundle: DocsResources.bundle))
+ button.setAccessibilityIdentifier("docs.font-picker")
+ button.setContentHuggingPriority(.required, for: .horizontal)
+ return button
+ }
+ func updateNSView(_ button: NSPopUpButton, context: Context) {
+ context.coordinator.choose = choose
+ button.isEnabled = context.environment.isEnabled
+ if let index = button.itemArray.firstIndex(where: { $0.representedObject as? String == selected }), button.indexOfSelectedItem != index {
+ button.selectItem(at: index)
+ }
+ }
+ @MainActor final class Coordinator: NSObject {
+ var choose: (String) -> Void = { _ in }
+ @objc func picked(_ sender: NSPopUpButton) {
+ if let key = sender.selectedItem?.representedObject as? String { choose(key) }
+ }
+ }
+}
+#else
+/// The toolbar's font control on iPhone and iPad: the current family's name
+/// in its face, opening a list of every family in its own.
+struct DocsFontPickerButton: View {
+ let selected: String
+ let choose: (String) -> Void
+ @State private var open = false
+ var body: some View {
+ let entries = DocsFontPicker.entries
+ let current = entries.first { $0.key == selected } ?? entries[0]
+ Button { open = true } label: {
+ Text(current.name).font(Font(current.font as CTFont)).lineLimit(1).frame(minWidth: 80, alignment: .leading)
+ }
+ .accessibilityLabel(Text("native.font", bundle: DocsResources.bundle))
+ .accessibilityValue(Text(current.name))
+ .accessibilityIdentifier("docs.font-picker")
+ .popover(isPresented: $open) {
+ List(entries) { entry in
+ Button { open = false; choose(entry.key) } label: {
+ HStack {
+ VStack(alignment: .leading, spacing: 2) {
+ Text(entry.name).font(Font(entry.font as CTFont))
+ if let detail = entry.detail { Text(detail).font(.caption).foregroundStyle(.secondary) }
+ }
+ Spacer()
+ if entry.key == selected { Image(systemName: "checkmark").foregroundStyle(Color.accentColor) }
+ }.contentShape(Rectangle())
+ }
+ .foregroundStyle(.primary)
+ .accessibilityAddTraits(entry.key == selected ? .isSelected : [])
+ }
+ .listStyle(.plain)
+ .frame(minWidth: 280, minHeight: 440)
+ .presentationCompactAdaptation(.popover)
+ }
+ }
+}
+#endif
diff --git a/native/apple/Sources/DocsKit/DocsFonts.swift b/native/apple/Sources/DocsKit/DocsFonts.swift
index d73fbe8..1438c8c 100644
--- a/native/apple/Sources/DocsKit/DocsFonts.swift
+++ b/native/apple/Sources/DocsKit/DocsFonts.swift
@@ -8,19 +8,189 @@ import UIKit
typealias DocsPlatformFont = UIFont
#endif
-@MainActor enum DocsFonts {
- private static let registered: Void = {
- for family in ["Sans", "Serif", "Mono"] {
- for face in ["Regular", "Bold", "Italic", "BoldItalic"] {
- let name = "Liberation\(family)-\(face)"
- if let url = DocsResources.bundle.url(forResource: name, withExtension: "ttf") {
- CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
+/// One family of internal/fonts/fonts.json, the font vocabulary the server,
+/// the editor, the Rust renderer and these apps all read.
+struct DocsFontFamily: Sendable, Hashable, Identifiable {
+ enum Style: String, Sendable, CaseIterable { case regular, bold, italic, boldItalic }
+ /// The mark is `font_<key>`. Keys never change: sans, serif and mono are
+ /// Liberation, as they were when there were only three.
+ let key: String
+ /// The family's own name, shown untranslated in the picker.
+ let name: String
+ let category: String
+ /// The proprietary face this one has the metrics of (Carlito: Calibri).
+ let twin: String?
+ /// The name a .docx uses for it: a twin's Word name, or its own.
+ let docxName: String
+ /// The CSS stack the web commits to when the face is late. Read here as
+ /// the names this family stands in for, when a paste names one of them.
+ let fallback: [String]
+ /// The position in the picker, from 0.
+ let index: Int
+ let directory: String
+ /// The licence's file name in the family's directory (OFL.txt).
+ let licenceFile: String
+ let files: [Style: String]
+ var id: String { key }
+ var mark: String { "font_" + key }
+ var styles: [Style] { Style.allCases.filter { files[$0] != nil } }
+}
+
+/// Docs' fonts on the Mac and iPhone: all bundled, registered synchronously
+/// before the first window, and resolved from the bundled files themselves.
+///
+/// Nothing is downloaded, so nothing is ever drawn in a face it later leaves
+/// (polish-audit/fonts/NO-FOUT.md §7): a document opens, a collaborator's
+/// change arrives and a pick applies with the face already in memory.
+///
+/// Faces are created from descriptors made from the bundled files, never
+/// looked up by PostScript name: a person with Inter installed would
+/// otherwise get their copy, with other metrics than the web's and the
+/// PDF's (NSFont(name: "Inter-Regular") returns the installed variable font
+/// on a Mac that has one).
+public enum DocsFonts {
+ struct Manifest: Decodable {
+ struct Family: Decodable {
+ struct Docx: Decodable { let name: String }
+ let key: String, name: String, category: String, twin: String?, docx: Docx
+ let fallback: [String], dir: String, licence: String, styles: [String: String]
+ }
+ let `default`: String, code: String, families: [Family]
+ }
+
+ final class Catalog: @unchecked Sendable {
+ let families: [DocsFontFamily]
+ let byKey: [String: DocsFontFamily]
+ let standard: DocsFontFamily
+ let code: DocsFontFamily
+ /// Every face's descriptor, from its file. CTFontDescriptor is
+ /// immutable, so sharing them across threads is safe.
+ let descriptors: [String: CTFontDescriptor]
+ let files: [String: URL]
+ let urls: [URL]
+
+ init(bundle: Bundle) {
+ guard let url = bundle.url(forResource: "fonts", withExtension: "json", subdirectory: "Fonts"),
+ let data = try? Data(contentsOf: url),
+ let manifest = try? JSONDecoder().decode(Manifest.self, from: data) else {
+ // A build that lost its fonts would set every document in a
+ // system face. That is a packaging mistake, not a state to run in.
+ fatalError("DocsFonts: Fonts/fonts.json is missing from the DocsKit bundle")
+ }
+ var families: [DocsFontFamily] = []
+ var descriptors: [String: CTFontDescriptor] = [:]
+ var urls: [URL] = []
+ var fileURLs: [String: URL] = [:]
+ for (index, entry) in manifest.families.enumerated() {
+ var files: [DocsFontFamily.Style: String] = [:]
+ for (name, file) in entry.styles {
+ guard let style = DocsFontFamily.Style(rawValue: name) else { fatalError("DocsFonts: \(entry.key) has unknown style \(name)") }
+ guard let fileURL = bundle.url(forResource: file, withExtension: "ttf", subdirectory: "Fonts/" + entry.dir),
+ let descriptor = (CTFontManagerCreateFontDescriptorsFromURL(fileURL as CFURL) as? [CTFontDescriptor])?.first else {
+ fatalError("DocsFonts: Fonts/\(entry.dir)/\(file).ttf is missing or unreadable")
+ }
+ files[style] = file
+ descriptors[entry.key + "/" + name] = descriptor
+ fileURLs[entry.key + "/" + name] = fileURL
+ urls.append(fileURL)
}
+ guard files[.regular] != nil else { fatalError("DocsFonts: \(entry.key) has no regular face") }
+ families.append(DocsFontFamily(key: entry.key, name: entry.name, category: entry.category, twin: entry.twin,
+ docxName: entry.docx.name, fallback: entry.fallback, index: index,
+ directory: entry.dir, licenceFile: entry.licence, files: files))
}
+ let byKey = Dictionary(uniqueKeysWithValues: families.map { ($0.key, $0) })
+ guard let standard = byKey[manifest.default], let code = byKey[manifest.code] else {
+ fatalError("DocsFonts: the default or code family is not in the manifest")
+ }
+ self.families = families
+ self.byKey = byKey
+ self.standard = standard
+ self.code = code
+ self.descriptors = descriptors
+ self.files = fileURLs
+ self.urls = urls
}
- }()
+ }
+
+ static let catalog = Catalog(bundle: DocsResources.bundle)
+
+ /// Every family, in the picker's order: Carlito and Caladea first.
+ static var families: [DocsFontFamily] { catalog.families }
+ /// The face an unmarked run is in: Carlito (Paul, 2026-10-24).
+ static var defaultFamily: DocsFontFamily { catalog.standard }
+ /// The face code is in, whatever else the run says.
+ static var codeFamily: DocsFontFamily { catalog.code }
+ /// Every font mark, the default's included. Choosing a font clears all
+ /// of them first, so a run is never in two faces.
+ static var marks: [String] { catalog.families.map(\.mark) }
+ static func family(key: String) -> DocsFontFamily? { catalog.byKey[key] }
+
+ /// The bundled file of one of a family's faces.
+ static func url(_ family: DocsFontFamily, _ style: DocsFontFamily.Style) -> URL? { catalog.files[family.key + "/" + style.rawValue] }
+
+ private nonisolated(unsafe) static var isRegistered = false
+ private static let registration = NSLock()
+
+ /// Registers every bundled face for this process, synchronously. The
+ /// apps call it before their first window; font(...) calls it too, so
+ /// no layout can ever run ahead of it. Idempotent.
+ public static func register() {
+ registration.lock()
+ defer { registration.unlock() }
+ guard !isRegistered else { return }
+ for url in catalog.urls {
+ // Already registered (a second test host in one process) is fine:
+ // the faces are still resolved from their descriptors below.
+ CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil)
+ }
+ isRegistered = true
+ }
+
+ /// The family a run with these marks is drawn in, as the web's
+ /// fontForMarks and internal/fonts' ForMarks decide it: code is always
+ /// the code family; otherwise the font mark latest in manifest order
+ /// wins; no font mark, or only marks this build does not know, is the
+ /// default. An unknown family (a newer build's) is Carlito everywhere,
+ /// on the web, in the PDF and here, and stays Carlito: it never swaps.
+ static func family(forMarks marks: [String: JSONValue]) -> DocsFontFamily {
+ if marks["code"] != nil { return catalog.code }
+ return family(forMarkNames: marks.keys)
+ }
+
+ /// The font a selection shows, from the font marks active on it.
+ static func family<S: Sequence>(forMarkNames names: S) -> DocsFontFamily where S.Element == String {
+ var found: DocsFontFamily?
+ for name in names where name.hasPrefix("font_") {
+ if let family = catalog.byKey[String(name.dropFirst(5))], family.index > (found?.index ?? -1) { found = family }
+ }
+ return found ?? catalog.standard
+ }
+
+ /// The mark a pick sets: nil for the default, which is spelled as the
+ /// absence of a font mark, so choosing Carlito clears the group. Sans
+ /// is font_sans, Liberation Sans, and is never the default.
+ static func mark(forPick key: String) -> String?? {
+ guard let family = catalog.byKey[key] else { return .none }
+ return .some(family.key == catalog.standard.key ? nil : family.mark)
+ }
+
+ /// The face for a weight and slope. A family without the style keeps
+ /// the nearest it has, as internal/fonts' Face does: Caveat has no
+ /// italic and stays upright, on the web (font-synthesis: none), in the
+ /// PDF and here.
+ static func font(_ family: DocsFontFamily, bold: Bool, italic: Bool, size: CGFloat) -> DocsPlatformFont {
+ register()
+ let wanted: DocsFontFamily.Style = bold ? (italic ? .boldItalic : .bold) : (italic ? .italic : .regular)
+ let style = family.files[wanted] != nil ? wanted : family.files[bold ? .bold : .regular] != nil ? (bold ? .bold : .regular) : .regular
+ guard let descriptor = catalog.descriptors[family.key + "/" + style.rawValue] else {
+ fatalError("DocsFonts: \(family.key) has no \(style.rawValue) face")
+ }
+ return CTFontCreateWithFontDescriptor(descriptor, size, nil) as DocsPlatformFont
+ }
+
+ /// The face a run is drawn in.
static func font(marks: [String: JSONValue], size baseSize: CGFloat, heading: Bool) -> DocsPlatformFont {
- _ = registered
var size = baseSize
for key in marks.keys.sorted() where key.hasPrefix("size_") {
if let value = Double(key.dropFirst(5)), [8, 9, 10, 11, 12, 14, 18, 24, 36, 48, 72].contains(value) { size = value }
@@ -29,11 +199,41 @@ typealias DocsPlatformFont = UIFont
else if key == "size_xl" { size = 18 }
}
if marks["code"] != nil { size *= 0.85 }
- let family = marks["font_mono"] != nil || marks["code"] != nil ? "Mono" : marks["font_serif"] != nil ? "Serif" : "Sans"
- let bold = marks["strong"] != nil || heading
- let italic = marks["em"] != nil
- let face = bold ? (italic ? "BoldItalic" : "Bold") : (italic ? "Italic" : "Regular")
- let postScriptName = "Liberation\(family)" + (face == "Regular" ? "" : "-\(face)")
- return DocsPlatformFont(name: postScriptName, size: size) ?? DocsPlatformFont.systemFont(ofSize: size)
+ return font(family(forMarks: marks), bold: marks["strong"] != nil || heading, italic: marks["em"] != nil, size: size)
+ }
+
+ /// The default face at the document's body size, for an empty document's
+ /// caret and anything else that stands for document text.
+ static func defaultFont(size: CGFloat = 12) -> DocsPlatformFont {
+ font(catalog.standard, bold: false, italic: false, size: size)
+ }
+
+ /// The family a pasted font stack stands for, deterministically, from the
+ /// shared list alone. The stack is read in order and the first name that
+ /// maps wins; a later name is only consulted when an earlier one maps to
+ /// nothing. Each name is matched exactly first, against Docs' private CSS
+ /// name ("Docs Inter", which text copied out of web Docs carries), then
+ /// each family's Word name and then its own name (the rule internal/fonts' ByDocxName
+ /// applies to .docx: Calibri is Carlito, Cambria is Caladea), and then
+ /// against the names each family stands in for, its fallback stack, in
+ /// picker order: Georgia is Caladea, Helvetica is Liberation Sans, Menlo
+ /// is JetBrains Mono, generic serif is Caladea. Nil when no name maps,
+ /// which is the default: an unknown face pastes as Carlito. The web's
+ /// familyForStack is the same rule; fixtures/vectors/font-stacks.json
+ /// holds the cases both are tested against.
+ static func family(cssStack stack: String) -> DocsFontFamily? {
+ let names = stack.split(separator: ",").map {
+ $0.trimmingCharacters(in: .whitespacesAndNewlines).trimmingCharacters(in: CharacterSet(charactersIn: "\"'")).lowercased()
+ }.filter { !$0.isEmpty }
+ for name in names {
+ // A run copied out of web Docs names its private face first.
+ if let family = catalog.families.first(where: { ("docs " + $0.name).lowercased() == name })
+ ?? catalog.families.first(where: { $0.docxName.lowercased() == name })
+ ?? catalog.families.first(where: { $0.name.lowercased() == name })
+ ?? catalog.families.first(where: { $0.fallback.contains { $0.lowercased() == name } }) {
+ return family
+ }
+ }
+ return nil
}
}
diff --git a/native/apple/Sources/DocsKit/DocsHTMLClipboard.swift b/native/apple/Sources/DocsKit/DocsHTMLClipboard.swift
index 34141a7..d4ed5ac 100644
--- a/native/apple/Sources/DocsKit/DocsHTMLClipboard.swift
+++ b/native/apple/Sources/DocsKit/DocsHTMLClipboard.swift
@@ -175,9 +175,10 @@ import Foundation
var result = inherited
let style = styles(element.attrs["style"] ?? "")
for name in (element.attrs["class"] ?? "").split(whereSeparator: \.isWhitespace) {
- if ["docs-font-sans", "docs-font-serif", "docs-font-mono"].contains(String(name)) {
- for key in ["font_sans", "font_serif", "font_mono"] { result.removeValue(forKey: key) }
- result["font_" + name.dropFirst(10)] = .object([:])
+ // The web editor's own class for each family (core/src/fragment.rs).
+ if name.hasPrefix("docs-font-"), let family = DocsFonts.family(key: String(name.dropFirst(10))) {
+ for key in DocsFonts.marks { result.removeValue(forKey: key) }
+ if family.key != DocsFonts.defaultFamily.key { result[family.mark] = .object([:]) }
}
if name.hasPrefix("docs-size-") {
let suffix = String(name.dropFirst(10))
@@ -197,11 +198,11 @@ import Foundation
if let title = element.attrs["title"] { link["title"] = .string(title) }
result["link"] = .object(link)
}
- if let family = style["font-family"] ?? element.attrs["face"] {
- let family = family.lowercased()
- for key in ["font_sans", "font_serif", "font_mono"] { result.removeValue(forKey: key) }
- let key = family.contains("mono") || family.contains("courier") ? "font_mono" : family.contains("sans") ? "font_sans" : family.contains("serif") || family.contains("times") || family.contains("georgia") ? "font_serif" : "font_sans"
- result[key] = .object([:])
+ // Any other application's font, mapped once onto the shared list
+ // (DocsFonts.family(cssStack:)); what it does not name is the default.
+ if let stack = style["font-family"] ?? element.attrs["face"] {
+ for key in DocsFonts.marks { result.removeValue(forKey: key) }
+ if let family = DocsFonts.family(cssStack: stack), family.key != DocsFonts.defaultFamily.key { result[family.mark] = .object([:]) }
}
if let raw = style["font-size"] {
let number = Double(raw.prefix { $0.isNumber || $0 == "." })
diff --git a/native/apple/Sources/DocsKit/DocsRichClipboard.swift b/native/apple/Sources/DocsKit/DocsRichClipboard.swift
index fa610af..b6a4127 100644
--- a/native/apple/Sources/DocsKit/DocsRichClipboard.swift
+++ b/native/apple/Sources/DocsKit/DocsRichClipboard.swift
@@ -140,8 +140,9 @@ import UIKit
}
static func marks(_ attributes: [NSAttributedString.Key: Any]) -> [String: JSONValue] {
var result: [String: JSONValue] = [:]
+ var authored = false
if let data = attributes[.docsMarks] as? Data,
- let original = try? JSONDecoder().decode([String: JSONValue].self, from: data) { result = original }
+ let original = try? JSONDecoder().decode([String: JSONValue].self, from: data) { result = original; authored = true }
if let font = attributes[.font] as? DocsPlatformFont {
#if os(macOS)
let traits = font.fontDescriptor.symbolicTraits
@@ -156,9 +157,14 @@ import UIKit
let mono = traits.contains(.traitMonoSpace)
let family = font.familyName.lowercased()
#endif
- if mono || family.contains("mono") || family.contains("courier") { result["font_mono"] = .object([:]) }
- else if family.contains("serif") || family.contains("times") || family.contains("georgia") { result["font_serif"] = .object([:]) }
- else { result["font_sans"] = .object([:]) }
+ // Text copied from a document keeps the font marks it had: its
+ // face is the default's, or code's, for reasons the marks
+ // already say. Anything else maps by family name onto the shared
+ // list; a face it does not name is the default, never Sans.
+ if !authored {
+ let matched = DocsFonts.family(cssStack: family) ?? (mono ? DocsFonts.codeFamily : nil)
+ if let matched, matched.key != DocsFonts.defaultFamily.key { result[matched.mark] = .object([:]) }
+ }
let size = sizes.min { abs(CGFloat($0) - font.pointSize) < abs(CGFloat($1) - font.pointSize) } ?? 12
if size != 12 { result["size_\(size)"] = .object([:]) }
}
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift
index ee4a520..5ffad87 100644
--- a/native/apple/Sources/DocsKit/DocsWorkspace.swift
+++ b/native/apple/Sources/DocsKit/DocsWorkspace.swift
@@ -14,6 +14,7 @@ import SwiftUI
@Environment(\.openWindow) private var openWindow
@Environment(\.scenePhase) private var scenePhase
@State private var jumping = false
+ @State private var showingLicences = false
@State private var discarding = false
@State private var images = DocsImageStore()
@State private var column: NavigationSplitViewColumn = .sidebar
@@ -58,8 +59,18 @@ import SwiftUI
DocsJumpControls(presented: $jumping)
if model.canCreate { Button { beginDocument() } label: { Label { Text("docs.list.create.label", bundle: DocsResources.bundle) } icon: { Image(systemName: "plus") } }.accessibilityIdentifier("docs.create") }
Button { if !model.hasUnsavedChanges && !model.creatingDocument { signOut() } } label: { Text("docs.signout.label", bundle: DocsResources.bundle) }.disabled(model.hasUnsavedChanges || model.creatingDocument)
+ #if os(iOS)
+ // The bundled typefaces' licences. The Mac has them in its app menu.
+ Button { showingLicences = true } label: { Label(DocsFontLicencesView.title, systemImage: "info.circle") }
+ .accessibilityIdentifier("docs.font-licences.open")
+ #endif
}
}
+ #if os(iOS)
+ .sheet(isPresented: $showingLicences) {
+ DocsFontLicencesView { showingLicences = false }
+ }
+ #endif
}
public var body: some View {
Group {
@@ -186,7 +197,7 @@ import SwiftUI
return true
}
return DocumentCommands(model: model, content: text).perform(action)
- }, selectionMoved: model.selectionMovedExplicitly, canAction: { action in model.detail?.can_write == true && !model.hasPendingInput && !model.composing && !model.inputPaused && (action == "undo" ? projection.canUndo : projection.canRedo) }, explicitCommandRevision: model.explicitCommandRevision, zoom: zoom)
+ }, selectionMoved: model.selectionMovedExplicitly, canAction: { action in model.detail?.can_write == true && !model.hasPendingInput && !model.composing && !model.inputPaused && (action == "undo" ? projection.canUndo : projection.canRedo) }, explicitCommandRevision: model.explicitCommandRevision, zoom: zoom, typingMarks: model.typingMarks)
.id(model.editorIdentity)
.task(id: [documentPath] + DocsImageStore.sources(in: projection)) { await images.load(sources: DocsImageStore.sources(in: projection), client: client, documentPath: documentPath) }
} else {
diff --git a/native/apple/Sources/DocsKit/DocumentCommands.swift b/native/apple/Sources/DocsKit/DocumentCommands.swift
index 930ec44..9123760 100644
--- a/native/apple/Sources/DocsKit/DocumentCommands.swift
+++ b/native/apple/Sources/DocsKit/DocumentCommands.swift
@@ -42,15 +42,29 @@ import Foundation
default: return false
}
}
+ /// Sets a mark, or, with an exclusive group, replaces whichever of the
+ /// group is set. 12 pt is the default size and is spelled as no size
+ /// mark. Fonts go through setFont, which knows the default family.
@discardableResult func format(_ name: String, exclusive: [String] = []) -> Bool {
+ applyMark(name == "size_12" ? nil : name, exclusive: exclusive)
+ }
+ /// The font picker's command, as the web's pickFont/fontMark: the
+ /// default (Carlito) clears every font mark, any other family replaces
+ /// them with its own, and Sans is font_sans like any other family. A
+ /// family this build does not know changes nothing.
+ @discardableResult func setFont(_ key: String) -> Bool {
+ guard case .some(let mark) = DocsFonts.mark(forPick: key) else { return false }
+ return applyMark(mark, exclusive: DocsFonts.marks)
+ }
+ private func applyMark(_ name: String?, exclusive: [String]) -> Bool {
guard isEnabled, validSelection else { return false }
var marks = model.typingMarks ?? marksAtCaret
- let active = hasMark(name)
var applied: [String: JSONValue] = [:]
for key in exclusive { marks.removeValue(forKey: key); applied[key] = .null }
- if (active && exclusive.isEmpty) || name == "size_12" || name == "font_sans" {
- marks.removeValue(forKey: name); applied[name] = .null
- } else { marks[name] = .object([:]); applied[name] = .object([:]) }
+ if let name {
+ if hasMark(name) && exclusive.isEmpty { marks.removeValue(forKey: name); applied[name] = .null }
+ else { marks[name] = .object([:]); applied[name] = .object([:]) }
+ }
if model.selection.length == 0 { model.typingMarks = marks; return true }
return submit(Self.markCommands(content: content, selection: model.selection, marks: applied))
}
diff --git a/native/apple/Sources/DocsKit/DocumentToolbarSelection.swift b/native/apple/Sources/DocsKit/DocumentToolbarSelection.swift
index b6e330b..c6585cc 100644
--- a/native/apple/Sources/DocsKit/DocumentToolbarSelection.swift
+++ b/native/apple/Sources/DocsKit/DocumentToolbarSelection.swift
@@ -6,7 +6,8 @@ struct DocumentToolbarSelection: Equatable {
var marks: Set<String> = []
var blocks: Set<String> = []
var style = "paragraph"
- var font = "sans"
+ /// The key of the family the selection is in: Carlito when no font mark is set.
+ var font = DocsFonts.defaultFamily.key
var size = 12
var alignment = "left"
var canUndo = false
@@ -29,7 +30,7 @@ struct DocumentToolbarSelection: Equatable {
style = block.type == "heading" ? "heading" + (block.attrs?["level"] ?? "1") : "paragraph"
alignment = block.attrs?["align"] ?? "left"
}
- font = ["serif", "mono"].first { commands.hasMark("font_" + $0) } ?? "sans"
+ font = DocsFonts.family(forMarkNames: DocsFonts.marks.filter { commands.hasMark($0) }).key
size = [8,9,10,11,12,14,18,24,36,48,72].first { commands.hasMark("size_\($0)") } ?? (commands.hasMark("size_sm") ? 10 : commands.hasMark("size_lg") ? 14 : commands.hasMark("size_xl") ? 18 : 12)
canUndo = commands.model.projection?.canUndo == true
canRedo = commands.model.projection?.canRedo == true
diff --git a/native/apple/Sources/DocsKit/EditorToolbar.swift b/native/apple/Sources/DocsKit/EditorToolbar.swift
index 20a3db8..009538e 100644
--- a/native/apple/Sources/DocsKit/EditorToolbar.swift
+++ b/native/apple/Sources/DocsKit/EditorToolbar.swift
@@ -18,11 +18,11 @@ import SwiftUI
Button { block("heading", level: level) } label: { Text(LocalizedStringKey("docs.editor.toolbar.block.heading\(level)"), bundle: DocsResources.bundle) }
}
} label: { Text(selection.styleLabel).frame(minWidth: 100, alignment: .leading) }.accessibilityLabel(Text("native.style", bundle: DocsResources.bundle))
- Menu {
- ForEach(["sans", "serif", "mono"], id: \.self) { family in
- Button { format("font_" + family, exclusive: ["font_sans", "font_serif", "font_mono"]) } label: { Text(LocalizedStringKey("docs.editor.toolbar.font." + family), bundle: DocsResources.bundle) }
- }
- } label: { Text(LocalizedStringKey("docs.editor.toolbar.font." + selection.font), bundle: DocsResources.bundle).frame(minWidth: 80, alignment: .leading) }.accessibilityLabel(Text("native.font", bundle: DocsResources.bundle))
+ #if os(macOS)
+ DocsFontPopUp(selected: selection.font) { actions.setFont($0) }.fixedSize()
+ #else
+ DocsFontPickerButton(selected: selection.font) { actions.setFont($0) }
+ #endif
Menu {
ForEach([12, 8, 9, 10, 11, 14, 18, 24, 36, 48, 72], id: \.self) { size in
Button(size.formatted()) { format("size_\(size)", exclusive: [8,9,10,11,12,14,18,24,36,48,72].map { "size_\($0)" } + ["size_sm", "size_lg", "size_xl"]) }
diff --git a/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Bold.ttf
new file mode 100644
index 0000000..a4a9703
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-BoldItalic.ttf
new file mode 100644
index 0000000..a9bb487
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Italic.ttf
new file mode 100644
index 0000000..2c910c6
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Regular.ttf
new file mode 100644
index 0000000..a490e8f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caladea/Caladea-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caladea/OFL.txt b/native/apple/Sources/DocsKit/Fonts/caladea/OFL.txt
new file mode 100644
index 0000000..b9d685b
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/caladea/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2012 The Caladea Project Authors (https://github.com/huertatipografica/Caladea)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Bold.ttf
new file mode 100644
index 0000000..67543b5
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-BoldItalic.ttf
new file mode 100644
index 0000000..e2c5d88
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Italic.ttf
new file mode 100644
index 0000000..8dc3c84
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Regular.ttf
new file mode 100644
index 0000000..427b959
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/carlito/Carlito-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/carlito/OFL.txt b/native/apple/Sources/DocsKit/Fonts/carlito/OFL.txt
new file mode 100644
index 0000000..8d6b170
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/carlito/OFL.txt
@@ -0,0 +1,94 @@
+Copyright 2013 The Carlito Project Authors (https://github.com/googlefonts/carlito), with Reserved Font Name "Carlito"
+
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Bold.ttf
new file mode 100644
index 0000000..7960ae4
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Regular.ttf
new file mode 100644
index 0000000..02ad793
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/caveat/Caveat-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/caveat/OFL.txt b/native/apple/Sources/DocsKit/Fonts/caveat/OFL.txt
new file mode 100644
index 0000000..6e5220c
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/caveat/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2014 The Caveat Project Authors (https://github.com/googlefonts/caveat)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/fonts.json b/native/apple/Sources/DocsKit/Fonts/fonts.json
new file mode 100644
index 0000000..04eecba
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/fonts.json
@@ -0,0 +1,411 @@
+{
+ "comment": "The font vocabulary. internal/fonts embeds it, fixtures/fonts.mjs imports it into the editor bundle, core/src/fragment.rs is tested against it, and scripts/vendor-fonts.py builds files/ from it with sources.json. Order is the picker's order. Keys are mark names after font_ and never change: sans, serif and mono are Liberation, as they always were.",
+ "default": "carlito",
+ "code": "mono",
+ "families": [
+ {
+ "key": "carlito",
+ "name": "Carlito",
+ "category": "sans",
+ "twin": "Calibri",
+ "reserved": "Carlito",
+ "docx": {
+ "name": "Calibri",
+ "family": "swiss",
+ "pitch": "variable",
+ "panose": "020F0502020204030204"
+ },
+ "fallback": [
+ "Calibri",
+ "Carlito",
+ "Segoe UI",
+ "Arial",
+ "sans-serif"
+ ],
+ "dir": "carlito",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "Carlito-Regular",
+ "bold": "Carlito-Bold",
+ "italic": "Carlito-Italic",
+ "boldItalic": "Carlito-BoldItalic"
+ }
+ },
+ {
+ "key": "caladea",
+ "name": "Caladea",
+ "category": "serif",
+ "twin": "Cambria",
+ "docx": {
+ "name": "Cambria",
+ "family": "roman",
+ "pitch": "variable",
+ "panose": "02040503050406030204"
+ },
+ "fallback": [
+ "Cambria",
+ "Caladea",
+ "Georgia",
+ "Times New Roman",
+ "serif"
+ ],
+ "dir": "caladea",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "Caladea-Regular",
+ "bold": "Caladea-Bold",
+ "italic": "Caladea-Italic",
+ "boldItalic": "Caladea-BoldItalic"
+ }
+ },
+ {
+ "key": "inter",
+ "name": "Inter",
+ "category": "sans",
+ "docx": {
+ "name": "Inter",
+ "family": "swiss",
+ "pitch": "variable",
+ "altName": "Arial"
+ },
+ "fallback": [
+ "Helvetica Neue",
+ "Arial",
+ "sans-serif"
+ ],
+ "dir": "inter",
+ "licence": "LICENSE.txt",
+ "styles": {
+ "regular": "Inter-Regular",
+ "bold": "Inter-Bold",
+ "italic": "Inter-Italic",
+ "boldItalic": "Inter-BoldItalic"
+ }
+ },
+ {
+ "key": "sourcesans",
+ "name": "Source Sans 3",
+ "category": "sans",
+ "reserved": "Source",
+ "docx": {
+ "name": "Source Sans 3",
+ "family": "swiss",
+ "pitch": "variable",
+ "altName": "Calibri"
+ },
+ "fallback": [
+ "Segoe UI",
+ "Arial",
+ "sans-serif"
+ ],
+ "dir": "sourcesans",
+ "licence": "LICENSE.md",
+ "styles": {
+ "regular": "SourceSans3-Regular",
+ "bold": "SourceSans3-Bold",
+ "italic": "SourceSans3-It",
+ "boldItalic": "SourceSans3-BoldIt"
+ }
+ },
+ {
+ "key": "plexsans",
+ "name": "IBM Plex Sans",
+ "category": "sans",
+ "reserved": "Plex",
+ "docx": {
+ "name": "IBM Plex Sans",
+ "family": "swiss",
+ "pitch": "variable",
+ "altName": "Arial"
+ },
+ "fallback": [
+ "Helvetica Neue",
+ "Arial",
+ "sans-serif"
+ ],
+ "dir": "plexsans",
+ "licence": "LICENSE.txt",
+ "styles": {
+ "regular": "IBMPlexSans-Regular",
+ "bold": "IBMPlexSans-Bold",
+ "italic": "IBMPlexSans-Italic",
+ "boldItalic": "IBMPlexSans-BoldItalic"
+ }
+ },
+ {
+ "key": "sourceserif",
+ "name": "Source Serif 4",
+ "category": "serif",
+ "reserved": "Source",
+ "docx": {
+ "name": "Source Serif 4",
+ "family": "roman",
+ "pitch": "variable",
+ "altName": "Georgia"
+ },
+ "fallback": [
+ "Georgia",
+ "Times New Roman",
+ "serif"
+ ],
+ "dir": "sourceserif",
+ "licence": "LICENSE.md",
+ "styles": {
+ "regular": "SourceSerif4-Regular",
+ "bold": "SourceSerif4-Bold",
+ "italic": "SourceSerif4-It",
+ "boldItalic": "SourceSerif4-BoldIt"
+ }
+ },
+ {
+ "key": "literata",
+ "name": "Literata",
+ "category": "serif",
+ "docx": {
+ "name": "Literata",
+ "family": "roman",
+ "pitch": "variable",
+ "altName": "Georgia"
+ },
+ "fallback": [
+ "Georgia",
+ "Times New Roman",
+ "serif"
+ ],
+ "dir": "literata",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "Literata-Regular",
+ "bold": "Literata-Bold",
+ "italic": "Literata-Italic",
+ "boldItalic": "Literata-BoldItalic"
+ }
+ },
+ {
+ "key": "garamond",
+ "name": "EB Garamond",
+ "category": "serif",
+ "docx": {
+ "name": "EB Garamond",
+ "family": "roman",
+ "pitch": "variable",
+ "altName": "Garamond"
+ },
+ "fallback": [
+ "Garamond",
+ "Georgia",
+ "serif"
+ ],
+ "dir": "garamond",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "EBGaramond-Regular",
+ "bold": "EBGaramond-Bold",
+ "italic": "EBGaramond-Italic",
+ "boldItalic": "EBGaramond-BoldItalic"
+ }
+ },
+ {
+ "key": "sans",
+ "name": "Liberation Sans",
+ "category": "sans",
+ "twin": "Arial",
+ "reserved": "Liberation",
+ "docx": {
+ "name": "Arial",
+ "family": "swiss",
+ "pitch": "variable",
+ "panose": "020B0604020202020204"
+ },
+ "fallback": [
+ "Arial",
+ "Helvetica",
+ "Liberation Sans",
+ "sans-serif"
+ ],
+ "dir": "liberation",
+ "licence": "LICENSE-OFL-1.1.txt",
+ "styles": {
+ "regular": "LiberationSans-Regular",
+ "bold": "LiberationSans-Bold",
+ "italic": "LiberationSans-Italic",
+ "boldItalic": "LiberationSans-BoldItalic"
+ }
+ },
+ {
+ "key": "serif",
+ "name": "Liberation Serif",
+ "category": "serif",
+ "twin": "Times New Roman",
+ "reserved": "Liberation",
+ "docx": {
+ "name": "Times New Roman",
+ "family": "roman",
+ "pitch": "variable",
+ "panose": "02020603050405020304"
+ },
+ "fallback": [
+ "Times New Roman",
+ "Times",
+ "Liberation Serif",
+ "serif"
+ ],
+ "dir": "liberation",
+ "licence": "LICENSE-OFL-1.1.txt",
+ "styles": {
+ "regular": "LiberationSerif-Regular",
+ "bold": "LiberationSerif-Bold",
+ "italic": "LiberationSerif-Italic",
+ "boldItalic": "LiberationSerif-BoldItalic"
+ }
+ },
+ {
+ "key": "mono",
+ "name": "Liberation Mono",
+ "category": "mono",
+ "twin": "Courier New",
+ "reserved": "Liberation",
+ "docx": {
+ "name": "Courier New",
+ "family": "modern",
+ "pitch": "fixed",
+ "panose": "02070309020205020404"
+ },
+ "fallback": [
+ "Courier New",
+ "Liberation Mono",
+ "Consolas",
+ "monospace"
+ ],
+ "dir": "liberation",
+ "licence": "LICENSE-OFL-1.1.txt",
+ "styles": {
+ "regular": "LiberationMono-Regular",
+ "bold": "LiberationMono-Bold",
+ "italic": "LiberationMono-Italic",
+ "boldItalic": "LiberationMono-BoldItalic"
+ }
+ },
+ {
+ "key": "notosans",
+ "name": "Noto Sans",
+ "category": "sans",
+ "docx": {
+ "name": "Noto Sans",
+ "family": "swiss",
+ "pitch": "variable",
+ "altName": "Arial"
+ },
+ "fallback": [
+ "Noto Sans",
+ "Arial",
+ "sans-serif"
+ ],
+ "dir": "notosans",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "NotoSans-Regular",
+ "bold": "NotoSans-Bold",
+ "italic": "NotoSans-Italic",
+ "boldItalic": "NotoSans-BoldItalic"
+ }
+ },
+ {
+ "key": "zilla",
+ "name": "Zilla Slab",
+ "category": "slab",
+ "docx": {
+ "name": "Zilla Slab",
+ "family": "roman",
+ "pitch": "variable",
+ "altName": "Rockwell"
+ },
+ "fallback": [
+ "Rockwell",
+ "Georgia",
+ "serif"
+ ],
+ "dir": "zilla",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "ZillaSlab-Regular",
+ "bold": "ZillaSlab-Bold",
+ "italic": "ZillaSlab-Italic",
+ "boldItalic": "ZillaSlab-BoldItalic"
+ }
+ },
+ {
+ "key": "jetbrains",
+ "name": "JetBrains Mono",
+ "category": "mono",
+ "docx": {
+ "name": "JetBrains Mono",
+ "family": "modern",
+ "pitch": "fixed",
+ "altName": "Consolas"
+ },
+ "fallback": [
+ "Consolas",
+ "Menlo",
+ "Courier New",
+ "monospace"
+ ],
+ "dir": "jetbrains",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "JetBrainsMono-Regular",
+ "bold": "JetBrainsMono-Bold",
+ "italic": "JetBrainsMono-Italic",
+ "boldItalic": "JetBrainsMono-BoldItalic"
+ }
+ },
+ {
+ "key": "playfair",
+ "name": "Playfair Display",
+ "category": "display",
+ "reserved": "Playfair Display",
+ "docx": {
+ "name": "Playfair Display",
+ "family": "roman",
+ "pitch": "variable",
+ "altName": "Georgia"
+ },
+ "fallback": [
+ "Didot",
+ "Bodoni MT",
+ "Georgia",
+ "serif"
+ ],
+ "dir": "playfair",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "PlayfairDisplay-Regular",
+ "bold": "PlayfairDisplay-Bold",
+ "italic": "PlayfairDisplay-Italic",
+ "boldItalic": "PlayfairDisplay-BoldItalic"
+ }
+ },
+ {
+ "key": "caveat",
+ "name": "Caveat",
+ "category": "handwriting",
+ "docx": {
+ "name": "Caveat",
+ "family": "script",
+ "pitch": "variable",
+ "altName": "Segoe Print"
+ },
+ "fallback": [
+ "Segoe Print",
+ "Bradley Hand",
+ "cursive"
+ ],
+ "dir": "caveat",
+ "licence": "OFL.txt",
+ "styles": {
+ "regular": "Caveat-Regular",
+ "bold": "Caveat-Bold"
+ }
+ }
+ ]
+}
diff --git a/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Bold.ttf
new file mode 100644
index 0000000..f28e84c
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-BoldItalic.ttf
new file mode 100644
index 0000000..7a2243e
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Italic.ttf
new file mode 100644
index 0000000..349d4af
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Regular.ttf
new file mode 100644
index 0000000..8f257c0
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/garamond/EBGaramond-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/garamond/OFL.txt b/native/apple/Sources/DocsKit/Fonts/garamond/OFL.txt
new file mode 100644
index 0000000..c1ec5e1
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/garamond/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The EB Garamond Project Authors (https://github.com/octaviopardo/EBGaramond12)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/inter/Inter-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Bold.ttf
new file mode 100644
index 0000000..9fb9b75
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/inter/Inter-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/inter/Inter-BoldItalic.ttf
new file mode 100644
index 0000000..8d05000
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/inter/Inter-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/inter/Inter-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Italic.ttf
new file mode 100644
index 0000000..e7ed211
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/inter/Inter-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Regular.ttf
new file mode 100644
index 0000000..b7aaca8
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/inter/Inter-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/inter/LICENSE.txt b/native/apple/Sources/DocsKit/Fonts/inter/LICENSE.txt
new file mode 100644
index 0000000..9b2ca37
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/inter/LICENSE.txt
@@ -0,0 +1,92 @@
+Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION AND CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Bold.ttf
new file mode 100644
index 0000000..5ee7203
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-BoldItalic.ttf
new file mode 100644
index 0000000..ff10c3a
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Italic.ttf
new file mode 100644
index 0000000..1fb7769
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Regular.ttf
new file mode 100644
index 0000000..b69068d
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/jetbrains/JetBrainsMono-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/jetbrains/OFL.txt b/native/apple/Sources/DocsKit/Fonts/jetbrains/OFL.txt
new file mode 100644
index 0000000..821a3da
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/jetbrains/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LICENSE-OFL-1.1.txt b/native/apple/Sources/DocsKit/Fonts/liberation/LICENSE-OFL-1.1.txt
similarity index 99%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LICENSE-OFL-1.1.txt
rename to native/apple/Sources/DocsKit/Fonts/liberation/LICENSE-OFL-1.1.txt
index d0a76d8..84619fc 100644
--- a/native/apple/Sources/DocsKit/Resources/Fonts/LICENSE-OFL-1.1.txt
+++ b/native/apple/Sources/DocsKit/Fonts/liberation/LICENSE-OFL-1.1.txt
@@ -88,3 +88,4 @@ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.
+
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Bold.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Bold.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Bold.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-BoldItalic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-BoldItalic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-BoldItalic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Italic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Italic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Italic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Regular.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationMono-Regular.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationMono-Regular.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Bold.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Bold.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Bold.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-BoldItalic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-BoldItalic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-BoldItalic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Italic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Italic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Italic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Regular.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSans-Regular.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSans-Regular.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Bold.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Bold.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Bold.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-BoldItalic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-BoldItalic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-BoldItalic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Italic.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Italic.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Italic.ttf
diff --git a/native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Regular.ttf
similarity index 100%
rename from native/apple/Sources/DocsKit/Resources/Fonts/LiberationSerif-Regular.ttf
rename to native/apple/Sources/DocsKit/Fonts/liberation/LiberationSerif-Regular.ttf
diff --git a/native/apple/Sources/DocsKit/Fonts/literata/Literata-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Bold.ttf
new file mode 100644
index 0000000..b2bcc99
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/literata/Literata-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/literata/Literata-BoldItalic.ttf
new file mode 100644
index 0000000..bfa80b1
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/literata/Literata-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/literata/Literata-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Italic.ttf
new file mode 100644
index 0000000..a89a32f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/literata/Literata-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Regular.ttf
new file mode 100644
index 0000000..03de0cc
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/literata/Literata-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/literata/OFL.txt b/native/apple/Sources/DocsKit/Fonts/literata/OFL.txt
new file mode 100644
index 0000000..9d3b4e3
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/literata/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Literata Project Authors (https://github.com/googlefonts/literata)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Bold.ttf
new file mode 100644
index 0000000..8f5fa29
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-BoldItalic.ttf
new file mode 100644
index 0000000..e468bfb
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Italic.ttf
new file mode 100644
index 0000000..cf9ae11
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Regular.ttf
new file mode 100644
index 0000000..c06c202
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/notosans/NotoSans-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/notosans/OFL.txt b/native/apple/Sources/DocsKit/Fonts/notosans/OFL.txt
new file mode 100644
index 0000000..6843f31
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/notosans/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/playfair/OFL.txt b/native/apple/Sources/DocsKit/Fonts/playfair/OFL.txt
new file mode 100644
index 0000000..101867a
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/playfair/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display".
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Bold.ttf
new file mode 100644
index 0000000..93a59cf
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-BoldItalic.ttf
new file mode 100644
index 0000000..3d2fbde
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Italic.ttf
new file mode 100644
index 0000000..aa65a5f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Regular.ttf
new file mode 100644
index 0000000..8468e68
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/playfair/PlayfairDisplay-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Bold.ttf
new file mode 100644
index 0000000..1d66b1a
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-BoldItalic.ttf
new file mode 100644
index 0000000..e07bc1f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Italic.ttf
new file mode 100644
index 0000000..efe8a1f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Regular.ttf
new file mode 100644
index 0000000..bd6817d
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/plexsans/IBMPlexSans-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/plexsans/LICENSE.txt b/native/apple/Sources/DocsKit/Fonts/plexsans/LICENSE.txt
new file mode 100644
index 0000000..c35c4c6
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/plexsans/LICENSE.txt
@@ -0,0 +1,93 @@
+Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/sourcesans/LICENSE.md b/native/apple/Sources/DocsKit/Fonts/sourcesans/LICENSE.md
new file mode 100644
index 0000000..88c07f7
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/sourcesans/LICENSE.md
@@ -0,0 +1,93 @@
+Copyright 2010-2022 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Bold.ttf
new file mode 100644
index 0000000..85693cc
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-BoldIt.ttf b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-BoldIt.ttf
new file mode 100644
index 0000000..1a83e3f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-BoldIt.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-It.ttf b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-It.ttf
new file mode 100644
index 0000000..8e0576f
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-It.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Regular.ttf
new file mode 100644
index 0000000..c5dd0b8
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourcesans/SourceSans3-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourceserif/LICENSE.md b/native/apple/Sources/DocsKit/Fonts/sourceserif/LICENSE.md
new file mode 100644
index 0000000..ebe298c
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/sourceserif/LICENSE.md
@@ -0,0 +1,93 @@
+Copyright 2014 - 2023 Adobe (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Bold.ttf
new file mode 100644
index 0000000..c4159ff
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-BoldIt.ttf b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-BoldIt.ttf
new file mode 100644
index 0000000..40f3863
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-BoldIt.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-It.ttf b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-It.ttf
new file mode 100644
index 0000000..e818087
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-It.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Regular.ttf
new file mode 100644
index 0000000..964a2bf
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/sourceserif/SourceSerif4-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/zilla/OFL.txt b/native/apple/Sources/DocsKit/Fonts/zilla/OFL.txt
new file mode 100644
index 0000000..af9d668
--- /dev/null
+++ b/native/apple/Sources/DocsKit/Fonts/zilla/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2017, The Mozilla Foundation
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Bold.ttf b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Bold.ttf
new file mode 100644
index 0000000..fcd2609
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Bold.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-BoldItalic.ttf b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-BoldItalic.ttf
new file mode 100644
index 0000000..15300ba
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-BoldItalic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Italic.ttf b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Italic.ttf
new file mode 100644
index 0000000..c9eeac7
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Italic.ttf differ
diff --git a/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Regular.ttf b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Regular.ttf
new file mode 100644
index 0000000..8a9724d
Binary files /dev/null and b/native/apple/Sources/DocsKit/Fonts/zilla/ZillaSlab-Regular.ttf differ
diff --git a/native/apple/Sources/DocsKit/NativeDocumentTextView.swift b/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
index 9750b5a..7fa3522 100644
--- a/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
+++ b/native/apple/Sources/DocsKit/NativeDocumentTextView.swift
@@ -18,6 +18,9 @@ struct NativeDocumentTextView: NSViewRepresentable {
var canAction: @MainActor (String) -> Bool = { _ in false }
var explicitCommandRevision: UInt64 = 0
var zoom: Double = 1
+ /// Marks chosen at a collapsed caret (DocsModel.typingMarks), so marked
+ /// text is drawn in the face it will commit in.
+ var typingMarks: [String: JSONValue]? = nil
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeNSView(context: Context) -> NSScrollView {
let scroll = NSScrollView()
@@ -43,6 +46,10 @@ struct NativeDocumentTextView: NSViewRepresentable {
text.compositionChanged = { coordinator.parent.compositionChanged($0) }
text.compositionCommitted = { before, after in coordinator.commitComposition(before: before, after: after) }
text.isRichText = true
+ // Before the first render, and in an empty document, the caret and
+ // anything typed are in the default face, never the system's.
+ text.font = DocsFonts.defaultFont()
+ text.typingAttributes[.font] = DocsFonts.defaultFont()
text.isAutomaticLinkDetectionEnabled = false
text.isAutomaticTextReplacementEnabled = false
text.allowsUndo = false
@@ -75,6 +82,7 @@ struct NativeDocumentTextView: NSViewRepresentable {
}
text.isEditable = candidate.isEditable
(text as? DocsTextView)?.paged = candidate.paged
+ defer { if !text.hasMarkedText() { applyTypingFont(candidate, to: text) } }
// pendingInput makes SwiftUI observe drain completion; only this live
// callback can authorize a delayed candidate at application time.
guard candidate.canRender(candidate.generation), !text.hasMarkedText() else { return }
@@ -90,6 +98,11 @@ struct NativeDocumentTextView: NSViewRepresentable {
if text.selectedRange() != range { text.setSelectedRange(range) }
candidate.didRender(candidate.generation)
}
+ func applyTypingFont(_ candidate: NativeDocumentTextView, to text: NSTextView) {
+ guard let marks = candidate.typingMarks, text.selectedRange().length == 0,
+ let font = NativeTextProjection.typingFont(in: text.attributedString(), at: text.selectedRange().location, marks: marks) else { return }
+ if text.typingAttributes[.font] as? NSFont != font { text.typingAttributes[.font] = font }
+ }
func ruleEdit(_ command: [String: JSONValue]) -> Bool {
var command = command; command["generation"] = .number(Double(generation))
let accepted = parent.edit(command)
@@ -161,6 +174,9 @@ struct NativeDocumentTextView: UIViewRepresentable {
var canAction: @MainActor (String) -> Bool = { _ in false }
var explicitCommandRevision: UInt64 = 0
var zoom: Double = 1
+ /// Marks chosen at a collapsed caret (DocsModel.typingMarks), so marked
+ /// text is drawn in the face it will commit in.
+ var typingMarks: [String: JSONValue]? = nil
func makeCoordinator() -> Coordinator { Coordinator(self) }
func makeUIView(context: Context) -> UITextView {
let text = DocsTextView()
@@ -176,6 +192,10 @@ struct NativeDocumentTextView: UIViewRepresentable {
text.compositionChanged = { coordinator.parent.compositionChanged($0) }
text.compositionCommitted = { before, after in coordinator.commitComposition(before: before, after: after) }
text.adjustsFontForContentSizeCategory = true
+ // Before the first render, and in an empty document, the caret and
+ // anything typed are in the default face, never the system's.
+ text.font = DocsFonts.defaultFont()
+ text.typingAttributes[.font] = DocsFonts.defaultFont()
text.accessibilityIdentifier = "docs.editor"
text.accessibilityLabel = String(localized: "native.editor", bundle: DocsResources.bundle)
return text
@@ -199,6 +219,7 @@ struct NativeDocumentTextView: UIViewRepresentable {
}
text.isEditable = candidate.isEditable
(text as? DocsTextView)?.paged = candidate.paged
+ defer { if text.markedTextRange == nil { applyTypingFont(candidate, to: text) } }
guard candidate.canRender(candidate.generation), text.markedTextRange == nil else { return }
let newGeneration = generation != candidate.generation
guard newGeneration || (rendered?.isEqual(to: candidate.content) != true && text.text == candidate.content.string) else { return }
@@ -211,6 +232,11 @@ struct NativeDocumentTextView: UIViewRepresentable {
text.selectedRange = NSRange(location: min(selected.location, candidate.content.length), length: min(selected.length, max(0, candidate.content.length - selected.location)))
candidate.didRender(candidate.generation)
}
+ func applyTypingFont(_ candidate: NativeDocumentTextView, to text: UITextView) {
+ guard let marks = candidate.typingMarks, text.selectedRange.length == 0,
+ let font = NativeTextProjection.typingFont(in: text.attributedText, at: text.selectedRange.location, marks: marks) else { return }
+ if text.typingAttributes[.font] as? UIFont != font { text.typingAttributes[.font] = font }
+ }
func ruleEdit(_ command: [String: JSONValue]) -> Bool {
var command = command; command["generation"] = .number(Double(generation))
let accepted = parent.edit(command)
diff --git a/native/apple/Sources/DocsKit/NativeTextProjection.swift b/native/apple/Sources/DocsKit/NativeTextProjection.swift
index 5f13ed9..d708b8b 100644
--- a/native/apple/Sources/DocsKit/NativeTextProjection.swift
+++ b/native/apple/Sources/DocsKit/NativeTextProjection.swift
@@ -57,11 +57,9 @@ extension NSAttributedString.Key {
#if os(macOS)
style.headerLevel = heading
#endif
- let base: CGFloat = heading == 1 ? 19.2 : heading == 2 ? 15.6 : heading == 3 ? 13.2 : 12
+ let base = baseSize(heading: heading)
let leading: CGFloat = heading > 0 ? 1.3 : 1.4
- var inheritedMarks: [String: JSONValue] = [:]
- if heading >= 4 || containers.contains(where: { $0.type == "blockquote" }) { inheritedMarks["em"] = .object([:]) }
- if node.type == "code_block" { inheritedMarks["code"] = .object([:]) }
+ let inheritedMarks = inherited(heading: heading, quoted: containers.contains(where: { $0.type == "blockquote" }), code: node.type == "code_block")
let baseFont = font(marks: inheritedMarks, size: base, heading: heading > 0)
#if os(macOS)
let naturalHeight = NSLayoutManager().defaultLineHeight(for: baseFont)
@@ -130,4 +128,28 @@ extension NSAttributedString.Key {
private static func font(marks: [String: JSONValue], size: CGFloat, heading: Bool) -> PlatformFont {
DocsFonts.font(marks: marks, size: size, heading: heading)
}
+ private static func baseSize(heading: Int) -> CGFloat {
+ heading == 1 ? 19.2 : heading == 2 ? 15.6 : heading == 3 ? 13.2 : 12
+ }
+ /// The marks a block lends its text: italic for quotes and small
+ /// headings, code for a code block.
+ private static func inherited(heading: Int, quoted: Bool, code: Bool) -> [String: JSONValue] {
+ var marks: [String: JSONValue] = [:]
+ if heading >= 4 || quoted { marks["em"] = .object([:]) }
+ if code { marks["code"] = .object([:]) }
+ return marks
+ }
+ /// The face text typed at a collapsed caret will be in, given the marks
+ /// it will carry. A font picked at the caret is only typing marks until
+ /// the first character, so the text view's typing attributes take this
+ /// face: IME marked text is then drawn in the face it commits in, not in
+ /// its neighbour's first.
+ static func typingFont(in content: NSAttributedString, at location: Int, marks: [String: JSONValue]) -> DocsPlatformFont? {
+ guard content.length > 0 else { return nil }
+ let attributes = content.attributes(at: min(max(0, location), content.length - 1), effectiveRange: nil)
+ let heading = attributes[.docsHeading] as? Int ?? 0
+ let visual = inherited(heading: heading, quoted: attributes[.docsQuoteBorders] != nil, code: attributes[.docsBlockType] as? String == "code_block")
+ .merging(marks, uniquingKeysWith: { _, typed in typed })
+ return font(marks: visual, size: baseSize(heading: heading), heading: heading > 0)
+ }
}
diff --git a/native/apple/Sources/DocsKit/Resources/ThirdPartyNotices.txt b/native/apple/Sources/DocsKit/Resources/ThirdPartyNotices.txt
index 7138490..28b6f96 100644
--- a/native/apple/Sources/DocsKit/Resources/ThirdPartyNotices.txt
+++ b/native/apple/Sources/DocsKit/Resources/ThirdPartyNotices.txt
@@ -24,3 +24,41 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+
+Fonts
+
+Oficina Docs bundles these typefaces, each under the SIL Open Font License,
+Version 1.1. Each family's licence is in the app, in Fonts/<directory>/.
+
+Carlito: Copyright 2013 The Carlito Project Authors (https://github.com/googlefonts/carlito), with Reserved Font Name "Carlito"
+ Licence: Fonts/carlito/OFL.txt
+Caladea: Copyright 2012 The Caladea Project Authors (https://github.com/huertatipografica/Caladea)
+ Licence: Fonts/caladea/OFL.txt
+Inter: Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
+ Licence: Fonts/inter/LICENSE.txt
+Source Sans 3: Copyright 2010-2022 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
+ Licence: Fonts/sourcesans/LICENSE.md
+IBM Plex Sans: Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
+ Licence: Fonts/plexsans/LICENSE.txt
+Source Serif 4: Copyright 2014 - 2023 Adobe (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
+ Licence: Fonts/sourceserif/LICENSE.md
+Literata: Copyright 2017 The Literata Project Authors (https://github.com/googlefonts/literata)
+ Licence: Fonts/literata/OFL.txt
+EB Garamond: Copyright 2017 The EB Garamond Project Authors (https://github.com/octaviopardo/EBGaramond12)
+ Licence: Fonts/garamond/OFL.txt
+Liberation Sans: Digitized data copyright (c) 2010 Google Corporation. Copyright (c) 2012 Red Hat, Inc.
+ Licence: Fonts/liberation/LICENSE-OFL-1.1.txt
+Liberation Serif: Digitized data copyright (c) 2010 Google Corporation. Copyright (c) 2012 Red Hat, Inc.
+ Licence: Fonts/liberation/LICENSE-OFL-1.1.txt
+Liberation Mono: Digitized data copyright (c) 2010 Google Corporation. Copyright (c) 2012 Red Hat, Inc.
+ Licence: Fonts/liberation/LICENSE-OFL-1.1.txt
+Noto Sans: Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
+ Licence: Fonts/notosans/OFL.txt
+Zilla Slab: Copyright 2017, The Mozilla Foundation
+ Licence: Fonts/zilla/OFL.txt
+JetBrains Mono: Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
+ Licence: Fonts/jetbrains/OFL.txt
+Playfair Display: Copyright 2017 The Playfair Display Project Authors (https://github.com/clauseggers/Playfair-Display), with Reserved Font Name "Playfair Display".
+ Licence: Fonts/playfair/OFL.txt
+Caveat: Copyright 2014 The Caveat Project Authors (https://github.com/googlefonts/caveat)
+ Licence: Fonts/caveat/OFL.txt
diff --git a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
index 0bd2e88..9c17165 100644
--- a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "قائمة نقطية";
"docs.editor.toolbar.code" = "شيفرة";
"docs.editor.toolbar.font" = "الخط";
-"docs.editor.toolbar.font.mono" = "ثابت العرض";
-"docs.editor.toolbar.font.sans" = "بلا زوائد";
-"docs.editor.toolbar.font.serif" = "بزوائد";
+"docs.editor.toolbar.font.compatible" = "متوافق مع {name}";
"docs.editor.toolbar.italic" = "مائل";
"docs.editor.toolbar.label" = "التنسيق";
"docs.editor.toolbar.orderedlist" = "قائمة مرقّمة";
@@ -173,3 +171,5 @@
"native.discard.action" = "تجاهل التغييرات";
"docs.document.rename" = "إعادة تسمية المستند";
+"native.licences.fonts" = "تراخيص الخطوط";
+"native.licences.fonts.intro" = "يتضمن Oficina Docs هذه الخطوط. يمكن استخدام كل منها ومشاركته بحرية وفق الترخيص المرفق به.";
diff --git a/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
index f047d80..08d5108 100644
--- a/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "বুলেটযুক্ত তালিকা";
"docs.editor.toolbar.code" = "কোড";
"docs.editor.toolbar.font" = "ফন্ট";
-"docs.editor.toolbar.font.mono" = "সমপ্রস্থ";
-"docs.editor.toolbar.font.sans" = "স্যান্স সেরিফ";
-"docs.editor.toolbar.font.serif" = "সেরিফ";
+"docs.editor.toolbar.font.compatible" = "{name}-সামঞ্জস্যপূর্ণ";
"docs.editor.toolbar.italic" = "তির্যক";
"docs.editor.toolbar.label" = "বিন্যাস";
"docs.editor.toolbar.orderedlist" = "সংখ্যাযুক্ত তালিকা";
@@ -173,3 +171,5 @@
"native.discard.action" = "পরিবর্তন বাতিল করুন";
"docs.document.rename" = "নথির নাম পরিবর্তন করুন";
+"native.licences.fonts" = "ফন্টের লাইসেন্স";
+"native.licences.fonts.intro" = "Oficina Docs-এ এই টাইপফেসগুলি রয়েছে। প্রতিটি তার সঙ্গে দেখানো লাইসেন্স অনুযায়ী অবাধে ব্যবহার ও শেয়ার করা যায়।";
diff --git a/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
index 875281e..3504be3 100644
--- a/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Bulleted list";
"docs.editor.toolbar.code" = "Code";
"docs.editor.toolbar.font" = "Font";
-"docs.editor.toolbar.font.mono" = "Monospace";
-"docs.editor.toolbar.font.sans" = "Sans serif";
-"docs.editor.toolbar.font.serif" = "Serif";
+"docs.editor.toolbar.font.compatible" = "{name}-compatible";
"docs.editor.toolbar.italic" = "Italic";
"docs.editor.toolbar.label" = "Formatting";
"docs.editor.toolbar.orderedlist" = "Numbered list";
@@ -178,3 +176,5 @@
"docs.document.rename" = "Rename document";
"docs.offline.banner" = "You’re offline. Waiting for a connection.";
+"native.licences.fonts" = "Font licences";
+"native.licences.fonts.intro" = "Oficina Docs includes these typefaces. Each is free to use and share under the licence shown with it.";
diff --git a/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
index 9f6a7d4..0f6ea8a 100644
--- a/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Lista con viñetas";
"docs.editor.toolbar.code" = "Código";
"docs.editor.toolbar.font" = "Fuente";
-"docs.editor.toolbar.font.mono" = "Monoespaciada";
-"docs.editor.toolbar.font.sans" = "Sin serifa";
-"docs.editor.toolbar.font.serif" = "Con serifa";
+"docs.editor.toolbar.font.compatible" = "compatible con {name}";
"docs.editor.toolbar.italic" = "Cursiva";
"docs.editor.toolbar.label" = "Formato";
"docs.editor.toolbar.orderedlist" = "Lista numerada";
@@ -173,3 +171,5 @@
"native.discard.action" = "Descartar cambios";
"docs.document.rename" = "Cambiar nombre del documento";
+"native.licences.fonts" = "Licencias de fuentes";
+"native.licences.fonts.intro" = "Oficina Docs incluye estas tipografías. Cada una se puede usar y compartir libremente según la licencia que la acompaña.";
diff --git a/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
index cae893b..9c10c9e 100644
--- a/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Liosta le hurchair";
"docs.editor.toolbar.code" = "Cód";
"docs.editor.toolbar.font" = "Cló";
-"docs.editor.toolbar.font.mono" = "Aonleithid";
-"docs.editor.toolbar.font.sans" = "Gan seirif";
-"docs.editor.toolbar.font.serif" = "Le seirif";
+"docs.editor.toolbar.font.compatible" = "comhoiriúnach le {name}";
"docs.editor.toolbar.italic" = "Iodálach";
"docs.editor.toolbar.label" = "Formáidiú";
"docs.editor.toolbar.orderedlist" = "Liosta uimhrithe";
@@ -173,3 +171,5 @@
"native.discard.action" = "Scrios athruithe";
"docs.document.rename" = "Athainmnigh an doiciméad";
+"native.licences.fonts" = "Ceadúnais na gcló";
+"native.licences.fonts.intro" = "Tá na clónna seo in Oficina Docs. Is féidir gach ceann a úsáid agus a roinnt faoin gceadúnas a thaispeántar leis.";
diff --git a/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
index 5b468f9..d86372b 100644
--- a/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "बुलेट वाली सूची";
"docs.editor.toolbar.code" = "कोड";
"docs.editor.toolbar.font" = "फ़ॉन्ट";
-"docs.editor.toolbar.font.mono" = "मोनोस्पेस";
-"docs.editor.toolbar.font.sans" = "सैन्स सेरिफ़";
-"docs.editor.toolbar.font.serif" = "सेरिफ़";
+"docs.editor.toolbar.font.compatible" = "{name}-संगत";
"docs.editor.toolbar.italic" = "इटैलिक";
"docs.editor.toolbar.label" = "फ़ॉर्मैटिंग";
"docs.editor.toolbar.orderedlist" = "क्रमांकित सूची";
@@ -173,3 +171,5 @@
"native.discard.action" = "बदलाव छोड़ें";
"docs.document.rename" = "दस्तावेज़ का नाम बदलें";
+"native.licences.fonts" = "फ़ॉन्ट लाइसेंस";
+"native.licences.fonts.intro" = "Oficina Docs में ये टाइपफ़ेस शामिल हैं। हर एक को उसके साथ दिखाए गए लाइसेंस के तहत मुक्त रूप से इस्तेमाल और साझा किया जा सकता है।";
diff --git a/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
index e02a00c..2b4c8fd 100644
--- a/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "箇条書き";
"docs.editor.toolbar.code" = "コード";
"docs.editor.toolbar.font" = "フォント";
-"docs.editor.toolbar.font.mono" = "等幅";
-"docs.editor.toolbar.font.sans" = "サンセリフ";
-"docs.editor.toolbar.font.serif" = "セリフ";
+"docs.editor.toolbar.font.compatible" = "{name} 互換";
"docs.editor.toolbar.italic" = "斜体";
"docs.editor.toolbar.label" = "書式設定";
"docs.editor.toolbar.orderedlist" = "番号付きリスト";
@@ -173,3 +171,5 @@
"native.discard.action" = "変更を破棄";
"docs.document.rename" = "ドキュメント名を変更";
+"native.licences.fonts" = "フォントのライセンス";
+"native.licences.fonts.intro" = "Oficina Docs には以下の書体が含まれています。各書体は、併記されたライセンスのもとで自由に使用・共有できます。";
diff --git a/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
index e2f7b7f..3cbcc6a 100644
--- a/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Lista com marcas";
"docs.editor.toolbar.code" = "Código";
"docs.editor.toolbar.font" = "Tipo de letra";
-"docs.editor.toolbar.font.mono" = "Monoespaçado";
-"docs.editor.toolbar.font.sans" = "Sem serifa";
-"docs.editor.toolbar.font.serif" = "Com serifa";
+"docs.editor.toolbar.font.compatible" = "compatível com {name}";
"docs.editor.toolbar.italic" = "Itálico";
"docs.editor.toolbar.label" = "Formatação";
"docs.editor.toolbar.orderedlist" = "Lista numerada";
@@ -173,3 +171,5 @@
"native.discard.action" = "Descartar alterações";
"docs.document.rename" = "Renomear documento";
+"native.licences.fonts" = "Licenças dos tipos de letra";
+"native.licences.fonts.intro" = "O Oficina Docs inclui estes tipos de letra. Cada um pode ser usado e partilhado livremente nos termos da licença indicada.";
diff --git a/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
index d7ff633..937afc6 100644
--- a/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Маркированный список";
"docs.editor.toolbar.code" = "Код";
"docs.editor.toolbar.font" = "Шрифт";
-"docs.editor.toolbar.font.mono" = "Моноширинный";
-"docs.editor.toolbar.font.sans" = "Без засечек";
-"docs.editor.toolbar.font.serif" = "С засечками";
+"docs.editor.toolbar.font.compatible" = "совместим с {name}";
"docs.editor.toolbar.italic" = "Курсив";
"docs.editor.toolbar.label" = "Форматирование";
"docs.editor.toolbar.orderedlist" = "Нумерованный список";
@@ -173,3 +171,5 @@
"native.discard.action" = "Отменить изменения";
"docs.document.rename" = "Переименовать документ";
+"native.licences.fonts" = "Лицензии шрифтов";
+"native.licences.fonts.intro" = "Oficina Docs включает эти шрифты. Каждый из них можно свободно использовать и распространять по указанной лицензии.";
diff --git a/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
index d33401d..fd4f78a 100644
--- a/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "Danh sách dấu đầu dòng";
"docs.editor.toolbar.code" = "Mã";
"docs.editor.toolbar.font" = "Phông chữ";
-"docs.editor.toolbar.font.mono" = "Đơn cách";
-"docs.editor.toolbar.font.sans" = "Không chân";
-"docs.editor.toolbar.font.serif" = "Có chân";
+"docs.editor.toolbar.font.compatible" = "tương thích với {name}";
"docs.editor.toolbar.italic" = "Nghiêng";
"docs.editor.toolbar.label" = "Định dạng";
"docs.editor.toolbar.orderedlist" = "Danh sách đánh số";
@@ -173,3 +171,5 @@
"native.discard.action" = "Hủy thay đổi";
"docs.document.rename" = "Đổi tên tài liệu";
+"native.licences.fonts" = "Giấy phép phông chữ";
+"native.licences.fonts.intro" = "Oficina Docs có kèm các kiểu chữ này. Mỗi kiểu chữ được tự do sử dụng và chia sẻ theo giấy phép đi kèm.";
diff --git a/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
index a8db880..793d3a2 100644
--- a/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "項目符號清單";
"docs.editor.toolbar.code" = "程式碼";
"docs.editor.toolbar.font" = "字體";
-"docs.editor.toolbar.font.mono" = "等寬字體";
-"docs.editor.toolbar.font.sans" = "無襯線字體";
-"docs.editor.toolbar.font.serif" = "襯線字體";
+"docs.editor.toolbar.font.compatible" = "同 {name} 兼容";
"docs.editor.toolbar.italic" = "斜體";
"docs.editor.toolbar.label" = "格式設定";
"docs.editor.toolbar.orderedlist" = "編號清單";
@@ -173,3 +171,5 @@
"native.discard.action" = "放棄變更";
"docs.document.rename" = "重新命名文件";
+"native.licences.fonts" = "字體授權";
+"native.licences.fonts.intro" = "Oficina Docs 包含以下字體。每款字體都可以按附帶嘅授權自由使用同分享。";
diff --git a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
index d01ecfb..6603606 100644
--- a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
@@ -47,9 +47,7 @@
"docs.editor.toolbar.bulletlist" = "项目符号列表";
"docs.editor.toolbar.code" = "代码";
"docs.editor.toolbar.font" = "字体";
-"docs.editor.toolbar.font.mono" = "等宽";
-"docs.editor.toolbar.font.sans" = "无衬线";
-"docs.editor.toolbar.font.serif" = "衬线";
+"docs.editor.toolbar.font.compatible" = "与 {name} 兼容";
"docs.editor.toolbar.italic" = "斜体";
"docs.editor.toolbar.label" = "格式设置";
"docs.editor.toolbar.orderedlist" = "编号列表";
@@ -173,3 +171,5 @@
"native.discard.action" = "放弃更改";
"docs.document.rename" = "重命名文档";
+"native.licences.fonts" = "字体许可";
+"native.licences.fonts.intro" = "Oficina Docs 包含以下字体。每种字体均可按其附带的许可自由使用和分享。";
diff --git a/native/apple/Tests/DocsKitTests/BrowserTypographyTests.swift b/native/apple/Tests/DocsKitTests/BrowserTypographyTests.swift
index 33f0e99..7b14634 100644
--- a/native/apple/Tests/DocsKitTests/BrowserTypographyTests.swift
+++ b/native/apple/Tests/DocsKitTests/BrowserTypographyTests.swift
@@ -15,6 +15,13 @@ import XCTest
("quote", CRDTNode(id: "quote", type: "blockquote", children: [block("qp", prose)]), "<blockquote><p>\(prose)</p></blockquote>"),
("serif", block("serif", prose, marks: ["font_serif": .object([:])]), "<p><span class='docs-font-serif'>\(prose)</span></p>"),
("mono", block("mono", prose, marks: ["font_mono": .object([:])]), "<p><span class='docs-font-mono'>\(prose)</span></p>"),
+ ("sans", block("sans", prose, marks: ["font_sans": .object([:])]), "<p><span class='docs-font-sans'>\(prose)</span></p>"),
+ ("caladea", block("caladea", prose, marks: ["font_caladea": .object([:])]), "<p><span class='docs-font-caladea'>\(prose)</span></p>"),
+ // Inter is installed on the machine this was written on; the run must be the bundled Inter.
+ ("inter", block("inter", prose, marks: ["font_inter": .object([:])]), "<p><span class='docs-font-inter'>\(prose)</span></p>"),
+ ("garamond-bold", block("garamond", prose, marks: ["font_garamond": .object([:]), "strong": .object([:])]), "<p><span class='docs-font-garamond'><strong>\(prose)</strong></span></p>"),
+ // Caveat has no italic: upright on both sides (font-synthesis: none).
+ ("caveat-italic", block("caveat", prose, marks: ["font_caveat": .object([:]), "em": .object([:])]), "<p><span class='docs-font-caveat'><em>\(prose)</em></span></p>"),
("large", block("large", prose, marks: ["size_24": .object([:])]), "<p><span class='docs-size-24'>\(prose)</span></p>"),
("mixed-size", CRDTNode(id: "mixedSize", type: "paragraph", children: [CRDTNode(id: "mixedSizet", type: "text", runs: [CRDTRun(insert: "Large", marks: ["size_72": .object([:])]), CRDTRun(insert: " " + prose + " " + prose)])]), "<p><span class='docs-size-72'>Large</span> \(prose) \(prose)</p>"),
("mixed-code-wrap", CRDTNode(id: "wrap", type: "paragraph", children: [CRDTNode(id: "wrapt", type: "text", runs: [CRDTRun(insert: String(repeating: "Wide words ", count: 7)), CRDTRun(insert: "WRAPPEDCODE " + prose, marks: ["code": .object([:])])])]), "<p>\(String(repeating: "Wide words ", count: 7))<code>WRAPPEDCODE \(prose)</code></p>"),
@@ -35,6 +42,13 @@ import XCTest
}
}
+ func testTypographyFixtureIsWhatTheBrowserDraws() async throws {
+ typealias Fixture = DocumentTypographyTests
+ let html = "<h1>\(Fixture.heading)</h1><p><strong>\(Fixture.bold)</strong></p><p></p><p>\(Fixture.body)</p>"
+ let lines = try await browserLines(html).map(\.text).filter { !$0.isEmpty }
+ XCTAssertEqual(lines, Fixture.browserLines)
+ }
+
func testAdjacentHeadingMarginsCollapse() async throws {
let text = "A heading with a predictable measure"
let nodes = (0..<4).map { block("h\($0)", text, type: "heading", attrs: ["level": "2"]) }
@@ -109,17 +123,26 @@ import XCTest
private func browserLines(_ html: String, paged: Bool = false, includeBounds: Bool = false) async throws -> [Line] {
let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
let source = try String(contentsOf: root.appendingPathComponent("internal/docs/views/show.html"), encoding: .utf8)
- let start = try XCTUnwrap(source.range(of: "<style>"))
+ // The document page's own stylesheet: the <style> in its content
+ // block (the head's <noscript> style comes first).
+ let content = try XCTUnwrap(source.range(of: "{{define \"content\"}}"))
+ let start = try XCTUnwrap(source.range(of: "<style>", range: content.upperBound..<source.endIndex))
let end = try XCTUnwrap(source.range(of: "</style>", range: start.upperBound..<source.endIndex))
var css = String(source[start.upperBound..<end.lowerBound])
- css = css.replacingOccurrences(of: #"\{\{range \.FontFaces\}\}[\s\S]*?\{\{end\}\}"#, with: "", options: .regularExpression)
- for family in ["Sans", "Serif", "Mono"] {
- for face in ["Regular", "Bold", "Italic", "BoldItalic"] {
- let font = try XCTUnwrap(DocsResources.bundle.url(forResource: "Liberation\(family)-\(face)", withExtension: "ttf"))
- let data = try Data(contentsOf: font).base64EncodedString()
- css += "@font-face{font-family:'Docs \(family)';src:url(data:font/ttf;base64,\(data));font-weight:\(face.contains("Bold") ? 700 : 400);font-style:\(face.contains("Italic") ? "italic" : "normal");}"
+ // The font rules are internal/fonts' generated stylesheet (fonts.go's
+ // stylesheet()): each face under its private name, the default family
+ // on [docs-text], each family on its mark's class, code in the code
+ // family. Faces are the app's bundled files, as data URLs.
+ for family in DocsFonts.families where family == DocsFonts.defaultFamily || family == DocsFonts.codeFamily || html.contains("docs-font-" + family.key + "'") {
+ for style in family.styles {
+ let data = try Data(contentsOf: try XCTUnwrap(DocsFonts.url(family, style))).base64EncodedString()
+ let bold = style == .bold || style == .boldItalic, italic = style == .italic || style == .boldItalic
+ css += "@font-face{font-family:\"Docs \(family.name)\";src:url(data:font/ttf;base64,\(data));font-weight:\(bold ? 700 : 400);font-style:\(italic ? "italic" : "normal");font-display:block}"
}
}
+ css += "[docs-text]{font-family:\"Docs \(DocsFonts.defaultFamily.name)\";font-synthesis:none}"
+ for family in DocsFonts.families { css += "[docs-text] .docs-font-\(family.key){font-family:\"Docs \(family.name)\"}" }
+ css += "[docs-text] code{font-family:\"Docs \(DocsFonts.codeFamily.name)\"}"
let pageSource = try String(contentsOf: root.appendingPathComponent("fixtures/pages.mjs"), encoding: .utf8)
let measureStart = try XCTUnwrap(pageSource.range(of: "function breakPositions(view)"))
let measureEnd = try XCTUnwrap(pageSource.range(of: "// pagesPlugin draws"))
diff --git a/native/apple/Tests/DocsKitTests/DocsFontLicencesTests.swift b/native/apple/Tests/DocsKitTests/DocsFontLicencesTests.swift
new file mode 100644
index 0000000..e6540f9
--- /dev/null
+++ b/native/apple/Tests/DocsKitTests/DocsFontLicencesTests.swift
@@ -0,0 +1,50 @@
+import Foundation
+import XCTest
+@testable import DocsKit
+
+/// Every bundled family's licence can be read in the app: its name, which
+/// licence it is under, its copyright notice and the full licence text,
+/// which is the same file the web serves under /static/fonts/.
+final class DocsFontLicencesTests: XCTestCase {
+ @MainActor func testEveryBundledFamilyHasAViewableLicence() throws {
+ let data = try Data(contentsOf: DocsFontsTests.repository.appendingPathComponent("internal/fonts/fonts.json"))
+ let families = try XCTUnwrap((try JSONSerialization.jsonObject(with: data) as? [String: Any])?["families"] as? [[String: Any]])
+ let entries = DocsFontLicences.entries
+ XCTAssertEqual(entries.map(\.key), families.map { $0["key"] as? String ?? "" }, "one entry per family, in picker order")
+ for family in families {
+ let key = try XCTUnwrap(family["key"] as? String)
+ let entry = try XCTUnwrap(entries.first { $0.key == key }, key)
+ XCTAssertEqual(entry.name, family["name"] as? String)
+ XCTAssertTrue(["SIL Open Font License 1.1", "Apache License 2.0"].contains(entry.licence), "\(key): \(entry.licence)")
+ // A notice names its year and holder; licence prose that merely
+ // mentions "copyright" ("the copyright statement(s)") is not one.
+ let notices = entry.copyright.split(whereSeparator: \.isNewline)
+ XCTAssertFalse(notices.isEmpty, key)
+ for notice in notices {
+ XCTAssertNotNil(notice.range(of: #"(19|20)\d\d"#, options: .regularExpression), "\(key): \(notice)")
+ XCTAssertTrue(notice.lowercased().contains("copyright") || notice.contains("©"), "\(key): \(notice)")
+ }
+ let served = try String(contentsOf: DocsFontsTests.repository.appendingPathComponent("internal/fonts/files/\(family["dir"]!)/\(family["licence"]!)"), encoding: .utf8)
+ XCTAssertEqual(entry.text, served, "\(key) shows the licence the web serves")
+ }
+ }
+
+ #if os(iOS)
+ /// Each licence page grows with Dynamic Type: at the largest accessibility
+ /// size its text wraps to a taller page instead of truncating. iOS only;
+ /// macOS has no Dynamic Type.
+ @MainActor func testLicencePagesFollowDynamicType() throws {
+ for entry in DocsFontLicences.entries {
+ func height(_ size: DynamicTypeSize) -> CGFloat {
+ UIHostingController(rootView: DocsFontLicenceDetailContent(entry: entry).dynamicTypeSize(size))
+ .sizeThatFits(in: CGSize(width: 390, height: CGFloat.greatestFiniteMagnitude)).height
+ }
+ XCTAssertGreaterThan(height(.accessibility5), height(.large) * 1.5, entry.name)
+ }
+ }
+ #endif
+}
+import SwiftUI
+#if os(iOS)
+import UIKit
+#endif
diff --git a/native/apple/Tests/DocsKitTests/DocsFontPickerTests.swift b/native/apple/Tests/DocsKitTests/DocsFontPickerTests.swift
new file mode 100644
index 0000000..63ab1f4
--- /dev/null
+++ b/native/apple/Tests/DocsKitTests/DocsFontPickerTests.swift
@@ -0,0 +1,175 @@
+import CoreText
+import Foundation
+import RastrilloApple
+import XCTest
+@testable import DocsKit
+#if os(macOS)
+import AppKit
+#endif
+
+/// The picker and the commands it drives, against the shared list in
+/// internal/fonts/fonts.json (DocsFontsTests reads it the same way).
+final class DocsFontPickerTests: XCTestCase {
+ /// The picker lists the shared list's families, in its order and by its
+ /// names, each drawn in its own face; twins say whose metrics they have.
+ @MainActor func testPickerEntriesAreDrawnInTheirOwnFace() throws {
+ let shared = try DocsFontsTests.shared()
+ let entries = DocsFontPicker.entries
+ XCTAssertEqual(entries.map(\.key), shared.families.map(\.key))
+ XCTAssertEqual(entries.map(\.name), shared.families.map(\.name))
+ XCTAssertEqual(entries.first?.key, "carlito")
+ for (entry, family) in zip(entries, shared.families) {
+ XCTAssertEqual(DocsFontsTests.url(of: entry.font), try DocsFontsTests.bundled(family, "regular"), "\(family.name) is drawn in \(family.name)")
+ XCTAssertEqual(entry.detail != nil, family.twin != nil, family.key)
+ if let twin = family.twin { XCTAssertTrue(entry.detail?.contains(twin) == true, "\(family.name) says it has \(twin)'s metrics") }
+ }
+ #if os(macOS)
+ // The toolbar's pop-up button: each item's title in its own face, the
+ // current family checked, its key what a choice reports.
+ let menu = DocsFontPicker.menu(selected: "sans")
+ XCTAssertEqual(menu.items.count, shared.families.count)
+ for (item, family) in zip(menu.items, shared.families) {
+ let title = try XCTUnwrap(item.attributedTitle, family.name)
+ XCTAssertTrue(title.string.hasPrefix(family.name), title.string)
+ var face = NSRange()
+ let font = try XCTUnwrap(title.attribute(.font, at: 0, effectiveRange: &face) as? NSFont, family.name)
+ XCTAssertEqual(DocsFontsTests.url(of: font), try DocsFontsTests.bundled(family, "regular"), family.name)
+ XCTAssertEqual(face.length, (family.name as NSString).length, "\(family.name): the name, and only the name, is in its face")
+ XCTAssertEqual(item.state, family.key == "sans" ? .on : .off)
+ XCTAssertEqual(item.representedObject as? String, family.key)
+ }
+ #endif
+ }
+
+ /// setFont is the picker's command: Sans is font_sans, the default clears
+ /// the group, one font at a time, and an unknown key changes nothing.
+ @MainActor func testSetFontKeepsSansAndDefaultApart() throws {
+ let model = DocsModel(client: NativeHTTP(origin: URL(string: "https://example.invalid")!))
+ model.detail = DocumentDetail(sqid: "fixture", title: "Fixture", guid: "fixture", can_write: true, can_share: false)
+ model.projection = CRDTProjection(children: [CRDTNode(id: "p", type: "paragraph", children: [CRDTNode(id: "t", type: "text", runs: [
+ CRDTRun(insert: "plain words"),
+ ])])], canUndo: false, canRedo: false)
+ let commands = DocumentCommands(model: model, content: NativeTextProjection.render(model.projection!))
+ model.selection = NSRange(location: 2, length: 0)
+ XCTAssertTrue(commands.setFont("sans"))
+ XCTAssertEqual(model.typingMarks?["font_sans"], .object([:]), "Sans is a mark, not the default")
+ XCTAssertTrue(commands.setFont("inter"))
+ XCTAssertEqual(model.typingMarks?["font_inter"], .object([:]))
+ XCTAssertNil(model.typingMarks?["font_sans"], "one font at a time")
+ XCTAssertTrue(commands.setFont("carlito"))
+ XCTAssertEqual(model.typingMarks?.keys.filter { $0.hasPrefix("font_") } ?? ["missing"], [], "the default clears every font mark")
+ model.typingMarks = ["font_playfair": .object([:])]
+ XCTAssertFalse(commands.setFont("futura"), "a family this build does not know changes nothing")
+ XCTAssertEqual(model.typingMarks, ["font_playfair": .object([:])])
+
+ }
+
+ /// The face a collapsed-caret pick will type in, so IME marked text is
+ /// drawn in it rather than in its neighbour's.
+ @MainActor func testTypingFontFollowsAPickAtTheCaret() throws {
+ let projection = CRDTProjection(children: [
+ CRDTNode(id: "h", type: "heading", attrs: ["level": "2"], children: [CRDTNode(id: "ht", type: "text", runs: [CRDTRun(insert: "Title")])]),
+ ], canUndo: false, canRedo: false)
+ let content = NativeTextProjection.render(projection)
+ let font = try XCTUnwrap(NativeTextProjection.typingFont(in: content, at: 2, marks: ["font_playfair": .object([:])]))
+ XCTAssertEqual(DocsFontsTests.url(of: font)?.lastPathComponent, "PlayfairDisplay-Bold.ttf", "a heading is bold")
+ XCTAssertEqual(font.pointSize, 15.6, accuracy: 0.01)
+ }
+
+ /// Pasted font names map onto the shared list once and deterministically.
+ @MainActor func testPastedFontNamesMapByTheSharedList() {
+ XCTAssertEqual(DocsFonts.family(cssStack: "Calibri, sans-serif")?.key, "carlito", "Calibri is Carlito")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Cambria")?.key, "caladea")
+ XCTAssertEqual(DocsFonts.family(cssStack: "'Liberation Sans', Arial")?.key, "sans")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Arial")?.key, "sans")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Helvetica")?.key, "sans")
+ XCTAssertEqual(DocsFonts.family(cssStack: "\"Times New Roman\", serif")?.key, "serif")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Georgia")?.key, "caladea")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Wingdings, Menlo, monospace")?.key, "jetbrains")
+ XCTAssertEqual(DocsFonts.family(cssStack: "monospace")?.key, "mono")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Source Serif 4")?.key, "sourceserif")
+ XCTAssertEqual(DocsFonts.family(cssStack: "sans-serif")?.key, "carlito")
+ XCTAssertNil(DocsFonts.family(cssStack: "Wingdings"))
+ // A stack is read in order: the first name that maps wins, whether it
+ // maps by its own name or as a name a family stands in for.
+ XCTAssertEqual(DocsFonts.family(cssStack: "Georgia, \"Times New Roman\", serif")?.key, "caladea")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Menlo, \"Courier New\", monospace")?.key, "jetbrains")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Helvetica, Calibri, sans-serif")?.key, "sans")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Wingdings, Cambria, Georgia")?.key, "caladea")
+ XCTAssertEqual(DocsFonts.family(cssStack: "Wingdings, Calibri, Arial")?.key, "carlito")
+ }
+
+ /// fixtures/vectors/font-stacks.json is the one list of paste cases the
+ /// web's familyForStack and this resolver are both held to.
+ @MainActor func testSharedFontStackVectors() throws {
+ let url = DocsFontsTests.repository.appendingPathComponent("fixtures/vectors/font-stacks.json")
+ let json = try XCTUnwrap(try JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any])
+ let cases = try XCTUnwrap(json["cases"] as? [[Any]])
+ XCTAssertGreaterThanOrEqual(cases.count, 23)
+ for pair in cases {
+ let stack = try XCTUnwrap(pair.first as? String)
+ let expected = pair.last as? String
+ XCTAssertEqual(DocsFonts.family(cssStack: stack)?.key, expected, stack)
+ }
+ }
+
+ /// Nested paste, against the shared vectors' "nested" cases: an inner
+ /// font-family that maps to the default or to nothing clears the outer
+ /// font, one that maps to another family replaces it, and a span with no
+ /// font-family keeps the outer font, as the web's parse rule does.
+ @MainActor func testNestedPastedFontsFollowTheSharedVectors() throws {
+ let url = DocsFontsTests.repository.appendingPathComponent("fixtures/vectors/font-stacks.json")
+ let json = try XCTUnwrap(try JSONSerialization.jsonObject(with: Data(contentsOf: url)) as? [String: Any])
+ let cases = try XCTUnwrap(json["nested"] as? [[Any]])
+ XCTAssertGreaterThanOrEqual(cases.count, 8)
+ func attribute(_ stack: String) -> String { "font-family: " + stack.replacingOccurrences(of: "\"", with: "&quot;") }
+ for pair in cases {
+ let outer = try XCTUnwrap(pair[0] as? String), inner = pair[1] as? String, expected = pair[2] as? String
+ let innerOpen = inner.map { "<span style=\"\(attribute($0))\">" } ?? "<span>"
+ let html = "<p><span style=\"\(attribute(outer))\">Outer \(innerOpen)Inner</span></span></p>"
+ let runs = Self.runs(DocsHTMLClipboard.blocks(html))
+ let run = try XCTUnwrap(runs.first { $0.text.contains("Inner") }, html)
+ let fonts = run.marks.keys.filter { $0.hasPrefix("font_") }.sorted()
+ XCTAssertEqual(fonts, expected.map { ["font_" + $0] } ?? [], "\(outer) > \(inner ?? "(no font-family)")")
+ }
+ }
+ static func runs(_ blocks: [JSONValue]) -> [(text: String, marks: [String: JSONValue])] {
+ var out: [(String, [String: JSONValue])] = []
+ func walk(_ value: JSONValue) {
+ guard case .object(let node) = value else { return }
+ if case .array(let runs)? = node["runs"] {
+ for case .object(let run) in runs {
+ guard case .string(let text)? = run["insert"] else { continue }
+ if case .object(let marks)? = run["marks"] { out.append((text, marks)) } else { out.append((text, [:])) }
+ }
+ }
+ if case .array(let children)? = node["children"] { children.forEach(walk) }
+ }
+ blocks.forEach(walk)
+ return out
+ }
+
+ /// A run copied out of web Docs names its private face first, then that
+ /// family's fallback stack (internal/fonts' generated stylesheet). The
+ /// private name decides: Source Sans 3's fallbacks start with Segoe UI,
+ /// which is Carlito's, and IBM Plex Sans's with Helvetica Neue, Inter's.
+ @MainActor func testDocsPrivateFontNamesMapToTheirFamily() throws {
+ let data = try Data(contentsOf: DocsFontsTests.repository.appendingPathComponent("internal/fonts/fonts.json"))
+ let families = try XCTUnwrap((try JSONSerialization.jsonObject(with: data) as? [String: Any])?["families"] as? [[String: Any]])
+ for family in families {
+ let name = try XCTUnwrap(family["name"] as? String), key = try XCTUnwrap(family["key"] as? String)
+ let fallback = try XCTUnwrap(family["fallback"] as? [String])
+ let stack = (["\"Docs \(name)\""] + fallback.map { $0.contains(" ") ? "\"\($0)\"" : $0 }).joined(separator: ", ")
+ XCTAssertEqual(DocsFonts.family(cssStack: stack)?.key, key, stack)
+ }
+ }
+
+ /// The same order through an HTML paste, which is where it writes a mark.
+ @MainActor func testPastedStackKeepsItsFirstMappedFamily() {
+ let blocks = DocsHTMLClipboard.blocks("<p><span style='font-family: Georgia, \"Times New Roman\", serif'>Serif</span></p>")
+ guard case .object(let paragraph)? = blocks.first, case .array(let children)? = paragraph["children"],
+ case .object(let text)? = children.first, case .array(let runs)? = text["runs"],
+ case .object(let run)? = runs.first, case .object(let marks)? = run["marks"] else { return XCTFail("no run: \(blocks)") }
+ XCTAssertEqual(marks.keys.filter { $0.hasPrefix("font_") }, ["font_caladea"])
+ }
+}
diff --git a/native/apple/Tests/DocsKitTests/DocsFontsTests.swift b/native/apple/Tests/DocsKitTests/DocsFontsTests.swift
new file mode 100644
index 0000000..0de46cc
--- /dev/null
+++ b/native/apple/Tests/DocsKitTests/DocsFontsTests.swift
@@ -0,0 +1,259 @@
+import CoreText
+import Foundation
+import RastrilloApple
+import SwiftUI
+import XCTest
+@testable import DocsKit
+#if os(macOS)
+import AppKit
+#else
+import UIKit
+#endif
+
+/// Paul's font rulings (2026-10-24) on the apps: the default is Carlito, every
+/// family is bundled and resolved from its own file, Sans is Liberation Sans
+/// and never the default, and the picker shows each family in its face.
+///
+/// The expectations are read from internal/fonts/fonts.json in the
+/// repository, not from DocsKit, so a bundle that drifted from the shared
+/// list fails here rather than agreeing with itself.
+final class DocsFontsTests: XCTestCase {
+ struct SharedFamily { let key: String; let name: String; let dir: String; let styles: [String: String]; let twin: String? }
+ static let repository = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent()
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ static func shared() throws -> (standard: String, code: String, families: [SharedFamily]) {
+ let data = try Data(contentsOf: repository.appendingPathComponent("internal/fonts/fonts.json"))
+ let json = try XCTUnwrap(try JSONSerialization.jsonObject(with: data) as? [String: Any])
+ let families = try XCTUnwrap(json["families"] as? [[String: Any]]).map {
+ SharedFamily(key: $0["key"] as! String, name: $0["name"] as! String, dir: $0["dir"] as! String,
+ styles: $0["styles"] as! [String: String], twin: $0["twin"] as? String)
+ }
+ return (json["default"] as! String, json["code"] as! String, families)
+ }
+ static func url(of font: DocsPlatformFont) -> URL? {
+ CTFontCopyAttribute(font as CTFont, kCTFontURLAttribute) as? URL
+ }
+ static func bundled(_ family: SharedFamily, _ style: String) throws -> URL {
+ let file = try XCTUnwrap(family.styles[style], "\(family.key) has no \(style)")
+ return try XCTUnwrap(DocsResources.bundle.url(forResource: file, withExtension: "ttf", subdirectory: "Fonts/" + family.dir),
+ "\(file).ttf is not in the app bundle")
+ }
+
+ /// Every face of all sixteen families is in the bundle, registers for the
+ /// process, resolves by its PostScript name, and is drawn from the
+ /// bundled file itself. Inter is installed system-wide on the machine
+ /// this was written on, and NSFont(name:) returns that copy; the run's
+ /// face must not.
+ @MainActor func testEveryBundledFaceRegistersAndResolvesFromItsOwnFile() throws {
+ let shared = try Self.shared()
+ XCTAssertEqual(shared.families.count, 16)
+ for family in shared.families {
+ for (style, bold, italic) in [("regular", false, false), ("bold", true, false), ("italic", false, true), ("boldItalic", true, true)] {
+ var marks: [String: JSONValue] = ["font_" + family.key: .object([:])]
+ if bold { marks["strong"] = .object([:]) }
+ if italic { marks["em"] = .object([:]) }
+ let font = DocsFonts.font(marks: marks, size: 12, heading: false)
+ // Caveat has no italic: it stays upright, as on the web and in the PDF.
+ let expected = family.styles[style] != nil ? style : (bold ? "bold" : "regular")
+ let file = try Self.bundled(family, expected)
+ XCTAssertEqual(Self.url(of: font)?.standardizedFileURL, file.standardizedFileURL, "\(family.key) \(style)")
+ let descriptor = try XCTUnwrap((CTFontManagerCreateFontDescriptorsFromURL(file as CFURL) as? [CTFontDescriptor])?.first)
+ let postScript = try XCTUnwrap(CTFontDescriptorCopyAttribute(descriptor, kCTFontNameAttribute) as? String)
+ XCTAssertEqual(CTFontCopyPostScriptName(font as CTFont) as String, postScript)
+ XCTAssertEqual(CTFontCopyFamilyName(font as CTFont) as String, family.name, "\(family.key)'s face names its family")
+ XCTAssertNotNil(DocsPlatformFont(name: postScript, size: 12), "\(postScript) resolves by name once registered")
+ #if os(macOS)
+ let registered = (CTFontManagerCopyAvailableFontURLs() as? [URL] ?? []).map(\.standardizedFileURL)
+ #else
+ let registered = (CTFontManagerCopyRegisteredFontDescriptors(.process, true) as? [CTFontDescriptor] ?? []).compactMap {
+ (CTFontDescriptorCopyAttribute($0, kCTFontURLAttribute) as? URL)?.standardizedFileURL
+ }
+ #endif
+ XCTAssertTrue(registered.contains(file.standardizedFileURL), "\(file.lastPathComponent) is registered for the process")
+ }
+ }
+ }
+
+ /// A name lookup is cached for the process: once anything has resolved
+ /// "Inter-Regular" while only an installed Inter answered to it,
+ /// NSFont(name:) keeps returning that copy even after the bundled one is
+ /// registered. The run's face must still be the bundled file. Needs an
+ /// Inter installed outside the app, as on the machine this was written on.
+ @MainActor func testAnInstalledCopyNeverStandsInForABundledFace() throws {
+ #if os(macOS)
+ DocsFonts.register()
+ let family = try XCTUnwrap(DocsFonts.family(key: "inter"))
+ let ours = try XCTUnwrap(DocsFonts.url(family, .regular))
+ let installed = (CTFontManagerCopyAvailableFontURLs() as? [URL] ?? []).filter {
+ $0.lastPathComponent.hasPrefix("Inter") && !$0.path.hasPrefix(ours.deletingLastPathComponent().path)
+ }
+ guard !installed.isEmpty else { throw XCTSkip("no Inter is installed outside the app to stand in for the bundled one") }
+ CTFontManagerUnregisterFontsForURL(ours as CFURL, .process, nil)
+ _ = NSFont(name: "Inter-Regular", size: 12)
+ CTFontManagerRegisterFontsForURL(ours as CFURL, .process, nil)
+ let byName = try XCTUnwrap(NSFont(name: "Inter-Regular", size: 12))
+ XCTAssertNotEqual(Self.url(of: byName)?.standardizedFileURL, ours.standardizedFileURL, "precondition: the name now answers with the installed copy")
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: ["font_inter": .object([:])], size: 12, heading: false))?.standardizedFileURL, ours.standardizedFileURL)
+ #else
+ throw XCTSkip("an installed copy of a bundled family is a Mac case")
+ #endif
+ }
+
+ /// The default is Carlito, body and headings; code stays Liberation Mono.
+ @MainActor func testTheDefaultFontIsCarlito() throws {
+ let shared = try Self.shared()
+ XCTAssertEqual(shared.standard, "carlito")
+ let carlito = try XCTUnwrap(shared.families.first { $0.key == "carlito" })
+ let mono = try XCTUnwrap(shared.families.first { $0.key == shared.code })
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: [:], size: 12, heading: false)), try Self.bundled(carlito, "regular"))
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: [:], size: 24, heading: true)), try Self.bundled(carlito, "bold"))
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: ["em": .object([:])], size: 12, heading: false)), try Self.bundled(carlito, "italic"))
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: ["code": .object([:]), "font_inter": .object([:])], size: 12, heading: false)), try Self.bundled(mono, "regular"))
+ // A family this build does not know is the default, as on the web and in the PDF.
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: ["font_futura": .object([:])], size: 12, heading: false)), try Self.bundled(carlito, "regular"))
+ // Two font marks (POST /d/{sqid}/updates allows it): the later in manifest order wins.
+ let inter = try XCTUnwrap(shared.families.first { $0.key == "inter" })
+ XCTAssertEqual(Self.url(of: DocsFonts.font(marks: ["font_carlito": .object([:]), "font_inter": .object([:])], size: 12, heading: false)), try Self.bundled(inter, "regular"))
+
+ // Every run of a rendered document, headings and lists included.
+ let projection = CRDTProjection(children: [
+ CRDTNode(id: "h", type: "heading", attrs: ["level": "1"], children: [CRDTNode(id: "ht", type: "text", runs: [CRDTRun(insert: "Title")])]),
+ CRDTNode(id: "p", type: "paragraph", children: [CRDTNode(id: "pt", type: "text", runs: [CRDTRun(insert: "Body "), CRDTRun(insert: "bold", marks: ["strong": .object([:])])])]),
+ CRDTNode(id: "l", type: "bullet_list", children: [CRDTNode(id: "li", type: "list_item", children: [CRDTNode(id: "lp", type: "paragraph", children: [CRDTNode(id: "lt", type: "text", runs: [CRDTRun(insert: "Item")])])])]),
+ CRDTNode(id: "e", type: "paragraph"),
+ ], canUndo: false, canRedo: false)
+ let rendered = NativeTextProjection.render(projection)
+ var faces = Set<String>()
+ rendered.enumerateAttribute(.font, in: NSRange(location: 0, length: rendered.length)) { value, _, _ in
+ if let font = value as? DocsPlatformFont, let url = Self.url(of: font) { faces.insert(url.lastPathComponent) } else { faces.insert("unbundled") }
+ }
+ XCTAssertEqual(faces, ["Carlito-Regular.ttf", "Carlito-Bold.ttf"])
+ }
+
+ /// Choosing Sans sets font_sans, Liberation Sans. It used to clear the
+ /// group, so Sans picked on the Mac showed as Carlito on the web.
+ @MainActor func testSansIsLiberationSansAndNotTheDefault() throws {
+ let model = DocsModel(client: NativeHTTP(origin: URL(string: "https://example.invalid")!))
+ model.detail = DocumentDetail(sqid: "fixture", title: "Fixture", guid: "fixture", can_write: true, can_share: false)
+ model.projection = CRDTProjection(children: [CRDTNode(id: "p", type: "paragraph", children: [CRDTNode(id: "t", type: "text", runs: [
+ CRDTRun(insert: "plain "), CRDTRun(insert: "sans", marks: ["font_sans": .object([:])]),
+ ])])], canUndo: false, canRedo: false)
+ let content = NativeTextProjection.render(model.projection!)
+ let commands = DocumentCommands(model: model, content: content)
+ model.selection = NSRange(location: 2, length: 0)
+ XCTAssertEqual(try XCTUnwrap(DocumentToolbarSelection(commands: commands)).font, "carlito", "unmarked text is Carlito")
+ model.selection = NSRange(location: 8, length: 0)
+ XCTAssertEqual(try XCTUnwrap(DocumentToolbarSelection(commands: commands)).font, "sans")
+
+ // The toolbar's own call for Sans, at a collapsed caret.
+ model.selection = NSRange(location: 2, length: 0)
+ XCTAssertTrue(commands.format("font_sans", exclusive: ["font_sans", "font_serif", "font_mono"]))
+ XCTAssertEqual(model.typingMarks?["font_sans"], .object([:]), "Sans is a mark, not the default")
+ let sans = DocsFonts.font(marks: ["font_sans": .object([:])], size: 12, heading: false)
+ XCTAssertEqual(CTFontCopyFamilyName(sans as CTFont) as String, "Liberation Sans")
+ }
+
+ /// A pasted font name maps to the shared list deterministically, once:
+ /// Word's names to their twins, other names to the family that stands in
+ /// for them, and anything else to the default rather than to Sans.
+ @MainActor func testPastedFontNamesMapToTheSharedList() {
+ // Copying unmarked text inside the app keeps it unmarked.
+ let source = NSAttributedString(string: "Plain\n", attributes: [.font: DocsFonts.font(marks: [:], size: 12, heading: false)])
+ let marks = DocsRichClipboard.marks(source.attributes(at: 0, effectiveRange: nil))
+ XCTAssertEqual(marks.keys.filter { $0.hasPrefix("font_") }, [], "Carlito pastes as the default, not as Sans")
+ let inter = DocsRichClipboard.marks([.font: DocsFonts.font(marks: ["font_inter": .object([:])], size: 12, heading: false)])
+ XCTAssertEqual(inter["font_inter"], .object([:]))
+
+ let html = DocsHTMLClipboard.blocks("<p><span class='docs-font-playfair'>Display</span> <span style=\"font-family: Calibri\">Word</span> <span style=\"font-family: Georgia\">Serif</span></p>")
+ let runs = html.flatMap { block -> [JSONValue] in
+ if case .object(let node) = block, case .array(let children)? = node["children"] {
+ return children.flatMap { child -> [JSONValue] in
+ if case .object(let text) = child, case .array(let runs)? = text["runs"] { return runs }
+ return []
+ }
+ }
+ return []
+ }
+ func marksOf(_ run: JSONValue) -> [String: JSONValue] {
+ if case .object(let values) = run, case .object(let marks)? = values["marks"] { return marks }
+ return [:]
+ }
+ func fonts(containing text: String) -> [String] {
+ let run = runs.first { if case .object(let values) = $0, case .string(let insert)? = values["insert"] { return insert.contains(text) }; return false }
+ return run.map { marksOf($0).keys.filter { $0.hasPrefix("font_") }.sorted() } ?? ["no run"]
+ }
+ XCTAssertEqual(fonts(containing: "Display"), ["font_playfair"])
+ XCTAssertEqual(fonts(containing: "Word"), [], "Calibri is Carlito, the default")
+ XCTAssertEqual(fonts(containing: "Serif"), ["font_caladea"], "Georgia's nearest in the shared list is Caladea")
+ }
+
+ /// Copying out writes every family's class, which the web editor parses,
+ /// and its name for any other application.
+ @MainActor func testCopiedHTMLNamesEveryFamily() throws {
+ let block: JSONValue = .object(["type": .string("paragraph"), "children": .array([.object(["type": .string("text"), "runs": .array([
+ .object(["insert": .string("Inter"), "marks": .object(["font_inter": .object([:])])]),
+ .object(["insert": .string("Sans"), "marks": .object(["font_sans": .object([:])])]),
+ ])])])])
+ let html = DocsRichClipboard.html([block])
+ XCTAssertTrue(html.contains("class=\"docs-font-inter\""), html)
+ XCTAssertTrue(html.contains("font-family:'Inter'"), html)
+ XCTAssertTrue(html.contains("class=\"docs-font-sans\""), html)
+ XCTAssertTrue(html.contains("font-family:'Liberation Sans'"), html)
+ }
+
+ #if os(macOS)
+ /// The first frame the editor draws is already the final one: every run
+ /// in Carlito, nothing blank, and no later frame differs. A frame drawn
+ /// with another face first would differ from the settled one, as the
+ /// Sans control shows.
+ @MainActor func testFirstFrameOfADocumentIsAlreadyInCarlito() throws {
+ let words = "Quarterly report. The first frame of this document is already in Carlito, and so is every frame after it."
+ func frames(_ marks: [String: JSONValue]?) throws -> (first: Data, settled: Data, storage: NSTextStorage) {
+ let projection = CRDTProjection(children: [
+ CRDTNode(id: "h", type: "heading", attrs: ["level": "1"], children: [CRDTNode(id: "ht", type: "text", runs: [CRDTRun(insert: "Report", marks: marks)])]),
+ CRDTNode(id: "p", type: "paragraph", children: [CRDTNode(id: "pt", type: "text", runs: [CRDTRun(insert: words, marks: marks)])]),
+ ], canUndo: false, canRedo: false)
+ let view = NativeDocumentTextView(content: NativeTextProjection.render(projection), generation: 1, didRender: { _ in }, compositionChanged: { _ in },
+ isEditable: false, paged: false, pendingInput: false, canRender: { _ in true }, currentSelection: { NSRange(location: 0, length: 0) },
+ selection: .constant(NSRange(location: 0, length: 0)), edit: { _ in true })
+ let host = NSHostingView(rootView: view.frame(width: 640, height: 240))
+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 640, height: 240), styleMask: [.borderless], backing: .buffered, defer: false)
+ window.contentView = host
+ host.layoutSubtreeIfNeeded()
+ func frame() throws -> Data {
+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))
+ host.cacheDisplay(in: host.bounds, to: rep)
+ return try XCTUnwrap(rep.representation(using: .png, properties: [:]))
+ }
+ let first = try frame()
+ RunLoop.main.run(until: Date().addingTimeInterval(0.6))
+ host.layoutSubtreeIfNeeded()
+ let settled = try frame()
+ let text = try XCTUnwrap(Self.textView(in: host))
+ return (first, settled, try XCTUnwrap(text.textStorage))
+ }
+ let carlito = try frames(nil)
+ XCTAssertEqual(carlito.first, carlito.settled, "the first frame is the final frame")
+ var faces = Set<String>()
+ carlito.storage.enumerateAttribute(.font, in: NSRange(location: 0, length: carlito.storage.length)) { value, range, _ in
+ guard (carlito.storage.string as NSString).substring(with: range).contains(where: { !$0.isWhitespace }) else { return }
+ faces.insert((value as? NSFont).flatMap(Self.url(of:))?.lastPathComponent ?? "unbundled")
+ }
+ XCTAssertEqual(faces, ["Carlito-Bold.ttf", "Carlito-Regular.ttf"])
+ let sans = try frames(["font_sans": .object([:])])
+ XCTAssertNotEqual(carlito.first, sans.first, "a frame in another face is visibly different")
+ XCTAssertGreaterThan(Self.ink(carlito.first), 2_000, "the first frame shows the words, not a gap")
+ }
+ static func ink(_ png: Data) -> Int {
+ guard let rep = NSBitmapImageRep(data: png) else { return 0 }
+ var dark = 0
+ for y in 0..<rep.pixelsHigh { for x in 0..<rep.pixelsWide where (rep.colorAt(x: x, y: y)?.usingColorSpace(.deviceGray)?.whiteComponent ?? 1) < 0.5 { dark += 1 } }
+ return dark
+ }
+ static func textView(in view: NSView) -> NSTextView? {
+ if let text = view as? NSTextView { return text }
+ for subview in view.subviews { if let text = textView(in: subview) { return text } }
+ return nil
+ }
+ #endif
+}
diff --git a/native/apple/Tests/DocsKitTests/DocumentAssetsTests.swift b/native/apple/Tests/DocsKitTests/DocumentAssetsTests.swift
index aa19225..da2e8d6 100644
--- a/native/apple/Tests/DocsKitTests/DocumentAssetsTests.swift
+++ b/native/apple/Tests/DocsKitTests/DocumentAssetsTests.swift
@@ -17,7 +17,9 @@ final class DocumentAssetsTests: XCTestCase {
await store.load(sources: [], client: client, documentPath: "/d/second")
XCTAssertTrue(store.images.isEmpty)
}
- @MainActor func testAllTwelveBundledFontFacesResolve() {
+ /// The three Liberation families keep their marks; the default is
+ /// Carlito (DocsFontsTests covers all sixteen families).
+ @MainActor func testLiberationFacesResolveForTheirMarks() {
for (key, family) in [("font_sans", "Sans"), ("font_serif", "Serif"), ("font_mono", "Mono")] {
for (bold, italic, face) in [(false, false, "Regular"), (true, false, "Bold"), (false, true, "Italic"), (true, true, "BoldItalic")] {
var marks: [String: JSONValue] = [key: .object([:])]
@@ -27,7 +29,7 @@ final class DocumentAssetsTests: XCTestCase {
XCTAssertEqual(font.fontName, "Liberation\(family)" + (face == "Regular" ? "" : "-\(face)"))
}
}
- XCTAssertEqual(DocsFonts.font(marks: [:], size: 12, heading: false).fontName, "LiberationSans")
+ XCTAssertEqual(DocsFonts.font(marks: [:], size: 12, heading: false).fontName, "Carlito-Regular")
XCTAssertEqual(DocsFonts.font(marks: ["size_24": .object([:])], size: 12, heading: false).pointSize, 24)
}
@MainActor func testAttachmentsOccupyOneUTF16UnitAndInvalidImagesFail() {
diff --git a/native/apple/Tests/DocsKitTests/DocumentTypographyTests.swift b/native/apple/Tests/DocsKitTests/DocumentTypographyTests.swift
index cbf9db5..e545cc9 100644
--- a/native/apple/Tests/DocsKitTests/DocumentTypographyTests.swift
+++ b/native/apple/Tests/DocsKitTests/DocumentTypographyTests.swift
@@ -4,12 +4,15 @@ import XCTest
@testable import DocsKit
final class DocumentTypographyTests: XCTestCase {
- // Synthetic fixture also measured in WebKit at 96 CSS px/in with the same
- // bundled Liberation fonts and the production [docs-text] CSS rules.
+ static let heading = "A shared document with consistent typography on every screen"
+ static let bold = "This is a synthetic layout fixture for the native and browser editors. The same bundled font, page width and paragraph styles must produce the same line breaks, including a long sentence that wraps across several lines."
+ static let body = "The quick brown fox jumps over the lazy dog. A small change in font metrics can move the final word onto another line, so this paragraph deliberately includes enough words to exercise wrapping at a fixed document width."
+ // Synthetic fixture, in Carlito, the default. BrowserTypographyTests'
+ // testTypographyFixtureIsWhatTheBrowserDraws measures the same blocks in
+ // WebKit with the bundled fonts and the production stylesheet, and holds
+ // browserLines to it.
@MainActor func testBrowserFixtureLineBreaks() throws {
- let heading = "A shared document with consistent typography on every screen"
- let bold = "This is a synthetic layout fixture for the native and browser editors. The same bundled font, page width and paragraph styles must produce the same line breaks, including a long sentence that wraps across several lines."
- let body = "The quick brown fox jumps over the lazy dog. A small change in font metrics can move the final word onto another line, so this paragraph deliberately includes enough words to exercise wrapping at a fixed document width."
+ let heading = Self.heading, bold = Self.bold, body = Self.body
func block(_ id: String, _ text: String, heading: Bool = false, strong: Bool = false) -> CRDTNode {
CRDTNode(id: id, type: heading ? "heading" : "paragraph", attrs: heading ? ["level": "1"] : nil, children: [CRDTNode(id: id + "t", type: "text", runs: [CRDTRun(insert: text, marks: strong ? ["strong": .object([:])] : nil)])])
}
@@ -33,15 +36,14 @@ final class DocumentTypographyTests: XCTestCase {
XCTAssertEqual(heights[3], 16.8, accuracy: 0.01)
XCTAssertEqual(lines, Self.browserLines)
}
- private static let browserLines: [String] = [
- "A shared document with consistent typography on",
- "every screen",
- "This is a synthetic layout fixture for the native and browser editors. The same",
- "bundled font, page width and paragraph styles must produce the same line",
- "breaks, including a long sentence that wraps across several lines.",
- "The quick brown fox jumps over the lazy dog. A small change in font metrics can move",
- "the final word onto another line, so this paragraph deliberately includes enough words to",
- "exercise wrapping at a fixed document width."
-]
-}
+ static let browserLines: [String] = [
+ "A shared document with consistent typography on every",
+ "screen",
+ "This is a synthetic layout fixture for the native and browser editors. The same bundled font,",
+ "page width and paragraph styles must produce the same line breaks, including a long",
+ "sentence that wraps across several lines.",
+ "The quick brown fox jumps over the lazy dog. A small change in font metrics can move the final",
+ "word onto another line, so this paragraph deliberately includes enough words to exercise",
+ "wrapping at a fixed document width.",
+ ]}
#endif
diff --git a/native/apple/Tests/DocsKitTests/RichClipboardTests.swift b/native/apple/Tests/DocsKitTests/RichClipboardTests.swift
index 24bbee3..bfa9b0a 100644
--- a/native/apple/Tests/DocsKitTests/RichClipboardTests.swift
+++ b/native/apple/Tests/DocsKitTests/RichClipboardTests.swift
@@ -69,7 +69,8 @@ private func runs(_ values: [JSONValue]) -> [JSONValue] {
#expect(text.count == 2)
#expect(text.allSatisfy { field(field($0, "marks")!, "link") == nil })
#expect(!flattened(values).contains { field($0, "type") == .string("image") })
- #expect(field(field(text[1], "marks")!, "font_serif") == .object([:]))
+ // Georgia maps onto the shared list's nearest family, Caladea (DocsFonts.family(cssStack:)).
+ #expect(field(field(text[1], "marks")!, "font_caladea") == .object([:]))
#expect(field(field(text[1], "marks")!, "size_18") == .object([:]))
}
diff --git a/native/ios/Review/DocsReviewPhone.swift b/native/ios/Review/DocsReviewPhone.swift
index f669020..8f15564 100644
--- a/native/ios/Review/DocsReviewPhone.swift
+++ b/native/ios/Review/DocsReviewPhone.swift
@@ -13,6 +13,8 @@ import SwiftUI
let origin = try? NativeHTTP.origin(config.origin), origin.scheme == "http", ["localhost", "127.0.0.1", "::1", "[::1]"].contains(origin.host ?? "") else { return nil }
return NativeHTTP(origin: origin, credential: config.credential)
}
+ // Every bundled face, registered before the first window, as the app does.
+ init() { DocsFonts.register() }
var body: some Scene {
WindowGroup {
if let client {
diff --git a/native/scripts/check-native.sh b/native/scripts/check-native.sh
index d4c768b..7d9e062 100755
--- a/native/scripts/check-native.sh
+++ b/native/scripts/check-native.sh
@@ -17,6 +17,8 @@ if [ "$core_only" = 0 ] && [ "$(uname -s)" != Darwin ]; then
fi
if [ -n "${DOCS_LLVM_LIBRARY_PATH:-}" ]; then export DYLD_LIBRARY_PATH="$DOCS_LLVM_LIBRARY_PATH"; fi
CARGO=${CARGO:-cargo}
+# The apps' copy of internal/fonts (manifest and TTFs) must match it.
+python3 native/scripts/sync-fonts.py --check
"$CARGO" build --locked --manifest-path native/crdt/Cargo.toml --release --target wasm32-unknown-unknown --lib
"$CARGO" test --locked --manifest-path native/crdt/Cargo.toml
"$CARGO" test --locked --manifest-path native/host/Cargo.toml
diff --git a/native/scripts/sync-fonts.py b/native/scripts/sync-fonts.py
new file mode 100755
index 0000000..d5ec346
--- /dev/null
+++ b/native/scripts/sync-fonts.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+"""Copy Docs' font vocabulary and TTFs into the Apple apps' resources.
+
+internal/fonts/fonts.json is the one list of families, and
+internal/fonts/files/ holds the files scripts/vendor-fonts.py cut for it.
+The server, the editor and the Rust renderer read them there. Swift
+Package Manager cannot reach outside native/apple, so the apps carry a
+copy at native/apple/Sources/DocsKit/Fonts: the manifest, each family's
+TTFs and its licence, in the same directories. Git stores identical
+files once, so the copy adds nothing to the repository.
+
+ native/scripts/sync-fonts.py # write the copy
+ native/scripts/sync-fonts.py --check # fail if it has drifted
+
+check-native.sh runs --check, on Linux too, so CI notices a font change
+that was not copied.
+"""
+
+import json
+import pathlib
+import shutil
+import sys
+
+ROOT = pathlib.Path(__file__).resolve().parents[2]
+SOURCE = ROOT / "internal" / "fonts"
+TARGET = ROOT / "native" / "apple" / "Sources" / "DocsKit" / "Fonts"
+
+
+def wanted():
+ """Every file the apps carry, as {relative path: source path}."""
+ manifest = json.loads((SOURCE / "fonts.json").read_text(encoding="utf-8"))
+ files = {"fonts.json": SOURCE / "fonts.json"}
+ for family in manifest["families"]:
+ directory = family["dir"]
+ files[f"{directory}/{family['licence']}"] = SOURCE / "files" / directory / family["licence"]
+ for name in family["styles"].values():
+ files[f"{directory}/{name}.ttf"] = SOURCE / "files" / directory / f"{name}.ttf"
+ return files
+
+
+def present():
+ if not TARGET.exists():
+ return set()
+ return {str(p.relative_to(TARGET)) for p in TARGET.rglob("*") if p.is_file()}
+
+
+def main(argv):
+ check = argv[1:] == ["--check"]
+ if argv[1:] not in ([], ["--check"]):
+ print("usage: sync-fonts.py [--check]", file=sys.stderr)
+ return 2
+ files = wanted()
+ missing = [str(p) for p in files.values() if not p.is_file()]
+ if missing:
+ print("sync-fonts: the manifest names files that do not exist:\n " + "\n ".join(missing), file=sys.stderr)
+ return 1
+ stale = sorted(present() - set(files))
+ changed = sorted(rel for rel, src in files.items()
+ if not (TARGET / rel).is_file() or (TARGET / rel).read_bytes() != src.read_bytes())
+ if check:
+ if stale or changed:
+ print("sync-fonts: native/apple/Sources/DocsKit/Fonts differs from internal/fonts. "
+ "Run native/scripts/sync-fonts.py.", file=sys.stderr)
+ for rel in changed:
+ print(" differs: " + rel, file=sys.stderr)
+ for rel in stale:
+ print(" not in the manifest: " + rel, file=sys.stderr)
+ return 1
+ size = sum((TARGET / rel).stat().st_size for rel in files if rel.endswith(".ttf"))
+ print(f"sync-fonts: {sum(r.endswith('.ttf') for r in files)} faces match internal/fonts ({size / 1e6:.1f} MB).")
+ return 0
+ for rel in stale:
+ (TARGET / rel).unlink()
+ for rel in changed:
+ (TARGET / rel).parent.mkdir(parents=True, exist_ok=True)
+ shutil.copyfile(files[rel], TARGET / rel)
+ for directory in sorted((p for p in TARGET.rglob("*") if p.is_dir()), reverse=True):
+ if not any(directory.iterdir()):
+ directory.rmdir()
+ print(f"sync-fonts: wrote {len(changed)}, removed {len(stale)}.")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))