Skip to content

Commit ee113d9

Browse files
authored
Merge pull request #5 from felipesanches/rationales_not_optional
Rationale and proposal fields are not optional
2 parents 2818a76 + 37122c3 commit ee113d9

File tree

11 files changed

+47
-47
lines changed

11 files changed

+47
-47
lines changed

fontspector-checkapi/src/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub type CheckId = String;
88
pub struct Check<'a> {
99
pub id: &'a str,
1010
pub title: &'a str,
11-
pub rationale: Option<&'a str>,
12-
pub proposal: Option<&'a str>,
11+
pub rationale: &'a str,
12+
pub proposal: &'a str,
1313
pub check_one: Option<&'a dyn Fn(&Testable) -> CheckFnResult>,
1414
pub check_all: Option<&'a dyn Fn(&FontCollection) -> CheckFnResult>,
1515
pub hotfix: Option<&'a dyn Fn(&Testable) -> FixFnResult>,
@@ -24,7 +24,7 @@ pub struct CheckResult {
2424
pub status: Status,
2525
pub check_id: CheckId,
2626
pub check_name: String,
27-
pub check_rationale: Option<String>,
27+
pub check_rationale: String,
2828
pub filename: Option<String>,
2929
}
3030

@@ -41,7 +41,7 @@ impl<'a> Check<'a> {
4141
status,
4242
check_id: self.id.to_string(),
4343
check_name: self.title.to_string(),
44-
check_rationale: self.rationale.map(|x| x.to_string()),
44+
check_rationale: self.rationale.to_string(),
4545
filename: file.map(|x| x.filename.clone()),
4646
}
4747
}

