oficina / docs Public

Both apps show the bundled fonts' licences

Astra's P2 on #84: the licences were bundled but nothing showed them.
Neither app had a credits or acknowledgements screen, so this adds one.

DocsFontLicencesView lists every family of the shared manifest, in
picker order, with its licence (SIL Open Font License 1.1 for all
sixteen; Apache License 2.0 is recognised too). Each page shows the
family's name, its licence, its copyright notice and the full licence
text, which is the bundled file the web serves under /static/fonts/.
Liberation's licence carries no copyright line, so its notice is the
one in the font's name table. Text styles throughout, a header trait on
the family name, combined list rows, and selectable licence text.

Mac: "Font licences" in the app menu under About, opening its own
window. iPhone and iPad: a Font licences button in the document list's
toolbar, opening a sheet with Close. Strings in all twelve locales.

testEveryBundledFamilyHasAViewableLicence failed against an empty stub
first. Rendering the pages then showed licence prose ("copyright
statement(s).", "COPYRIGHT HOLDER BE LIABLE") taken for notices, which
the test had let through. It now requires every notice line to name a
year, failed on that, and passes with notices read only from lines that
start "Copyright" or "©" and name a year (the old splitting on "\n" also
missed every line of the CRLF Source licences). An iOS-only test holds
each page to growing at accessibility text sizes; it builds, and runs
when a simulator does. A macOS check of the VoiceOver tree was dropped:
SwiftUI exposed no accessibility children to the test process, so it
could not have failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 09d50f02481cb4fbd8aaed9695b32a62c1893744 parent e91663b
18 files changed, +214 −2
  • native/apple/Sources/DocsApp/DocsApp.swift +3 −0
  • native/apple/Sources/DocsApp/DocsWindowCommands.swift +3 −0
  • native/apple/Sources/DocsKit/DocsFontLicences.swift +119 −0
  • native/apple/Sources/DocsKit/DocsFonts.swift +4 −2
  • native/apple/Sources/DocsKit/DocsWorkspace.swift +11 −0
  • native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings +2 −0
  • native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings +2 −0
  • native/apple/Tests/DocsKitTests/DocsFontLicencesTests.swift +50 −0

CI passed — run details

diff --git a/native/apple/Sources/DocsApp/DocsApp.swift b/native/apple/Sources/DocsApp/DocsApp.swift
index 00ea82e..dccb484 100644
--- a/native/apple/Sources/DocsApp/DocsApp.swift
+++ b/native/apple/Sources/DocsApp/DocsApp.swift
@@ -32,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/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/DocsFonts.swift b/native/apple/Sources/DocsKit/DocsFonts.swift
index 39c9542..1438c8c 100644
--- a/native/apple/Sources/DocsKit/DocsFonts.swift
+++ b/native/apple/Sources/DocsKit/DocsFonts.swift
@@ -28,6 +28,8 @@ struct DocsFontFamily: Sendable, Hashable, Identifiable {
/// 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 }
@@ -51,7 +53,7 @@ public enum DocsFonts {
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, styles: [String: String]
+ let fallback: [String], dir: String, licence: String, styles: [String: String]
}
let `default`: String, code: String, families: [Family]
}
@@ -95,7 +97,7 @@ public enum DocsFonts {
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, files: files))
+ 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 {
diff --git a/native/apple/Sources/DocsKit/DocsWorkspace.swift b/native/apple/Sources/DocsKit/DocsWorkspace.swift
index 84ec613..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 {
diff --git a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
index 783ec6b..9c17165 100644
--- a/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ar.lproj/Localizable.strings
@@ -171,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 e3a0c75..08d5108 100644
--- a/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/bn.lproj/Localizable.strings
@@ -171,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 ff34c16..3504be3 100644
--- a/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/en.lproj/Localizable.strings
@@ -176,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 5c86a25..0f6ea8a 100644
--- a/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/es.lproj/Localizable.strings
@@ -171,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 fde2253..9c10c9e 100644
--- a/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ga.lproj/Localizable.strings
@@ -171,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 031c44b..d86372b 100644
--- a/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/hi.lproj/Localizable.strings
@@ -171,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 f3b9c0f..2b4c8fd 100644
--- a/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ja.lproj/Localizable.strings
@@ -171,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 509dd6c..3cbcc6a 100644
--- a/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/pt.lproj/Localizable.strings
@@ -171,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 1233f0a..937afc6 100644
--- a/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/ru.lproj/Localizable.strings
@@ -171,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 a5a0ebf..fd4f78a 100644
--- a/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/vi.lproj/Localizable.strings
@@ -171,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 f0b7c36..793d3a2 100644
--- a/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/yue.lproj/Localizable.strings
@@ -171,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 df37507..6603606 100644
--- a/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
+++ b/native/apple/Sources/DocsKit/Resources/zh-Hans.lproj/Localizable.strings
@@ -171,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/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