Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split fontique into its own package. #37

Merged
merged 2 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ env:
# If the compilation fails, then the version specified here needs to be bumped up to reality.
# Be sure to also update the rust-version property in the workspace Cargo.toml file,
# plus all the README.md files of the affected packages.
RUST_MIN_VER: "1.74"
RUST_MIN_VER: "1.70"
# List of packages that will be checked with the minimum supported Rust version.
# This should be limited to packages that are intended for publishing.
RUST_MIN_VER_PKGS: "-p parley"
RUST_MIN_VER_PKGS: "-p parley -p fontique"
# List of features that depend on the standard library and will be excluded from no_std checks.
FEATURES_DEPENDING_ON_STD: "std,default,system"


# Rationale
Expand Down Expand Up @@ -41,6 +43,10 @@ env:
#
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
#
# For no_std checks we target x86_64-unknown-none, because this target doesn't support std
# and as such will error out if our dependency tree accidentally tries to use std.
# https://doc.rust-lang.org/stable/rustc/platform-support/x86_64-unknown-none.html

name: CI

Expand Down Expand Up @@ -88,18 +94,23 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE_VER }}
targets: x86_64-unknown-none
components: clippy

- name: install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack

# TODO: Add --target x86_64-unknown-none to the no_std check once we solve the compilation issues with it
- name: cargo clippy (no_std)
run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features libm --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} -- -D warnings

- name: cargo clippy
run: cargo hack clippy --workspace --locked --each-feature --optional-deps -- -D warnings
run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features std -- -D warnings

- name: cargo clippy (auxiliary)
run: cargo hack clippy --workspace --locked --each-feature --optional-deps --tests --benches --examples -- -D warnings
run: cargo hack clippy --workspace --locked --optional-deps --each-feature --features std --tests --benches --examples -- -D warnings

clippy-stable-android:
name: cargo clippy (android)
Expand All @@ -126,10 +137,10 @@ jobs:
tool: cargo-hack

- name: cargo clippy
run: cargo hack clippy --workspace --locked --target ${{ matrix.target }} --each-feature --optional-deps -- -D warnings
run: cargo hack clippy --workspace --locked --target ${{ matrix.target }} --optional-deps --each-feature --features std -- -D warnings

- name: cargo clippy (auxiliary)
run: cargo hack clippy --workspace --locked --target ${{ matrix.target }} --each-feature --optional-deps --tests --benches --examples -- -D warnings
run: cargo hack clippy --workspace --locked --target ${{ matrix.target }} --optional-deps --each-feature --features std --tests --benches --examples -- -D warnings

test-stable:
name: cargo test
Expand Down Expand Up @@ -173,8 +184,12 @@ jobs:
with:
tool: cargo-hack

# TODO: Add --target x86_64-unknown-none to the no_std check once we solve the compilation issues with it
- name: cargo check (no_std)
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature --features libm --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }}

- name: cargo check
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --each-feature --optional-deps
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature --features std

check-msrv-android:
name: cargo check (msrv) (android)
Expand All @@ -200,7 +215,7 @@ jobs:
tool: cargo-hack

- name: cargo check
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target ${{ matrix.target }} --each-feature --optional-deps
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target ${{ matrix.target }} --optional-deps --each-feature --features std

doc:
name: cargo doc
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# source control.
Google LLC
Chad Brokaw
Kaur Kuut
46 changes: 28 additions & 18 deletions Cargo.lock

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

74 changes: 41 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
[package]
name = "parley"
version = "0.0.1"
authors = ["Chad Brokaw <[email protected]>"]
license = "Apache-2.0 OR MIT"
[workspace]
resolver = "2"
members = [
"fontique"
]

[workspace.package]
edition = "2021"
# Keep in sync with RUST_MIN_VER in .github/workflows/ci.yml and with the relevant README.md files.
rust-version = "1.74"
rust-version = "1.70"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/linebender/parley"

