Skip to content

Commit 8cfb898

Browse files
authored
Merge pull request #10 from felipesanches/more_checks_2024_sep_20
More checks (2024/09/20)
2 parents 05b309e + 77f0008 commit 8cfb898

File tree

69 files changed

+1203
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1203
-7
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ foo*
33
python
44
docs
55
Cargo.lock
6-
*.ttf
76
flamegraph.svg

fontspector-checkapi/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ crate-type = ["cdylib", "rlib"]
1111
pluginator = {workspace = true}
1212

1313
[dependencies]
14+
font-types = { workspace = true }
1415
read-fonts = {workspace = true}
16+
write-fonts = { workspace = true }
1517
skrifa = {workspace = true}
1618
fontspector-checkhelper = {workspace = true}
1719

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
use crate::{
2+
prelude::*,
3+
Check,
4+
CheckResult,
5+
Context,
6+
FileTypeConvert,
7+
StatusCode,
8+
};
9+
use font_types::NameId;
10+
use read_fonts::TableProvider;
11+
use serde_json::Map;
12+
use write_fonts::{
13+
FontBuilder,
14+
tables::name::{Name, NameRecord}
15+
};
16+
17+
#[macro_export] macro_rules! TEST_FILE {
18+
($fname:expr) => {
19+
Testable::new(concat!(
20+
env!("CARGO_MANIFEST_DIR"),
21+
"/resources/test/",
22+
$fname
23+
))
24+
.unwrap()
25+
};
26+
}
27+
28+
pub fn run_check(
29+
check: Check<'_>,
30+
font: Testable,
31+
) -> std::option::Option<CheckResult> {
32+
let ctx: Context = Context {
33+
skip_network: false,
34+
network_timeout: Some(10),
35+
configuration: Map::new(),
36+
check_metadata: check.metadata(),
37+
};
38+
check.run(&TestableType::Single(&font), &ctx, None)
39+
}
40+
41+
pub fn assert_pass(check_result: std::option::Option<CheckResult>) {
42+
let status = check_result.unwrap().worst_status();
43+
assert_eq!(status, StatusCode::Pass);
44+
}
45+
46+
pub fn assert_results_contain(
47+
check_result: std::option::Option<CheckResult>,
48+
severity: StatusCode,
49+
code: Option<String>,
50+
) {
51+
let subresults = check_result.unwrap().subresults;
52+
assert!(subresults
53+
.iter()
54+
.any(|subresult| subresult.severity == severity && subresult.code == code));
55+
}
56+
57+
pub fn set_name_entry(font: &mut Testable, platform: u16, encoding: u16, language: u16, nameid: NameId, new_string: String){
58+
use std::collections::BTreeSet;
59+
60+
let f = TTF.from_testable(&font).unwrap();
61+
let name = f.font().name().unwrap();
62+
63+
let new_record = NameRecord::new(
64+
platform,
65+
encoding,
66+
language,
67+
nameid,
68+
new_string.to_string().into(),
69+
);
70+
let mut new_records: BTreeSet<NameRecord> = name
71+
.name_record()
72+
.iter()
73+
.filter(|record| record.name_id() != nameid)
74+
.map(|r| {
75+
#[allow(clippy::unwrap_used)]
76+
NameRecord::new(
77+
r.platform_id(),
78+
r.encoding_id(),
79+
r.language_id(),
80+
r.name_id(),
81+
r.string(name.string_data())
82+
.unwrap()
83+
.chars()
84+
.collect::<String>()
85+
.to_string()
86+
.into(),
87+
)
88+
})
89+
.collect();
90+
new_records.insert(new_record);
91+
let new_nametable = Name::new(new_records);
92+
let new_bytes = FontBuilder::new()
93+
.add_table(&new_nametable)
94+
.unwrap()
95+
.copy_missing_tables(f.font())
96+
.build();
97+
98+
font.contents = new_bytes;
99+
}

fontspector-checkapi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![deny(clippy::unwrap_used, clippy::expect_used)]
22
mod check;
33
mod checkresult;
4+
pub mod codetesting;
45
pub mod constants;
56
mod context;
67
mod filetype;

profile-googlefonts/Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
chrono = "0.4.38" # For metadata date checks
78
fontspector-checkapi = { path = "../fontspector-checkapi" }
8-
protobuf ={ git = "https://github.com/cmyr/rust-protobuf", branch="parse-unicode-strings" }
9+
font-types = { workspace = true }
10+
google-fonts-languages = { git = "https://github.com/googlefonts/lang", branch = "rust" }
911
itertools = "0.13.0"
10-
11-
chrono="0.4.38" # For metadata date checks
12-
google-fonts-languages = { git="https://github.com/googlefonts/lang", branch = "rust" }
12+
protobuf = { git = "https://github.com/cmyr/rust-protobuf", branch = "parse-unicode-strings" }
13+
read-fonts = { workspace = true }
14+
write-fonts = { workspace = true }
15+
regex = "1.10.6"
16+
skrifa = { workspace = true }
1317

