Description
While implementing the EPUB technique document in Readium, I noticed an issue that I'd like to double-check with the group.
In section 3.1.2.3, we display "Not readable in read aloud or dynamic braille" in case the publication contains only audio content OR only visual content.
This means that if a publication contains a mix of non-textual access modes, we will fallback on displaying "No information about nonvisual reading is available". For example if it has the accessModes
: [visual, mathOnVisual]
, or [visual, auditory]
.
I suggest instead adding replacing the audio_only_content
and visual_only_content
variables with a single no_text_content
which is true
if accessModes
and accessModesSufficient
are not empty, but they don't contain textual
.
This is how I implemented it in Readium's Swift toolkit:
let allText = a11y.accessModes == [.textual]
|| a11y.accessModesSufficient.contains([.textual])
let someText = a11y.accessModes.contains(.textual)
|| a11y.accessModesSufficient.contains { $0.contains(.textual) }
let noText = !(a11y.accessModes.isEmpty && a11y.accessModesSufficient.isEmpty)
&& !a11y.accessModes.contains(.textual)
&& !a11y.accessModesSufficient.contains { $0.contains(.textual) }
let hasTextAlt = a11y.features.containsAny(
.longDescription, .alternativeText, .describedMath, .transcript
)
nonvisualReading = {
if allText {
return .readable
} else if someText || hasTextAlt {
return .notFully
} else if noText {
return .unreadable
} else {
return .noMetadata
}
}()
and the associated tests:
func testWaysOfReadingInitNonvisualReading() {
func test(_ a11y: Accessibility?, expected: WaysOfReading.NonvisualReading) {
let sut = WaysOfReading(publication: publication(accessibility: a11y))
XCTAssertEqual(sut.nonvisualReading, expected)
}
// No metadata
test(nil, expected: .noMetadata)
test(.init(accessModes: [], accessModesSufficient: []), expected: .noMetadata)
// It's readable when there's only textual content or an access mode
// sufficient of textual.
test(.init(accessModes: [.textual]), expected: .readable)
test(.init(accessModes: [.auditory], accessModesSufficient: [[.textual]]), expected: .readable)
// It's partially readable:
// ... when it contains textual content and other medium.
test(.init(accessModes: [.textual, .auditory]), expected: .notFully)
test(.init(accessModesSufficient: [[.textual, .auditory]]), expected: .notFully)
// ... when it contains textual alternatives features.
test(.init(accessModes: [.visual], features: [.longDescription]), expected: .notFully)
test(.init(accessModes: [.visual], features: [.alternativeText]), expected: .notFully)
test(.init(accessModes: [.visual], features: [.describedMath]), expected: .notFully)
test(.init(accessModes: [.visual], features: [.transcript]), expected: .notFully)
// It's not readable:
// ... when it contains only audio content.
test(.init(accessModes: [.auditory]), expected: .unreadable)
// ... when it contains only visual content.
test(.init(accessModes: [.visual]), expected: .unreadable)
// ... when it contains a mix of non textual content.
test(.init(accessModes: [.visual, .auditory, .mathOnVisual]), expected: .unreadable)
}