|
| 1 | +use fontspector_checkapi::constants::GlyphClass; |
1 | 2 | use fontspector_checkapi::{prelude::*, testfont, FileTypeConvert};
|
2 | 3 |
|
3 | 4 | const ARABIC_SPACING_SYMBOLS: [u16; 17] = [
|
@@ -36,30 +37,19 @@ const ARABIC_SPACING_SYMBOLS: [u16; 17] = [
|
36 | 37 | fn arabic_spacing_symbols(t: &Testable, _context: &Context) -> CheckFnResult {
|
37 | 38 | let mut problems: Vec<Status> = vec![];
|
38 | 39 | let f = testfont!(t);
|
39 |
| - let cmap = f |
40 |
| - .get_cmap() |
41 |
| - .map_err(|_| CheckError::Error("Font lacks a cmap table".to_string()))?; |
42 |
| - let gdef = f |
43 |
| - .get_gdef() |
44 |
| - .map_err(|_| CheckError::Error("Font lacks a gdef table".to_string()))?; |
45 |
| - |
46 |
| - let class_def = match gdef.glyph_class_def() { |
47 |
| - None => return return_result(problems), |
48 |
| - Some(d) => d.map_err(|e| CheckError::Error(format!("Some classDef error: {}", e)))?, |
49 |
| - }; |
| 40 | + let cmap = f.get_cmap()?; |
50 | 41 |
|
51 | 42 | for codepoint in ARABIC_SPACING_SYMBOLS {
|
52 |
| - let gid = cmap.map_codepoint(codepoint); |
53 |
| - if gid.is_some() |
54 |
| - && class_def.get(gid.ok_or(CheckError::Error("Failed to read gid".to_string()))?) == 3 |
55 |
| - { |
56 |
| - problems.push(Status::fail( |
57 |
| - "gdef-mark", |
58 |
| - &format!( |
59 |
| - "U+{:04X} is defined in GDEF as a mark (class 3).", |
60 |
| - codepoint |
61 |
| - ), |
62 |
| - )); |
| 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 | + } |
63 | 53 | }
|
64 | 54 | }
|
65 | 55 |
|
|
0 commit comments