//! Joining: which form each letter of Arabic (and Syriac, N'Ko, …) takes — //! alone, at the start of a word, in its middle or at its end — from //! whether its neighbours join it. The forms themselves are the font's //! (its `isol`, `init`, `medi` and `fina` features); this says which a //! letter asks for. use alloc::vec::Vec; use crate::tables; #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u8)] pub enum Joining { /// Joins neither side (most characters). U, /// Joins the letter before it only (alef, dal, reh, waw). R, /// Joins the letter after it only. L, /// Joins both sides (beh, seen, lam, …). D, /// Makes its neighbours join, itself drawn by none (tatweel's kin, ZWJ). C, /// Passed over: marks between letters do not break their joining. T, } const JOININGS: [Joining; 6] = [ Joining::U, Joining::R, Joining::L, Joining::D, Joining::C, Joining::T, ]; pub fn joining(c: char) -> Joining { crate::find(&tables::JOINING, c as u32).map_or(Joining::U, |i| JOININGS[usize::from(i)]) } #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Form { /// Not a joining letter: no form feature applies. None, Isolated, Initial, Medial, Final, } /// The form of each character of `text`, in logical order. pub fn forms(text: &[char]) -> Vec