[package]
name = "parley"
version = "0.1.0"
description = "Parley provides an API for implementing rich text layout."
keywords = ["text", "layout"]
categories = ["gui", "graphics"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
exclude = ["/.github/", "/doc/", ".gitignore"]

[workspace.lints]
clippy.doc_markdown = "warn"
clippy.semicolon_if_nothing_returned = "warn"
clippy.trivially_copy_pass_by_ref = "warn"

[lints]
workspace = true

[features]
default = ["system"]
# Enabled support for system font backends
system = ["std"]
std = ["dep:memmap2"]
std = ["fontique/std", "skrifa/std", "peniko/std"]
libm = ["fontique/libm", "skrifa/libm", "peniko/libm"]
# Enables support for system font backends
system = ["std", "fontique/system"]

[dependencies]
swash = "0.1.15"
skrifa = { version = "0.19.0", default-features = false, features = ["libm"] }
smallvec = "1.13.2"
memmap2 = { version = "0.5.10", optional = true }
unicode-script = { version = "0.5.6", optional = true }
peniko = { version = "0.1.0", default-features = false, features = ["libm"] }
icu_properties = "1.4.0"
icu_locid = "1.4.0"
hashbrown = "0.14.3"

[target.'cfg(target_family="windows")'.dependencies]
dwrote = "0.11.0"
winapi = { version = "0.3.9", features = ["dwrite", "dwrite_1", "dwrite_3", "winnt", "unknwnbase", "libloaderapi", "winnls"] }
wio = "0.2.2"

[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
core-text = "20.1.0"
core-foundation = "0.9.4"
core-foundation-sys = "0.8.6"
skrifa = { workspace = true }
peniko = { workspace = true }
fontique = { workspace = true }

[target.'cfg(not(any(target_os="macos", target_os="ios", target_family="windows")))'.dependencies]
anyhow = "1.0.82"
bytemuck = { version = "1.15.0", features = ["derive"] }
fontconfig-cache-parser = "0.2"
thiserror = "1.0.58"
roxmltree = "0.18.1"
[workspace.dependencies]
fontique = { version = "0.1.0", default-features = false, path = "fontique" }
skrifa = { version = "0.19.0", default-features = false }
peniko = { version = "0.1.0", default-features = false }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It is backed by [Swash](https://github.com/dfrg/swash).

## Minimum supported Rust Version (MSRV)

This version of Parley has been verified to compile with **Rust 1.74** and later.
This version of Parley has been verified to compile with **Rust 1.70** and later.

Future versions of Parley might increase the Rust version requirement.
It will not be treated as a breaking change and as such can even happen with small patch releases.
Expand Down
48 changes: 48 additions & 0 deletions fontique/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
name = "fontique"
version = "0.1.0" # Keep in sync with workspace dependency specification
description = "Font enumeration and fallback."
keywords = ["font", "text"]
categories = ["gui", "os"]
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true

[lints]
workspace = true

[features]
default = ["system"]
std = ["skrifa/std", "peniko/std", "dep:memmap2"]
libm = ["skrifa/libm", "peniko/libm", "dep:core_maths"]
# Enables support for system font backends
system = ["std"]

[dependencies]
skrifa = { workspace = true }
peniko = { workspace = true }
smallvec = "1.13.2"
memmap2 = { version = "0.5.10", optional = true }
unicode-script = { version = "0.5.6", optional = true }
core_maths = { version = "0.1.0", optional = true }
icu_properties = "1.4.0"
icu_locid = "1.4.0"
hashbrown = "0.14.3"

[target.'cfg(target_family="windows")'.dependencies]
dwrote = "0.11.0"
winapi = { version = "0.3.9", features = ["dwrite", "dwrite_1", "dwrite_3", "winnt", "unknwnbase", "libloaderapi", "winnls"] }
wio = "0.2.2"

[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
core-text = "20.1.0"
core-foundation = "0.9.4"
core-foundation-sys = "0.8.6"

[target.'cfg(not(any(target_os="macos", target_os="ios", target_family="windows")))'.dependencies]
anyhow = "1.0.82"
bytemuck = { version = "1.15.0", features = ["derive"] }
fontconfig-cache-parser = "0.2.0"
thiserror = "1.0.58"
roxmltree = "0.18.1"
54 changes: 54 additions & 0 deletions fontique/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div align="center">

# Fontique

**Font enumeration and fallback**

[![Latest published fontique version.](https://img.shields.io/crates/v/fontique.svg)](https://crates.io/crates/fontique)
[![Documentation build status.](https://img.shields.io/docsrs/fontique.svg)](https://docs.rs/fontique)
[![Dependency staleness status.](https://deps.rs/repo/github/linebender/fontique/status.svg)](https://deps.rs/repo/github/linebender/fontique)
[![Linebender Zulip chat.](https://img.shields.io/badge/Linebender-%23text-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/205635-text)
[![Apache 2.0 or MIT license.](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](#license)

</div>

Fontique provides font enumeration and fallback.

## Minimum supported Rust Version (MSRV)

This version of Fontique has been verified to compile with **Rust 1.70** and later.

Future versions of Fontique might increase the Rust version requirement.
It will not be treated as a breaking change and as such can even happen with small patch releases.

<details>
<summary>Click here if compiling fails.</summary>

As time has passed, some of Fontique's dependencies could have released versions with a higher Rust requirement.
If you encounter a compilation issue due to a dependency and don't want to upgrade your Rust toolchain, then you could downgrade the dependency.

```sh
# Use the problematic dependency's name and version
cargo update -p package_name --precise 0.1.1
```
</details>

## Community

Discussion of Fontique development happens in the [Linebender Zulip](https://xi.zulipchat.com/), specifically the [#text stream](https://xi.zulipchat.com/#narrow/stream/205635-text).
All public content can be read without logging in.

Contributions are welcome by pull request. The [Rust code of conduct] applies.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache 2.0 license, shall be licensed as noted in the [License](#license) section, without any additional terms or conditions.

## License

Licensed under either of

- Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](../LICENSE-MIT) or <http://opensource.org/licenses/MIT>)

at your option.

[Rust code of conduct]: https://www.rust-lang.org/policies/code-of-conduct
3 changes: 3 additions & 0 deletions src/fontique/attributes.rs → fontique/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

//! Properties for specifying font weight, stretch and style.

#[cfg(not(feature = "std"))]
use core_maths::*;

use core::fmt;

/// Primary attributes for font matching: stretch, style and weight.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ fn all_family_names(family: &dwrote::FontFamily) -> Option<Vec<String>> {
continue;
}
buf.pop();
names.push(String::from_utf16_lossy(&buf))
names.push(String::from_utf16_lossy(&buf));
}
}
Some(names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl SystemFonts {
}
}

/// FontConfig seems to force RBIZ (regular, bold, italic, bold italic) when
/// Fontconfig seems to force RBIZ (regular, bold, italic, bold italic) when
/// categorizing fonts. This removes those suffixes from family names so that
/// we can match on all attributes.
fn strip_rbiz(name: &str) -> &str {
Expand Down
File renamed without changes.
Loading