@@ -20,22 +20,48 @@ const ARABIC_SPACING_SYMBOLS: [u16; 17] = [
20
20
0xFBC2 , // Wasla Above
21
21
] ;
22
22
23
- fn arabic_spacing_symbols ( t : & Testable ) -> StatusList {
23
+ fn arabic_spacing_symbols ( t : & Testable ) -> CheckFnResult {
24
24
let mut problems: Vec < Status > = vec ! [ ] ;
25
- let f = TTF . from_testable ( t) . expect ( "Not a TTF file" ) ;
26
- let cmap = f. get_cmap ( ) . unwrap ( ) ;
27
- let class_def = f. get_gdef_glyph_class_def ( ) . unwrap ( ) ;
25
+ let f = TTF . from_testable ( t) . ok_or ( "Not a TTF file" ) ?;
26
+ let cmap = match f. get_cmap ( ) {
27
+ Err ( _) => {
28
+ problems. push ( Status :: fail ( "Font lacks a cmap table" ) ) ;
29
+ return return_result ( problems) ;
30
+ } ,
31
+ Ok ( c) => c
32
+ } ;
33
+
34
+ let gdef = match f. get_gdef ( ) {
35
+ Err ( _) => {
36
+ problems. push ( Status :: fail ( "Font lacks a gdef table" ) ) ;
37
+ return return_result ( problems) ;
38
+ } ,
39
+ Ok ( g) => g
40
+ } ;
41
+
42
+ let class_def = match gdef. glyph_class_def ( ) {
43
+ None => return return_result ( problems) ,
44
+ Some ( d) => d
45
+ } ;
46
+
47
+ let class_def = match class_def {
48
+ Err ( e) => {
49
+ problems. push ( Status :: error ( & format ! ( "Some classDef error: {}" , e) ) ) ;
50
+ return return_result ( problems) ;
51
+ } ,
52
+ Ok ( d) => d
53
+ } ;
28
54
29
55
for codepoint in ARABIC_SPACING_SYMBOLS {
30
56
let gid = cmap. map_codepoint ( codepoint) ;
31
- if gid. is_some ( ) && class_def. get ( gid. unwrap ( ) ) == 3 {
57
+ if gid. is_some ( ) && class_def. get ( gid. ok_or ( "Failed to read gid" ) ? ) == 3 {
32
58
problems. push ( Status :: fail ( & format ! (
33
59
"U+{:04X} is defined in GDEF as a mark (class 3)." , codepoint) ) ) ;
34
60
}
35
61
}
36
62
37
63
if problems. is_empty ( ) {
38
- Status :: just_one_pass ( )
64
+ Ok ( Status :: just_one_pass ( ) )
39
65
} else {
40
66
return_result ( problems)
41
67
}
0 commit comments