10 releases

new 0.3.1 Jun 17, 2021
0.3.0 Jun 15, 2021
0.2.1 Mar 31, 2021
0.2.0 Nov 23, 2020
0.1.3 Aug 14, 2020

#99 in Text processing

Download history 4/week @ 2021-02-26 13/week @ 2021-03-05 4/week @ 2021-03-12 17/week @ 2021-03-19 48/week @ 2021-03-26 78/week @ 2021-04-02 58/week @ 2021-04-09 69/week @ 2021-04-16 37/week @ 2021-04-23 51/week @ 2021-04-30 47/week @ 2021-05-07 17/week @ 2021-05-14 6/week @ 2021-05-21 8/week @ 2021-05-28 11/week @ 2021-06-04 32/week @ 2021-06-11

160 downloads per month
Used in 3 crates (2 directly)


3.5K SLoC

KAS Text

kas Docs

A rich-text processing library suitable for KAS and other GUI tools.

What it does (or plans to) do:

  • Provides a representation for rich-text
  • Manages loading and selection of fonts (partial)
  • Transforms input text to a sequence of positioned glyphs
  • Performs line-wrapping and alignment
  • Supports bi-directional text
  • Supports font shaping via HarfBuzz (optional: shaping feature; requires HarfBuzz library)
  • Simple integrated "shaper" supporting kerning
  • Provides helpers for text editing / navigation
  • Fast line-wrapping when only width changes
  • Scale well to large documents

What it does not do:

  • Draw glyphs — this is left to other libraries such as glyph-brush
  • Directly handle text editing — this is mostly about handling input, however this library does provide helper methods for navigating prepared text

What it arguably should do, but is beyond the current scope:

  • Support font fallbacks for missing glyphs
  • Emojis, vertical text, sub-ligature navigation, correctly positioning multiple diacritics, and many more details

For more, see the initial design document and issue #1.


Since kas-text only concerns text-layout, all examples here are courtesy of KAS GUI. See the examples directory.

Bidi layout and editing Markdown


Contributions are welcome. For the less straightforward contributions it is advisable to discuss in an issue before creating a pull-request.

Testing is currently done in a very ad-hoc manner via KAS examples. This is facilitated by tying KAS commits to kas-text commit hashes during development and allows testing editing as well as display. A comprehensive test framework must consider a huge number of cases and the test framework alone would consitute considerably more work than building this library, so for now user-testing and bug reports will have to suffice.

Copyright and Licence

The COPYRIGHT file includes a list of contributors who claim copyright on this project. This list may be incomplete; new contributors may optionally add themselves to this list.

The KAS library is published under the terms of the Apache License, Version 2.0. You may obtain a copy of this licence from the LICENSE file or on the following webpage: https://www.apache.org/licenses/LICENSE-2.0


~66K SLoC