Skip to content

Commit e6d9e8f

Browse files
committed
Move harfbuzz-traits implementations into component crates
1 parent 25acf58 commit e6d9e8f

File tree

23 files changed

+477
-736
lines changed

23 files changed

+477
-736
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Utils
6+
- Retire the `icu_harfbuzz` crate. The `icu_properties` and `icu_normalizer` types now directly implement the `harfbuzz-traits`
7+
38
## icu4x 2.1
49

510
- Components

CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ components/segmenter/ @aethanyc @makotokato @sffc
2727
components/time/ @nekevss @robertbastian @sffc
2828
ffi/capi/ @Manishearth
2929
ffi/ecma402/ @filmil
30-
ffi/harfbuzz/ @hsivonen
3130
provider/blob/ @sffc @Manishearth
3231
provider/core/ @sffc @Manishearth
3332
provider/source/ @sffc @robertbastian @Manishearth

Cargo.lock

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ members = [
3434
"ffi/capi",
3535
"ffi/ecma402",
3636
"ffi/freertos",
37-
"ffi/harfbuzz",
3837

3938
# Provider
4039
"provider/adapters",
@@ -158,7 +157,6 @@ icu_time = { version = "~2.1.1", path = "components/time", default-features = fa
158157
icu_capi = { version = "~2.1.1", path = "ffi/capi", default-features = false }
159158
# icu4x_ecma402 never used as a dep
160159
# icu_freertos never used as a dep
161-
# icu_harfbuzz never used as a dep
162160

163161
# Provider
164162
icu_provider_export = { version = "~2.1.1", path = "provider/export", default-features = false }
@@ -245,6 +243,7 @@ arrayvec = { version = "0.7.2", default-features = false }
245243
core_maths = { version = "0.1.0", default-features = false }
246244
displaydoc = { version = "0.2.3", default-features = false }
247245
either = { version = "1.9.0", default-features = false }
246+
harfbuzz-traits = { version = "0.6.0", default-features = false }
248247
libc_alloc = { version = "1.0.6", default-features = false }
249248
log = { version = "0.4.17", default-features = false }
250249
memchr = { version = "2.6.0", default-features = false }

components/normalizer/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ license.workspace = true
2020
all-features = true
2121

2222
[dependencies]
23+
harfbuzz-traits = { workspace = true, optional = true }
2324
icu_collections = { workspace = true }
2425
icu_properties = { workspace = true, optional = true }
2526
icu_provider = { workspace = true }
@@ -58,6 +59,7 @@ icu_properties = ["dep:icu_properties"]
5859
utf16_iter = ["dep:utf16_iter", "dep:write16"]
5960
# For dealing with potentially ill-formed UTF8 strings
6061
utf8_iter = ["dep:utf8_iter"]
62+
harfbuzz_traits = ["dep:harfbuzz-traits"]
6163

6264
# added by accident
6365
write16 = []

components/normalizer/README.md

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// This file is part of ICU4X. For terms of use, please see the file
2+
// called LICENSE at the top level of the ICU4X source tree
3+
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4+
5+
use crate::properties::{
6+
CanonicalCombiningClassMap, CanonicalCombiningClassMapBorrowed, CanonicalComposition,
7+
CanonicalCompositionBorrowed, CanonicalDecomposition, CanonicalDecompositionBorrowed,
8+
Decomposed,
9+
};
10+
use harfbuzz_traits::{CombiningClassFunc, ComposeFunc, DecomposeFunc};
11+
12+
impl ComposeFunc for CanonicalCompositionBorrowed<'_> {
13+
fn compose(&self, a: char, b: char) -> Option<char> {
14+
CanonicalCompositionBorrowed::compose(*self, a, b)
15+
}
16+
}
17+
18+
impl ComposeFunc for CanonicalComposition {
19+
fn compose(&self, a: char, b: char) -> Option<char> {
20+
ComposeFunc::compose(&self.as_borrowed(), a, b)
21+
}
22+
}
23+
24+
impl ComposeFunc for &'_ CanonicalComposition {
25+
fn compose(&self, a: char, b: char) -> Option<char> {
26+
ComposeFunc::compose(&self.as_borrowed(), a, b)
27+
}
28+
}
29+
30+
impl DecomposeFunc for CanonicalDecompositionBorrowed<'_> {
31+
fn decompose(&self, ab: char) -> Option<(char, char)> {
32+
match CanonicalDecompositionBorrowed::decompose(self, ab) {
33+
Decomposed::Default => None,
34+
Decomposed::Expansion(first, second) => Some((first, second)),
35+
Decomposed::Singleton(single) => Some((single, '\0')),
36+
}
37+
}
38+
}
39+
40+
impl DecomposeFunc for CanonicalDecomposition {
41+
fn decompose(&self, ab: char) -> Option<(char, char)> {
42+
DecomposeFunc::decompose(&self.as_borrowed(), ab)
43+
}
44+
}
45+
46+
impl DecomposeFunc for &'_ CanonicalDecomposition {
47+
fn decompose(&self, ab: char) -> Option<(char, char)> {
48+
DecomposeFunc::decompose(&self.as_borrowed(), ab)
49+
}
50+
}
51+
52+
impl CombiningClassFunc for CanonicalCombiningClassMapBorrowed<'_> {
53+
fn combining_class(&self, ch: char) -> u8 {
54+
self.get_u8(ch)
55+
}
56+
}
57+
58+
impl CombiningClassFunc for CanonicalCombiningClassMap {
59+
fn combining_class(&self, ch: char) -> u8 {
60+
CombiningClassFunc::combining_class(&self.as_borrowed(), ch)
61+
}
62+
}
63+
64+
impl CombiningClassFunc for &'_ CanonicalCombiningClassMap {
65+
fn combining_class(&self, ch: char) -> u8 {
66+
CombiningClassFunc::combining_class(&self.as_borrowed(), ch)
67+
}
68+
}