fontspector-cli/src/main.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ fn main() {
131131
if args.verbose > 1 {
132132
println!(" {:}", result.check_name);
133133
}
134-
if let Some(rationale) = &result.check_rationale {
135-
if args.verbose > 1 {
136-
termimad::print_inline(&format!("Rationale:\n\n```\n{}\n```\n", rationale));
137-
}
134+
if args.verbose > 1 {
135+
termimad::print_inline(&format!("Rationale:\n\n```\n{}\n```\n", result.check_rationale));
138136
}
139137
termimad::print_inline(&format!("**{:}**", result.status));
140138
if result.status.code != StatusCode::Fail {

profile-googlefonts/src/family.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ fn family_equal_codepoint_coverage(c: &Testable) -> CheckFnResult {
4040
return_result(problems)
4141
}
4242

43-
pub const EQUAL_CODEPOINT_COVERAGE_CHECK: Check = Check {
43+
pub const CHECK_FAMILY_EQUAL_CODEPOINT_COVERAGE: Check = Check {
4444
id: "com.google.fonts/check/family/equal_codepoint_coverage",
4545
title: "Fonts have equal codepoint coverage?",
46-
rationale: Some(
47-
"For a given family, all fonts must have the same codepoint coverage.
48-
This is because we want to avoid the situation where, for example,
49-
a character is present in a regular font but missing in the italic style;
50-
turning on italic would cause the character to be rendered either as a
51-
fake italic (auto-slanted) or to show tofu.",
52-
),
53-
proposal: Some("https://github.com/fonttools/fontbakery/issues/4180"),
46+
rationale: "For a given family, all fonts must have the same codepoint coverage.
47+
This is because we want to avoid the situation where, for example,
48+
a character is present in a regular font but missing in the italic
49+
style; turning on italic would cause the character to be rendered
50+
either as a fake italic (auto-slanted) or to show tofu.",
51+
proposal: "https://github.com/fonttools/fontbakery/issues/4180",
5452
check_one: Some(&family_equal_codepoint_coverage),
5553
check_all: None,
5654
applies_to: "TTF",

profile-googlefonts/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#![deny(clippy::unwrap_used, clippy::expect_used)]
22
mod family;
33
mod metadata;
4-
use family::EQUAL_CODEPOINT_COVERAGE_CHECK;
4+
use family::CHECK_FAMILY_EQUAL_CODEPOINT_COVERAGE;
55
use fontspector_checkapi::prelude::*;
6-
use metadata::VALIDATE_METADATA_PB;
6+
use metadata::CHECK_METADATA_PARSES;
77

88
pub struct GoogleFonts;
99
impl fontspector_checkapi::Plugin for GoogleFonts {
1010
fn register(&self, cr: &mut Registry) -> Result<(), String> {
1111
let mdpb = FileType::new("METADATA.pb");
1212
cr.register_filetype("MDPB", mdpb);
13-
cr.register_check(EQUAL_CODEPOINT_COVERAGE_CHECK);
14-
cr.register_check(VALIDATE_METADATA_PB);
13+
cr.register_check(CHECK_FAMILY_EQUAL_CODEPOINT_COVERAGE);
14+
cr.register_check(CHECK_METADATA_PARSES);
1515
let profile = Profile::from_toml(
1616
r#"
1717
include_profiles = ["universal"]

profile-googlefonts/src/metadata.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ fn validate_metadatapb(c: &Testable) -> CheckFnResult {
4343
}
4444
}
4545

46-
pub const VALIDATE_METADATA_PB: Check = Check {
46+
pub const CHECK_METADATA_PARSES: Check = Check {
4747
id: "com.google.fonts/check/metadata/parses",
48-
title: "Check METADATA.pb parse correctly",
49-
rationale: None,
50-
proposal: None,
48+
title: "Check METADATA.pb parses correctly",
49+
rationale: "
50+
The purpose of this check is to ensure that the METADATA.pb file is not
51+
malformed.
52+
",
53+
proposal: "https://github.com/fonttools/fontbakery/issues/2248",
5154
check_all: None,
5255
check_one: Some(&validate_metadatapb),
5356
applies_to: "MDPB",

profile-testplugin/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ fn validate_toml(c: &Testable) -> CheckFnResult {
1919
pub const SAY_HELLO: Check = Check {
2020
id: "com.google.fonts/check/test/say_hello",
2121
title: "Check that the plugin protocol is working",
22-
rationale: None,
23-
proposal: None,
22+
rationale: "This check is part of the example of how to create plugins.",
23+
proposal: "https://github.com/simoncozens/fontspector/commit/5fdf9750991176c8e2776557ce6c17c642c24a73",
2424
check_all: None,
2525
check_one: Some(&say_hello),
2626
applies_to: "TTF",
@@ -31,8 +31,8 @@ pub const SAY_HELLO: Check = Check {
3131
pub const VALIDATE_TOML: Check = Check {
3232
id: "com.google.fonts/check/test/validate_toml",
3333
title: "Check that the filetype plugin protocol is working",
34-
rationale: None,
35-
proposal: None,
34+
rationale: "This check is part of the example of how to create plugins.",
35+
proposal: "https://github.com/simoncozens/fontspector/commit/5fdf9750991176c8e2776557ce6c17c642c24a73",
3636
check_all: None,
3737
check_one: Some(&validate_toml),
3838
applies_to: "TOML",

profile-universal/src/checks/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod bold_italic_unique;
22
mod name_trailing_spaces;
33
mod required_tables;
44
mod unwanted_tables;
5-
// pub use bold_italic_unique::BOLD_ITALIC_UNIQUE_CHECK;
6-
pub use name_trailing_spaces::NAME_TRAILING_SPACES_CHECK;
7-
pub use required_tables::REQUIRED_TABLES_CHECK;
8-
pub use unwanted_tables::UNWANTED_TABLES_CHECK;
5+
// pub use bold_italic_unique::CHECK_BOLD_ITALIC_UNIQUE;
6+
pub use name_trailing_spaces::CHECK_NAME_TRAILING_SPACES;
7+
pub use required_tables::CHECK_REQUIRED_TABLES;
8+
pub use unwanted_tables::CHECK_UNWANTED_TABLES;

profile-universal/src/checks/name_trailing_spaces.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ fn fix_trailing_spaces(_f: &Testable) -> FixFnResult {
3030
Ok(false)
3131
}
3232

33-
pub const NAME_TRAILING_SPACES_CHECK: Check = Check {
33+
pub const CHECK_NAME_TRAILING_SPACES: Check = Check {
3434
id: "com.google.fonts/check/name/trailing_spaces",
3535
title: "Name table records must not have trailing spaces.",
36-
rationale: None,
37-
proposal: Some("https://github.com/googlefonts/fontbakery/issues/2417"),
36+
rationale: "This check ensures that no entries in the name table end in spaces;
37+
trailing spaces, particularly in font names, can be confusing to users.
38+
In most cases this can be fixed by removing trailing spaces from the
39+
metadata fields in the font editor.",
40+
proposal: "https://github.com/googlefonts/fontbakery/issues/2417",
3841
check_one: Some(&name_trailing_spaces),
3942
check_all: None,
4043
applies_to: "TTF",

profile-universal/src/checks/required_tables.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,10 @@ fn required_tables(t: &Testable) -> CheckFnResult {
8282
return_result(problems)
8383
}
8484

85-
pub const REQUIRED_TABLES_CHECK: Check = Check {
85+
pub const CHECK_REQUIRED_TABLES: Check = Check {
8686
id: "com.google.fonts/check/required_tables",
8787
title: "Font contains all required tables?",
88-
rationale: Some(
89-
"
88+
rationale: "
9089
According to the OpenType spec
9190
https://docs.microsoft.com/en-us/typography/opentype/spec/otff#required-tables
9291
@@ -116,8 +115,7 @@ pub const REQUIRED_TABLES_CHECK: Check = Check {
116115
- A gasp table is necessary if a designer wants to influence the sizes
117116
at which grayscaling is used under Windows. Etc.
118117
",
119-
),
120-
proposal: Some("legacy:check/052"),
118+
proposal: "legacy:check/052",
121119
check_one: Some(&required_tables),
122120
check_all: None,
123121
applies_to: "TTF",

profile-universal/src/checks/unwanted_tables.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ fn delete_unwanted_tables(t: &Testable) -> FixFnResult {
4949
Ok(true)
5050
}
5151

52-
pub const UNWANTED_TABLES_CHECK: Check = Check {
52+
pub const CHECK_UNWANTED_TABLES: Check = Check {
5353
id: "com.google.fonts/check/unwanted_tables",
5454
title: "Are there unwanted tables?",
55-
rationale: Some("Some font editors store source data in their own SFNT tables, and these can sometimes sneak into final release files, which should only have OpenType spec tables."),
56-
proposal: Some("legacy:check/053"),
55+
rationale: "Some font editors store source data in their own SFNT tables, and these can sometimes sneak into final release files, which should only have OpenType spec tables.",
56+
proposal: "legacy:check/053",
5757
check_one: Some(&unwanted_tables),
5858
check_all: None,
5959
applies_to: "TTF",

profile-universal/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub struct Universal;
66

77
impl fontspector_checkapi::Plugin for Universal {
88
fn register(&self, cr: &mut Registry) -> Result<(), String> {
9-
cr.register_check(checks::NAME_TRAILING_SPACES_CHECK);
10-
cr.register_check(checks::UNWANTED_TABLES_CHECK);
11-
cr.register_check(checks::REQUIRED_TABLES_CHECK);
9+
cr.register_check(checks::CHECK_NAME_TRAILING_SPACES);
10+
cr.register_check(checks::CHECK_UNWANTED_TABLES);
11+
cr.register_check(checks::CHECK_REQUIRED_TABLES);
1212
let profile = Profile::from_toml(
1313
r#"
1414
[sections]

0 commit comments

Comments
 (0)