typst/tests/typ/text/bidi.typ
2021-09-30 22:50:14 +02:00

57 lines
1.3 KiB
Typst
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Test bidirectional text and language configuration.
---
// Test reordering with different top-level paragraph directions.
#let text = [Text טֶקסט]
#font(serif, "Noto Serif Hebrew")
#lang("he") {text}
#lang("de") {text}
---
// Test that consecutive, embedded LTR runs stay LTR.
// Here, we have two runs: "A" and italic "B".
#let text = [أنت A_B_مطرC]
#font(serif, "Noto Sans Arabic")
#lang("ar") {text}
#lang("de") {text}
---
// Test that consecutive, embedded RTL runs stay RTL.
// Here, we have three runs: "גֶ", bold "שֶׁ", and "ם".
#let text = [Aגֶ*שֶׁ*םB]
#font(serif, "Noto Serif Hebrew")
#lang("he") {text}
#lang("de") {text}
---
// Test embedding up to level 4 with isolates.
#font(serif, "Noto Serif Hebrew", "Twitter Color Emoji")
#lang(dir: rtl)
א\u{2066}A\u{2067}Bב\u{2069}?
---
// Test hard line break (leads to two paragraphs in unicode-bidi).
#font("Noto Sans Arabic", serif)
#lang("ar")
Life المطر هو الحياة \
الحياة تمطر is rain.
---
// Test spacing.
#font(serif, "Noto Serif Hebrew")
L #h(1cm) ריווחR \
יווח #h(1cm) R
---
// Test inline object.
#font("Noto Serif Hebrew", serif)
#lang("he")
קרנפיםRh#image("../../res/rhino.png", height: 11pt)inoחיים
---
// Test the `lang` function.
// Ref: false
// Error: 12-15 must be horizontal
#lang(dir: ttb)