components/normalizer/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
//!
4040
//! The `properties` module provides the non-recursive canonical decomposition operation on a per `char` basis and
4141
//! the canonical compositon operation given two `char`s. It also provides access to the Canonical Combining Class
42-
//! property. These operations are primarily meant for [HarfBuzz](https://harfbuzz.github.io/) via the
43-
//! [`icu_harfbuzz`](https://docs.rs/icu_harfbuzz/latest/icu_harfbuzz/) crate.
42+
//! property. These operations are primarily meant for [HarfBuzz](https://harfbuzz.github.io/), the types
43+
//! [`CanonicalComposition`](properties::CanonicalComposition), [`CanonicalDecomposition`](properties::CanonicalDecomposition),
44+
//! and [`CanonicalCombiningClassMap`](properties::CanonicalCombiningClassMap) implement the [`harfbuzz_traits`] if
45+
//! the `harfbuzz_traits` Cargo feature is enabled.
4446
//!
4547
//! Notably, this normalizer does _not_ provide the normalization “quick check” that can result in “maybe” in
4648
//! addition to “yes” and “no”. The normalization checks provided by this crate always give a definitive
@@ -99,6 +101,8 @@ macro_rules! ccc {
99101
};
100102
}
101103

104+
#[cfg(feature = "harfbuzz_traits")]
105+
mod harfbuzz;
102106
pub mod properties;
103107
pub mod provider;
104108
pub mod uts46;

components/properties/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ databake = { workspace = true, features = ["derive"], optional = true}
2828
serde = { workspace = true, features = ["derive"], optional = true }
2929
icu_locale_core = { workspace = true, features = ["zerovec"] }
3030

31+
harfbuzz-traits = { workspace = true, optional = true }
3132
unicode-bidi = { workspace = true, optional = true }
3233

3334
icu_properties_data = { workspace = true, optional = true }
@@ -39,6 +40,7 @@ icu = { path = "../../components/icu", default-features = false }
3940
default = ["compiled_data"]
4041
serde = ["dep:serde", "icu_locale_core/serde", "zerovec/serde", "icu_collections/serde", "icu_provider/serde", "zerotrie/serde"]
4142
datagen = ["serde", "dep:databake", "zerovec/databake", "icu_collections/databake", "icu_locale_core/databake", "zerotrie/databake", "icu_provider/export"]
42-
unicode_bidi = [ "dep:unicode-bidi" ]
43+
unicode_bidi = ["dep:unicode-bidi"]
44+
harfbuzz_traits = ["dep:harfbuzz-traits"]
4345
compiled_data = ["dep:icu_properties_data", "icu_provider/baked"]
4446
alloc = ["zerovec/alloc", "icu_collections/alloc", "serde?/alloc"]

components/properties/README.md

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)