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

-1
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

+2
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

+99
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

+1
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

+9-5
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" }
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>
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2014 The Nunito Project Authors ([email protected])
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
http://scripts.sil.org/OFL
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.

0 commit comments

Comments
 (0)