Skip to content

Commit

Permalink
Merge branch 'main' into cursor2
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrg committed Nov 27, 2024
2 parents d80969a + 17ac2ae commit 84b17e5
Show file tree
Hide file tree
Showing 23 changed files with 783 additions and 12 deletions.
10 changes: 8 additions & 2 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# The default Clippy value for this is 8 bytes, which is chosen to improve performance on 32-bit.
# Given that we're building for the future and even mobile phones have 64-bit CPUs,
# LINEBENDER LINT SET - .clippy.toml - v1
# See https://linebender.org/wiki/canonical-lints/

# The default Clippy value is capped at 8 bytes, which was chosen to improve performance on 32-bit.
# Given that we are building for the future and even low-end mobile phones have 64-bit CPUs,
# it makes sense to optimize for 64-bit and accept the performance hits on 32-bit.
# 16 bytes is the number of bytes that fits into two 64-bit CPU registers.
trivial-copy-size-limit = 16

# END LINEBENDER LINT SET

# Don't warn about these identifiers when using clippy::doc_markdown.
doc-valid-idents = ["OpenType", ".."]
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ license = "Apache-2.0 OR MIT"
repository = "https://github.com/linebender/parley"

[workspace.lints]
# LINEBENDER LINT SET - v1
# LINEBENDER LINT SET - Cargo.toml - v2
# See https://linebender.org/wiki/canonical-lints/
rust.keyword_idents_2024 = "forbid"
rust.non_ascii_idents = "forbid"
Expand Down Expand Up @@ -65,6 +65,7 @@ clippy.semicolon_if_nothing_returned = "warn"
clippy.shadow_unrelated = "warn"
clippy.should_panic_without_expect = "warn"
clippy.todo = "warn"
clippy.trivially_copy_pass_by_ref = "warn"
clippy.unseparated_literal_suffix = "warn"
clippy.use_self = "warn"
clippy.wildcard_imports = "warn"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@ Licensed under either of

at your option.

Some files used for tests are under different licenses:

- The font file `Roboto-Regular.ttf` in `/parley/tests/assets/roboto_fonts/` is licensed solely as documented in that folder (and is licensed under the Apache License, Version 2.0).


[Rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct
25 changes: 16 additions & 9 deletions fontique/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ libm = ["read-fonts/libm", "peniko/libm", "dep:core_maths"]
icu_properties = ["dep:icu_properties"]
unicode_script = ["dep:unicode-script"]
# Enables support for system font backends
system = ["std"]
system = [
"std",
"dep:windows", "dep:windows-core",
"dep:core-text", "dep:core-foundation", "dep:objc2", "dep:objc2-foundation",
"dep:fontconfig-cache-parser", "dep:roxmltree",
]

[dependencies]
read-fonts = { workspace = true }
Expand All @@ -36,15 +41,17 @@ icu_locid = "1.5.0"
hashbrown = { workspace = true }

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.58.0", features = ["implement", "Win32_Graphics_DirectWrite"] }
windows-core = { version = "0.58" }
windows = { version = "0.58.0", features = ["implement", "Win32_Graphics_DirectWrite"], optional = true }
windows-core = { version = "0.58", optional = true }

[target.'cfg(target_vendor = "apple")'.dependencies]
core-text = "20.1.0"
core-foundation = "0.9.4"
objc2 = { version = "0.5.2" }
objc2-foundation = { version = "0.2.2", features = ["NSArray", "NSEnumerator", "NSPathUtilities", "NSString"] }
core-text = { version = "20.1.0", optional = true }
core-foundation = { version = "0.9.4", optional = true }
objc2 = { version = "0.5.2", optional = true }
objc2-foundation = { version = "0.2.2", features = ["NSArray", "NSEnumerator", "NSPathUtilities", "NSString"], optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
fontconfig-cache-parser = { version = "0.2.0", optional = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
fontconfig-cache-parser = "0.2.0"
roxmltree = "0.19.0"
roxmltree = { version = "0.19.0", optional = true }
7 changes: 7 additions & 0 deletions fontique/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

//! Font enumeration and fallback.
// LINEBENDER LINT SET - lib.rs - v1
// See https://linebender.org/wiki/canonical-lints/
// These lints aren't included in Cargo.toml because they
// shouldn't apply to examples and tests
#![warn(unused_crate_dependencies)]
#![warn(clippy::print_stdout, clippy::print_stderr)]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(elided_lifetimes_in_paths)]
Expand Down
4 changes: 4 additions & 0 deletions parley/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
exclude = ["/tests"]

[package.metadata.docs.rs]
all-features = true
Expand All @@ -31,3 +32,6 @@ fontique = { workspace = true }
core_maths = { version = "0.1.0", optional = true }
accesskit = { workspace = true, optional = true }
hashbrown = { workspace = true, optional = true }

[dev-dependencies]
tiny-skia = "0.11.4"
4 changes: 4 additions & 0 deletions parley/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ Licensed under either of

at your option.

Some files used for tests are under different licenses:

- The font file `Roboto-Regular.ttf` in `/parley/tests/assets/roboto_fonts/` is licensed solely as documented in that folder (and is licensed under the Apache License, Version 2.0).

[Rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct
10 changes: 10 additions & 0 deletions parley/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@
//! }
//! ```
// LINEBENDER LINT SET - lib.rs - v1
// See https://linebender.org/wiki/canonical-lints/
// These lints aren't included in Cargo.toml because they
// shouldn't apply to examples and tests
#![warn(unused_crate_dependencies)]
#![warn(clippy::print_stdout, clippy::print_stderr)]
// END LINEBENDER LINT SET
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(elided_lifetimes_in_paths)]
Expand Down Expand Up @@ -111,6 +118,9 @@ mod util;
pub mod layout;
pub mod style;

#[cfg(test)]
mod tests;

pub use peniko::kurbo::Rect;
pub use peniko::Font;

Expand Down
5 changes: 5 additions & 0 deletions parley/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2024 the Parley Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

mod test_basic;
mod utils;
42 changes: 42 additions & 0 deletions parley/src/tests/test_basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 the Parley Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use crate::{testenv, Alignment, InlineBox};

#[test]
fn plain_multiline_text() {
let mut env = testenv!();

let text = "Hello world!\nLine 2\nLine 4";
let mut builder = env.builder(text);
let mut layout = builder.build(text);
layout.break_all_lines(None);
layout.align(None, Alignment::Start);

env.check_snapshot(&layout);
}

#[test]
fn placing_inboxes() {
let mut env = testenv!();

for (position, test_case_name) in [
(0, "start"),
(3, "in_word"),
(12, "end_nl"),
(13, "start_nl"),
] {
let text = "Hello world!\nLine 2\nLine 4";
let mut builder = env.builder(text);
builder.push_inline_box(InlineBox {
id: 0,
index: position,
width: 10.0,
height: 10.0,
});
let mut layout = builder.build(text);
layout.break_all_lines(None);
layout.align(None, Alignment::Start);
env.check_snapshot_with_name(test_case_name, &layout);
}
}
Loading

0 comments on commit 84b17e5

Please sign in to comment.