|
| 1 | +use fontspector_checkapi::constants::GlyphClass; |
| 2 | +use fontspector_checkapi::{prelude::*, testfont, FileTypeConvert}; |
| 3 | + |
| 4 | +const ARABIC_SPACING_SYMBOLS: [u16; 17] = [ |
| 5 | + 0xFBB2, // Dot Above |
| 6 | + 0xFBB3, // Dot Below |
| 7 | + 0xFBB4, // Two Dots Above |
| 8 | + 0xFBB5, // Two Dots Below |
| 9 | + 0xFBB6, // Three Dots Above |
| 10 | + 0xFBB7, // Three Dots Below |
| 11 | + 0xFBB8, // Three Dots Pointing Downwards Above |
| 12 | + 0xFBB9, // Three Dots Pointing Downwards Below |
| 13 | + 0xFBBA, // Four Dots Above |
| 14 | + 0xFBBB, // Four Dots Below |
| 15 | + 0xFBBC, // Double Vertical Bar Below |
| 16 | + 0xFBBD, // Two Dots Vertically Above |
| 17 | + 0xFBBE, // Two Dots Vertically Below |
| 18 | + 0xFBBF, // Ring |
| 19 | + 0xFBC0, // Small Tah Above |
| 20 | + 0xFBC1, // Small Tah Below |
| 21 | + 0xFBC2, // Wasla Above |
| 22 | +]; |
| 23 | + |
| 24 | +#[check( |
| 25 | + id = "com.google.fonts/check/arabic_spacing_symbols", |
| 26 | + title = "Check that Arabic spacing symbols U+FBB2–FBC1 aren't classified as marks.", |
| 27 | + rationale = " |
| 28 | + Unicode has a few spacing symbols representing Arabic dots and other marks, |
| 29 | + but they are purposefully not classified as marks. |
| 30 | +
|
| 31 | + Many fonts mistakenly classify them as marks, making them unsuitable |
| 32 | + for their original purpose as stand-alone symbols to used in pedagogical |
| 33 | + contexts discussing Arabic consonantal marks. |
| 34 | + ", |
| 35 | + proposal = "https://github.com/googlefonts/fontbakery/issues/4295" |
| 36 | +)] |
| 37 | +fn arabic_spacing_symbols(t: &Testable, _context: &Context) -> CheckFnResult { |
| 38 | + let mut problems: Vec<Status> = vec![]; |
| 39 | + let f = testfont!(t); |
| 40 | + let cmap = f.get_cmap()?; |
| 41 | + |
| 42 | + for codepoint in ARABIC_SPACING_SYMBOLS { |
| 43 | + if let Some(gid) = cmap.map_codepoint(codepoint) { |
| 44 | + if f.gdef_class(gid) == Some(GlyphClass::Mark) { |
| 45 | + problems.push(Status::fail( |
| 46 | + "gdef-mark", |
| 47 | + &format!( |
| 48 | + "U+{:04X} is defined in GDEF as a mark (class 3).", |
| 49 | + codepoint |
| 50 | + ), |
| 51 | + )); |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + if problems.is_empty() { |
| 57 | + Ok(Status::just_one_pass()) |
| 58 | + } else { |
| 59 | + return_result(problems) |
| 60 | + } |
| 61 | +} |
0 commit comments