mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
Merge pull request #1936
This commit is contained in:
@@ -3,7 +3,7 @@ use super::{FontFace, UnicodeSegmentation};
|
||||
/// Is `family` a symbol font (characters at U+F000 + code)?
|
||||
pub(crate) fn is_symbol_font(family: &str) -> bool {
|
||||
let f = family.to_ascii_lowercase();
|
||||
f.starts_with("wingdings") || f == "symbol" || f.starts_with("webdings") || f.starts_with("marlett")
|
||||
f.starts_with("wingdings") || f == "symbol" || f.starts_with("webdings") || f.starts_with("marlett") || f.starts_with("monotype sorts")
|
||||
}
|
||||
|
||||
/// Does `face` draw the symbol-font character `c` (a U+F0xx private-use code)? Either directly at
|
||||
@@ -300,7 +300,11 @@ pub fn map_symbol_bullet(c: &str, font: Option<&str>) -> String {
|
||||
}
|
||||
// Only the legacy symbol fonts: "Noto Sans Symbols" and the like are Unicode fonts whose
|
||||
// characters (❑ ❖) are drawn as they are. Private-use codes are mapped only when no font is named.
|
||||
if f.contains("wingdings") || f == "symbol" || (font.is_none() && ('\u{f000}'..='\u{f0ff}').contains(&first)) {
|
||||
if f.contains("wingdings")
|
||||
|| (f.starts_with("monotype sorts") && ((first as u32) < 0x100 || ('\u{f000}'..='\u{f0ff}').contains(&first)))
|
||||
|| f == "symbol"
|
||||
|| (font.is_none() && ('\u{f000}'..='\u{f0ff}').contains(&first))
|
||||
{
|
||||
let code = (first as u32) & 0xff;
|
||||
// Wingdings 2 and 3 put different shapes at the same codes.
|
||||
if f.starts_with("wingdings 2") {
|
||||
@@ -327,6 +331,8 @@ pub fn map_symbol_bullet(c: &str, font: Option<&str>) -> String {
|
||||
return m.to_string();
|
||||
}
|
||||
let m = match code {
|
||||
0x6d if f.starts_with("monotype sorts") => '○',
|
||||
0xf0 if f.contains("wingdings") => '⇨',
|
||||
0xa7 => '▪',
|
||||
0xd8 => '➢',
|
||||
0xe8 => '➔',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
use deckcraft_text::map_symbol_bullet;
|
||||
|
||||
#[test]
|
||||
fn monotype_sorts_m_bullet_is_open_circle() {
|
||||
assert_eq!(map_symbol_bullet("m", Some("Monotype Sorts")), "\u{25CB}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wingdings_eth_bullet_is_right_arrow() {
|
||||
assert_eq!(map_symbol_bullet("\u{f0}", Some("Wingdings")), "\u{21E8}");
|
||||
assert_eq!(map_symbol_bullet("\u{f0f0}", Some("Wingdings")), "\u{21E8}");
|
||||
}
|
||||
Reference in New Issue
Block a user