Skip to main content

ParleyTextSystem

Struct ParleyTextSystem 

Source
pub struct ParleyTextSystem { /* private fields */ }
Expand description

Experimental flat-LTR backend with an opt-in paragraph path. Select fonts before constructing GPUI; GPUI owns the font-metric, line-layout, wrapping and final raster caches.

Implementations§

Source§

impl ParleyTextSystem

Source

pub fn new( fonts: FontContext, default_family: impl Into<String>, ) -> Result<Self>

Use an existing Parley font context and an explicit application default. .SystemUIFont maps to this family; native system-family discovery is not implied. FontContext system discovery requires the system-fonts feature.

Source

pub fn set_layout_error_handler(&self, handler: LayoutErrorHandler)

Replace the rejection diagnostic (default: stderr). Rejections remain fallible through try_layout_line; only GPUI’s infallible hook substitutes.

Source

pub fn try_layout_line( &self, text: &str, size: Pixels, runs: &[FontRun], ) -> Result<LineLayout>

Fallible equivalent of the infallible GPUI layout hook. Validate unsupported input here before using the backend through GPUI (RTL, synthetic styles, paragraph breaks and invalid style ranges return errors).

Source

pub fn prepare_paragraph( &self, text: &str, size: Pixels, runs: &[FontRun], ) -> Result<ParagraphShape>

Extension-only prototype, automatic base direction, one logical paragraph. U+2028 is a hard line break; document/paragraph separators are rejected. Reuses backend contexts/face registry. GPUI owns paragraph caching through the optional PlatformTextSystem hook; this method itself adds no cache.

Source

pub fn prepare_paragraph_with_options( &self, text: &str, size: Pixels, runs: &[FontRun], options: ParagraphOptions, ) -> Result<ParagraphShape>

Like Self::prepare_paragraph, with an explicit base direction and content language. The language applies to the whole paragraph and selects language-specific shaping and line breaking where fonts support it.

Trait Implementations§

Source§

impl PlatformTextSystem for ParleyTextSystem

Source§

fn add_fonts(&self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()>

Source§

fn set_missing_glyph_sink(&self, sink: Option<Arc<dyn MissingGlyphSink>>)

Installs a nonblocking sink for unresolved grapheme clusters.
Source§

fn all_font_names(&self) -> Vec<String>

Get all available font names.
Source§

fn font_id(&self, descriptor: &Font) -> Result<FontId>

Get the font ID for a font descriptor.
Source§

fn font_capabilities(&self) -> FontCapabilities

Reports support for font inspection and explicit static variations.
Source§

fn font_table( &self, id: FontId, tag: FontTag, ) -> Result<FontQuery<Option<Vec<u8>>>>

Reads one OpenType table from the resolved face identified by font_id. Read more
Source§

fn font_metrics(&self, id: FontId) -> FontMetrics

Get metrics for a font.
Source§

fn typographic_bounds(&self, id: FontId, glyph: GlyphId) -> Result<Bounds<f32>>

Get typographic bounds for a glyph.
Source§

fn advance(&self, id: FontId, glyph: GlyphId) -> Result<Size<f32>>

Get the advance width for a glyph.
Source§

fn glyph_for_char(&self, id: FontId, ch: char) -> Option<GlyphId>

Get the glyph ID for a character.
Source§

fn glyph_raster_bounds( &self, params: &RenderGlyphParams, ) -> Result<Bounds<DevicePixels>>

Get raster bounds for a glyph.
Source§

fn rasterize_glyph( &self, params: &RenderGlyphParams, bounds: Bounds<DevicePixels>, ) -> Result<(Size<DevicePixels>, Vec<u8>)>

Rasterize a glyph.
Source§

fn layout_line(&self, text: &str, size: Pixels, runs: &[FontRun]) -> LineLayout

Layout a line of text with the given font runs.
Source§

fn shape_paragraph( &self, request: ParagraphRequest<'_>, ) -> Result<Arc<dyn PlatformParagraphShape>>

Optional paragraph capability; native implementations need not opt in.
Source§

fn recommended_rendering_mode(&self, _: FontId, _: Pixels) -> TextRenderingMode

Returns the recommended text rendering mode for the given font and size.
Source§

fn font_axes( &self, font_id: FontId, ) -> Result<FontQuery<Vec<VariationAxisInfo>>, Error>

Queries axis ranges on a resolved face, distinguishing unsupported queries. By default, reads fvar through font_table and parses it in core.
Source§

fn opentype_features( &self, font_id: FontId, ) -> Result<FontQuery<Vec<OpenTypeFeatureInfo>>, Error>

Queries feature metadata for a resolved face. Backends that cannot inspect the face must return Unsupported, rather than a successful empty list. The default reads GSUB/GPOS through font_table and parses them in core. Invalid IDs, failed reads, and malformed metadata return errors.
Source§

fn prewarm_fonts(&self, _font_ids: &[FontId])

Prewarm any system font caches needed to shape text.
Source§

fn glyph_dilation_for_color(&self, _color: Hsla) -> u8

Returns the dilation level to use for a glyph painted in the given color.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more