t

text-dirr

@preview

Get resolved value for text.dir.

v1.0.0
AGPL-3.0-only

Package Information

Last Updated
Minimum Typst Version
0.11.0

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/text-dirr:1.0.0

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/text-dirr:1.0.0": *

Version History

1.0.00.11.0
69160ce226f0...

text-dirr (Typst package)

This package is made to work around https://github.com/typst/typst/issues/6181,
as text.dir by default returns auto instead of ltr/rtl. When this issue
will be resolved, there will be no need to use this package.

Note that Typst currently doesn't support (ISO 639) set 2 and 3 language codes:
https://github.com/typst/typst/issues/6182.

Usage

#import "@preview/text-dirr:1.0.0": text-dir, rtl-languages

ISO 639 language codes for RTL languages that Typst can detect:
#rtl-languages.map(list.item).join()

#context assert.eq(text-dir(), ltr)

#set text(lang: "ar")
#context assert.eq(text-dir(), rtl)

#set text(dir: ltr)
#context assert.eq(text-dir(), ltr)
  • text-dir() — returns either ltr or rtl and must be used inside context
  • rtl-languages — array of strings (language codes for RTL languages)

License

This Typst package is licensed under AGPL-3.0-only license. You can view the
license in the LICENSE file in the root of the project or at
https://www.gnu.org/licenses/agpl-3.0.txt.