Success Criterion 1.4.12 - Level AA
Text Spacing
Ensure there is enough space between paragraphs, letters and words. People with dyslexia can read faster as a result. People who are visually impaired can also read the text more easily. White space can also help people with a cognitive impairment to distinguish parts from each other.
Impact
People with dyslexia can read faster if sufficient distance between texts is used.
People who have poor vision can read more easily if there is sufficient distance between text, words and paragraphs.
Check
“Is there enough distance between letters, lines and paragraphs?”
This can be tested visually, no assistive technologies are needed.
Solution
Adjust text spacing
On Android, you can use the following attribute to increase text spacing:
letterSpacing
: set spacing between letterslineHeight
: set spacing between lineslineSpacingExtra
: increase spacing between lineslineSpacingMultiplier
: multiply spacing between linesmarginBottom
: set spacing between paragraphs
<TextView
android:text="Appt"
android:letterSpacing="3sp"
android:lineHeight="20sp"
android:lineSpacingExtra="5sp"
android:lineSpacingMultiplier="1.5"
android:layout_marginBottom="20dp"/>
Support bold text
Android 12 has added the fontWeightAdjustment
property. The property returns an integer between 1
and 1000
, which indicates the current user preference for increasing font weight. The constant FontStyle.FONT_WEIGHT_BOLD
has a value of 700
.
fun Context.prefersBoldFont(): Boolean {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
return false
}
return resources.configuration.fontWeightAdjustment >= FontStyle.FONT_WEIGHT_BOLD
}