ui/hyph.rs#
Source: lib/ui/hyph.rs
hyph -- hyphenation of wrapped texts and text boxes (spell::Hyphenator, text::segment)
TX_HYPHENATE (text style, with TX_WRAP), TB_HYPHENATE (textbox, with TB_MULTI | TB_WRAP)
a word that does not fit at the end of a line is broken at its last hyphenation
point that fits, and a hyphen is drawn there. Soft hyphens (U+00AD) in the text
work in every wrapped text, with or without the flag: invisible inside a line, a
hyphen where the line breaks after one
hyph_language(tag) the language: a BCP 47 tag; "" (default) = font_language(),
the user's tag of the UI language
next_hyph_language(tag) the language of the next wrapped text (TX_WRAP) or multi-line
box only (it counts when that one hyphenates)
hyph_sources(SRC_*) where dictionaries come from (spell crate; 0 = the default:
everything in window mode, only app:// in headless runs, so
scripts never depend on the machine)
hyph_set(tag, hyphenator) the app's own patterns for a language (before any source)
hyphenator(tag) -> Option<Arc<Hyphenator>> the patterns for a tag ("": the current
language), found (spell::find_hyphen: hyph_xx_YY.dic of
LibreOffice, /usr/share/hyphen, config://hyphen,
app://hyphen) and read on first use, then kept
A dictionary is read on the UI thread the first time a language is needed (de_DE, 1 MB:
some 40 ms); a language without one keeps texts unhyphenated (soft hyphens still work).
impl Ui
fn hyph_language(&mut self, tag: &str)the hyphenation language: a BCP 47 tag ("de-DE"); "" = the UI language'sfn next_hyph_language(&mut self, tag: &str)the language of the next wrapped text or multi-line box only (it counts when that one hyphenates: TX_HYPHENATE, TB_HYPHENATE)fn hyph_sources(&mut self, sources: u32)where hyphenation dictionaries come from (spell::SRC_*; 0 = the default)fn hyph_set(&mut self, tag: &str, h: Hyphenator)the app's own hyphenation patterns for a language tag ("de", "en-US")fn hyphenator(&mut self, tag: &str) -> Option<Arc<Hyphenator>>the hyphenation patterns for a tag ("": the current language), None when there are none