Skip to main content

Crate parlance

Crate parlance 

Source
Expand description

Fundamental text property types.

This crate is intended as a lightweight, no_std-friendly vocabulary layer that can be shared across style systems, text layout engines, and font tooling. It focuses on small, typed representations of common “leaf” concepts (weights, widths, OpenType tags, language tags, etc).

§Features

  • std (enabled by default): This is currently unused and is provided for forward compatibility.
  • bytemuck: Implement traits from bytemuck on GenericFamily.

§Example

use parlance::{Language, Tag};

let tag = Tag::parse("wght").unwrap();
assert_eq!(tag.to_bytes(), *b"wght");

let lang = Language::parse("zh-Hans-CN").unwrap();
assert_eq!(lang.as_str(), "zh-Hans-CN");
assert_eq!(lang.language(), "zh");
assert_eq!(lang.script(), Some("Hans"));
assert_eq!(lang.region(), Some("CN"));

Structs§

FontFeature
OpenType font feature setting (tag + u16 value).
FontVariation
OpenType font variation setting (tag + f32 value).
FontWeight
Visual weight class of a font, typically on a scale from 1.0 to 1000.0.
FontWidth
Visual width of a font — a relative change from the normal aspect ratio, typically in the range 0.5 to 2.0.
Language
A compact, zero-allocation language tag.
ParseFontFamilyError
Error returned when parsing CSS font-family strings.
ParseSettingsError
Error returned when parsing OpenType settings source strings.
Script
An ISO 15924 script identifier (four ASCII letters).
Tag
A 4-byte OpenType tag (for example wght, liga).

Enums§

BaseDirection
The paragraph’s base direction.
BidiControl
An inline bidirectional text control.
BidiDirection
Direction choice used by bidi controls.
BidiOverride
Direction choice used by bidi overrides.
FontFamily
CSS font-family property value.
FontFamilyName
A single named or generic font family.
FontStyle
Visual style or “slope” of a font.
GenericFamily
Generic font families, named after CSS.
OverflowWrap
Control over “emergency” line-breaking.
ParseFontFamilyErrorKind
Kinds of errors that can occur when parsing CSS font-family strings.
ParseLanguageError
An error returned when parsing a Language fails.
ParseScriptError
An error returned from parsing a Script.
ParseSettingsErrorKind
Kinds of errors that can occur when parsing OpenType settings source strings.
TextWrapMode
Control over non-“emergency” line-breaking.
WordBreak
Control over word breaking, named for the CSS property.