@@ -160,6 +160,30 @@ fn write_lang(
160160 writeln ! ( w, " }}" ) ?;
161161 writeln ! ( w) ?;
162162
163+ // Implementation of `hyphenation_character`.
164+ writeln ! ( w, " /// The default character used to join syllables." ) ?;
165+ writeln ! ( w, " ///" ) ?;
166+ writeln ! ( w, " /// Returns `Some('\\ u{{ad}}')` (SOFT HYPHEN) for most languages, but `None`" ) ?;
167+ writeln ! (
168+ w,
169+ " /// for Indic scripts where visual hyphenation is not conventional."
170+ ) ?;
171+ writeln ! ( w, " pub fn hyphenation_character(self) -> Option<char> {{" ) ?;
172+ writeln ! ( w, " match self {{" ) ?;
173+ for & ( name, _, _, script, ..) in languages {
174+ if !is_indic_script ( script) {
175+ continue ;
176+ }
177+ let feature = name. to_lowercase ( ) ;
178+ write ! ( w, " " ) ?;
179+ write_cfg ( w, & feature) ?;
180+ writeln ! ( w, " Self::{name} => None," ) ?;
181+ }
182+ writeln ! ( w, " _ => Some('\\ u{{ad}}')," ) ?;
183+ writeln ! ( w, " }}" ) ?;
184+ writeln ! ( w, " }}" ) ?;
185+ writeln ! ( w) ?;
186+
163187 // Implementation of `root`.
164188 writeln ! ( w, " fn root(self) -> State<'static> {{" ) ?;
165189 writeln ! ( w, " match self {{" ) ?;
@@ -175,6 +199,14 @@ fn write_lang(
175199 writeln ! ( w, "}}" )
176200}
177201
202+ /// Returns true for Indic scripts where visual hyphenation is not conventional.
203+ fn is_indic_script ( script : & str ) -> bool {
204+ matches ! (
205+ script,
206+ "Beng" | "Deva" | "Gujr" | "Guru" | "Knda" | "Mlym" | "Orya" | "Taml" | "Telu"
207+ )
208+ }
209+
178210fn write_cfg ( w : & mut String , feature : & str ) -> fmt:: Result {
179211 writeln ! ( w, r#"#[cfg(feature = "{feature}")]"# )
180212}
0 commit comments