Skip to content

Commit f13d7c3

Browse files
committed
Add support for styling U+2126 OHM SIGN
1 parent 6941f8d commit f13d7c3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/styling.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl MathStyle {
230230
) -> MathStyle {
231231
use MathVariant::*;
232232
use conversions::*;
233+
let c = normalize(c);
233234
match (variant.unwrap_or(Plain), bold, italic) {
234235
(SansSerif, false, Some(false)) if is_latin(c) => MathStyle::SansSerif,
235236
(SansSerif, false, _) if is_latin(c) => MathStyle::SansSerifItalic,
@@ -370,6 +371,7 @@ impl fmt::Display for ToStyle {
370371
pub fn to_style(c: char, style: MathStyle) -> ToStyle {
371372
use MathStyle::*;
372373
use conversions::*;
374+
let c = normalize(c);
373375
let styled = match style {
374376
Plain => [c, '\0'],
375377
Bold => [to_bold(c), '\0'],
@@ -416,6 +418,20 @@ mod conversions {
416418
const VARIATION_SELECTOR_1: char = '\u{FE00}';
417419
const VARIATION_SELECTOR_2: char = '\u{FE01}';
418420

421+
/// Applies relevant canonical decompositions.
422+
///
423+
/// For example, this function converts U+2126 OHM SIGN to the regular
424+
/// capital omega.
425+
///
426+
/// All functions in this module expect that characters have been
427+
/// normalized.
428+
pub fn normalize(c: char) -> char {
429+
match c {
430+
'Ω' => 'Ω',
431+
_ => c,
432+
}
433+
}
434+
419435
#[inline]
420436
pub fn is_digit(c: char) -> bool {
421437
c.is_ascii_digit()

0 commit comments

Comments
 (0)