summaryrefslogtreecommitdiffstats
path: root/vendor/unicode-bidi/src/explicit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/unicode-bidi/src/explicit.rs')
-rw-r--r--vendor/unicode-bidi/src/explicit.rs44
1 files changed, 29 insertions, 15 deletions
diff --git a/vendor/unicode-bidi/src/explicit.rs b/vendor/unicode-bidi/src/explicit.rs
index e9d579fd6..a9b13e89c 100644
--- a/vendor/unicode-bidi/src/explicit.rs
+++ b/vendor/unicode-bidi/src/explicit.rs
@@ -47,13 +47,17 @@ pub fn compute(
RLE | LRE | RLO | LRO | RLI | LRI | FSI => {
let last_level = stack.last().level;
+ // <https://www.unicode.org/reports/tr9/#Retaining_Explicit_Formatting_Characters>
+ levels[i] = last_level;
+
// X5a-X5c: Isolate initiators get the level of the last entry on the stack.
let is_isolate = match original_classes[i] {
RLI | LRI | FSI => true,
_ => false,
};
if is_isolate {
- levels[i] = last_level;
+ // Redundant due to "Retaining explicit formatting characters" step.
+ // levels[i] = last_level;
match stack.last().status {
OverrideStatus::RTL => processing_classes[i] = R,
OverrideStatus::LTR => processing_classes[i] = L,
@@ -90,6 +94,13 @@ pub fn compute(
} else if overflow_isolate_count == 0 {
overflow_embedding_count += 1;
}
+
+ if !is_isolate {
+ // X9 +
+ // <https://www.unicode.org/reports/tr9/#Retaining_Explicit_Formatting_Characters>
+ // (PDF handled below)
+ processing_classes[i] = BN;
+ }
}
// <http://www.unicode.org/reports/tr9/#X6a>
@@ -123,31 +134,34 @@ pub fn compute(
// <http://www.unicode.org/reports/tr9/#X7>
PDF => {
if overflow_isolate_count > 0 {
- continue;
- }
- if overflow_embedding_count > 0 {
+ // do nothing
+ } else if overflow_embedding_count > 0 {
overflow_embedding_count -= 1;
- continue;
- }
- if stack.last().status != OverrideStatus::Isolate && stack.vec.len() >= 2 {
+ } else if stack.last().status != OverrideStatus::Isolate && stack.vec.len() >= 2 {
stack.vec.pop();
}
- // The spec doesn't explicitly mention this step, but it is necessary.
- // See the reference implementations for comparison.
+ // <https://www.unicode.org/reports/tr9/#Retaining_Explicit_Formatting_Characters>
levels[i] = stack.last().level;
+ // X9 part of retaining explicit formatting characters.
+ processing_classes[i] = BN;
}
- // Nothing
- B | BN => {}
+ // Nothing.
+ // BN case moved down to X6, see <https://www.unicode.org/reports/tr9/#Retaining_Explicit_Formatting_Characters>
+ B => {}
// <http://www.unicode.org/reports/tr9/#X6>
_ => {
let last = stack.last();
levels[i] = last.level;
- match last.status {
- OverrideStatus::RTL => processing_classes[i] = R,
- OverrideStatus::LTR => processing_classes[i] = L,
- _ => {}
+ // This condition is not in the spec, but I am pretty sure that is a spec bug.
+ // https://www.unicode.org/L2/L2023/23014-amd-to-uax9.pdf
+ if original_classes[i] != BN {
+ match last.status {
+ OverrideStatus::RTL => processing_classes[i] = R,
+ OverrideStatus::LTR => processing_classes[i] = L,
+ _ => {}
+ }
}
}
}