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