Repository navigation
v0.27.0
Fixed
Widgets
- Right-to-left text in a text field is visible. Arabic or Hebrew typed
into aTextInput,SearchFieldorPasswordFieldwas laid out at an
infinite x: nothing was drawn, and every caret, click and selection
position was infinite. It now sits in the field (text-typeset 3.2).
Added
Core
content_language: the language a widget's content is written in, for
its whole subtree, the equivalent of HTML'slang. It is a builder method
on every widget (.content_language(tag), also onHandlerSetand in
teksu!), takes aLanguageTag, anOption<LanguageTag>or a signal of
either, and is inherited by the subtree; an overlay's content inherits it
from the widget the overlay is attached to. The accessibility tree carries
it as AccessKit'slanguagewherever it differs from what a node inherits,
so a screen reader can read a field holding a translation, or a language's
own name, in that language; declaring nothing leaves the tree as it was.
A list row or a table cell named from its content is read in that
content's language.
Widgets read it withcontent_language()onLayoutContext,PaintContext
(a new public field) andEventContext, and tests with
WidgetTree::content_language(id).LanguageTag, a BCP 47 language tag checked and written in canonical
case (en-usbecomesen-US,en_USis accepted), with
likely_direction(). In the prelude.- A text run can state its own language:
TextRunSource::with_language,
and alanguagefield onTextRunSpec.
Canvas
TextBackend::layout_in_languagelays aTextLayoutRequest(one of
the four layout calls) out for text in a given language; its default
ignores the language, so other backends keep working.Canvasgained
draw_text_in_languageanddraw_paragraph_in_language.
Widgets
- Text inputs read in their own direction.
TextInputField,
TextInput,SearchFieldandRichTextEditortake abase_direction
(TextBaseDirection::{Auto, LeftToRight, RightToLeft}, or a signal of
one).Auto, the default, follows the text's first strongly directional
character, then the declaredcontent_language, then the window: an empty
field declared Arabic opens with its caret on the right. The editing engine
is told the direction and the language; nothing is written to the text. ComboBox::item_languagedeclares the language of each item, on its
dropdown row and on the closed combo's value.LanguageSwitcheruses it:
each language's own name is read in that language, while the control keeps
the interface's.
Automation
- The language a node is read in.
SemanticNode::languagewhere a
declaration took effect,TextRangeInfo::languagefor the language a text
is read in, alanguagefilter onfind_node, and alanguage_equals
assertion onassert_node.accessibility::auditgained
effective_languages, andNodeTextInfoalanguagefield.
Changed
Widgets
- Every text input now follows the direction of its text (the new
base_direction,Autoby default). Arabic or Hebrew typed into a field in
a left-to-right window starts at the right edge and is announced right to
left;text_alignment(Leading)andTrailingfollow the text's direction
rather than the window's, so Latin text aligned to its leading edge in a
right-to-left window sits on the left. The arrow keys move the caret the
way they point through right-to-left text, as the rich text editor already
did. A field that must stay left to right sets
.base_direction(TextBaseDirection::LeftToRight); see "Text that reads in
its own direction" indocs/i18n.md. - Text is shaped in its language. Labels (
TextWidget, and every
control drawing its text with one), the text inputs and the rich text editor
pass the declaredcontent_languageto the shaper, which uses a font's
language-specific forms (OpenTypelocl) and draws Han in the language's
forms: the endonym 日本語 in a French list is drawn with Japanese glyphs.
A rich text paragraph with a language of its own (or the document's
default) is read in it by a screen reader. Requires text-typeset 3.2.
Internationalization
- Kurdish (
ku) with no script subtag is laid out left to right.
Kurmanji, whatkuusually means, is written in Latin script; Sorani
(ckb) stays right to left. A script subtag now decides the direction both
ways, soar-Latnandsd-Devaare left to right as well. The table is
LanguageTag::likely_direction's, whichrtl_from_localenow calls.
Full Changelog: v0.26.0...v0.27.0