Skip to content

kas-gui/kas-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kas Text

kas Docs

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

Kas-text is intended to address the needs of common GUI text tasks: fast, able to handle plain text well in common scripts including common effects like bold text and underline, along with support for editing plain texts.

More on what Kas-text does do:

  • Font discovery via Fontique
  • Font loading and management
  • Script-aware font selection and glyph-level fallback
  • Text layout via a choice of rustybuzz or a simple built-in shaper
  • Vertical text support
  • Supports bi-directional texts
  • A low-level API for text editing including logical-order and mouse navigation
  • Visual-order navigation
  • Sub-ligature navigation
  • Font styles (weight, width, italic)
  • Text decorations: highlight range, underline
  • Decently optimized: good enough for snappy GUIs

Rich text support is limited to changing font properties (e.g. weight, italic), size, family and underline/strikethrough decorations. A (very limited) Markdown processor is included to facilitate construction of these texts using the lower-level FormattableText trait.

Glyph rastering and painting is not implemented here, though kas-text can provide font references for Swash and (optionally) ab_glyph libraries. Check the kas-wgpu code for an example of rastering and painting.

Text editing is only supported via a low-level API. kas_widgets::edit::EditField is a simple editor built over this API.

Examples

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

BIDI layout and editing Markdown

Alternatives

Pure-Rust alternatives for typesetting and rendering text:

  • Parley provides an API for implementing rich text layout. It is backed by Swash.
  • COSMIC Text provides advanced text shaping, layout, and rendering wrapped up into a simple abstraction.
  • glyph_brush is a fast caching text render library using ab_glyph.

Contributing

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

Testing is done in an ad-hoc manner using examples. The Layout Demo often proves useful for quick tests. It helps to use a patch like that below in kas/Cargo.toml:

[patch.crates-io.kas-text]
path = "../kas-text"

Copyright and License

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 license from the LICENSE file or on the following web page: https://www.apache.org/licenses/LICENSE-2.0

About

Rich text processing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages