unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

bidi/implicit.mbt
1///|2/// I1-I2: Implicit Level Calculation3///4/// These rules adjust embedding levels based on resolved types.56///|7/// Apply implicit level rules8fn apply_implicit_levels(9  types : Array[BidiClass],10  levels : Array[Int32],11) -> Unit {12  for i, bc in types {13    let level = levels[i]1415    // Skip removed characters (BN)16    if bc is BN {17      continue18    }1920    // I1: For characters at even (LTR) levels21    // R -> level + 122    // AN, EN -> level + 223    if level % 2 == 0 {24      match bc {25        R => levels[i] = level + 126        AN | EN => levels[i] = level + 227        _ => ()28      }29    } else {30      // I2: For characters at odd (RTL) levels31      // L, EN, AN -> level + 132      match bc {33        L | EN | AN => levels[i] = level + 134        _ => ()35      }36    }37  }38}39