1418
[build-dependencies]
15-
protobuf-codegen ={ git = "https://github.com/cmyr/rust-protobuf", branch="parse-unicode-strings" }
19+
protobuf-codegen = { git = "https://github.com/cmyr/rust-protobuf", branch = "parse-unicode-strings" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Nunito is a well balanced Sans Serif with rounded terminals. Nunito has been designed mainly to be used as a display font but is useable as a text font too. Nunito has been designed to be used freely across the internet by web browsers on desktop computers, laptops and mobile devices.</p>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: "Nunito"
2+
designer: "Vernon Adams"
3+
license: "OFL"
4+
category: "SANS_SERIF"
5+
date_added: "2012-08-12"
6+
fonts {
7+
name: "Nunito"
8+
style: "normal"
9+
weight: 200
10+
filename: "Nunito-ExtraLight.ttf"
11+
post_script_name: "Nunito-ExtraLight"
12+
full_name: "Nunito ExtraLight"
13+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
14+
}
15+
fonts {
16+
name: "Nunito"
17+
style: "italic"
18+
weight: 200
19+
filename: "Nunito-ExtraLightItalic.ttf"
20+
post_script_name: "Nunito-ExtraLightItalic"
21+
full_name: "Nunito ExtraLight Italic"
22+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
23+
}
24+
fonts {
25+
name: "Nunito"
26+
style: "normal"
27+
weight: 300
28+
filename: "Nunito-Light.ttf"
29+
post_script_name: "Nunito-Light"
30+
full_name: "Nunito Light"
31+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
32+
}
33+
fonts {
34+
name: "Nunito"
35+
style: "italic"
36+
weight: 300
37+
filename: "Nunito-LightItalic.ttf"
38+
post_script_name: "Nunito-LightItalic"
39+
full_name: "Nunito Light Italic"
40+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
41+
}
42+
fonts {
43+
name: "Nunito"
44+
style: "normal"
45+
weight: 400
46+
filename: "Nunito-Regular.ttf"
47+
post_script_name: "Nunito-Regular"
48+
full_name: "Nunito Regular"
49+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
50+
}
51+
fonts {
52+
name: "Nunito"
53+
style: "italic"
54+
weight: 400
55+
filename: "Nunito-Italic.ttf"
56+
post_script_name: "Nunito-Italic"
57+
full_name: "Nunito Italic"
58+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
59+
}
60+
fonts {
61+
name: "Nunito"
62+
style: "normal"
63+
weight: 600
64+
filename: "Nunito-SemiBold.ttf"
65+
post_script_name: "Nunito-SemiBold"
66+
full_name: "Nunito SemiBold"
67+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
68+
}
69+
fonts {
70+
name: "Nunito"
71+
style: "italic"
72+
weight: 600
73+
filename: "Nunito-SemiBoldItalic.ttf"
74+
post_script_name: "Nunito-SemiBoldItalic"
75+
full_name: "Nunito SemiBold Italic"
76+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
77+
}
78+
fonts {
79+
name: "Nunito"
80+
style: "normal"
81+
weight: 700
82+
filename: "Nunito-Bold.ttf"
83+
post_script_name: "Nunito-Bold"
84+
full_name: "Nunito Bold"
85+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
86+
}
87+
fonts {
88+
name: "Nunito"
89+
style: "italic"
90+
weight: 700
91+
filename: "Nunito-BoldItalic.ttf"
92+
post_script_name: "Nunito-BoldItalic"
93+
full_name: "Nunito Bold Italic"
94+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
95+
}
96+
fonts {
97+
name: "Nunito"
98+
style: "normal"
99+
weight: 800
100+
filename: "Nunito-ExtraBold.ttf"
101+
post_script_name: "Nunito-ExtraBold"
102+
full_name: "Nunito ExtraBold"
103+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
104+
}
105+
fonts {
106+
name: "Nunito"
107+
style: "italic"
108+
weight: 800
109+
filename: "Nunito-ExtraBoldItalic.ttf"
110+
post_script_name: "Nunito-ExtraBoldItalic"
111+
full_name: "Nunito ExtraBold Italic"
112+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
113+
}
114+
fonts {
115+
name: "Nunito"
116+
style: "normal"
117+
weight: 900
118+
filename: "Nunito-Black.ttf"
119+
post_script_name: "Nunito-Black"
120+
full_name: "Nunito Black"
121+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
122+
}
123+
fonts {
124+
name: "Nunito"
125+
style: "italic"
126+
weight: 900
127+
filename: "Nunito-BlackItalic.ttf"
128+
post_script_name: "Nunito-BlackItalic"
129+
full_name: "Nunito Black Italic"
130+
copyright: "Copyright 2014 The Nunito Project Authors ([email protected])"
131+
}
132+
subsets: "latin"
133+
subsets: "latin-ext"
134+
subsets: "menu"
135+
subsets: "vietnamese"
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)