Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/styling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl MathStyle {
) -> MathStyle {
use MathVariant::*;
use conversions::*;
let c = normalize(c);
match (variant.unwrap_or(Plain), bold, italic) {
(SansSerif, false, Some(false)) if is_latin(c) => MathStyle::SansSerif,
(SansSerif, false, _) if is_latin(c) => MathStyle::SansSerifItalic,
Expand Down Expand Up @@ -370,6 +371,7 @@ impl fmt::Display for ToStyle {
pub fn to_style(c: char, style: MathStyle) -> ToStyle {
use MathStyle::*;
use conversions::*;
let c = normalize(c);
let styled = match style {
Plain => [c, '\0'],
Bold => [to_bold(c), '\0'],
Expand Down Expand Up @@ -416,6 +418,20 @@ mod conversions {
const VARIATION_SELECTOR_1: char = '\u{FE00}';
const VARIATION_SELECTOR_2: char = '\u{FE01}';

/// Applies relevant canonical decompositions.
///
/// For example, this function converts U+2126 OHM SIGN to the regular
/// capital omega.
///
/// All functions in this module expect that characters have been
/// normalized.
pub fn normalize(c: char) -> char {
match c {
'Ω' => 'Ω',
_ => c,
}
}

#[inline]
pub fn is_digit(c: char) -> bool {
c.is_ascii_digit()
Expand Down
Loading