Skip to main content

ShapeOptions

Struct ShapeOptions 

Source
pub struct ShapeOptions<'a> {
    plan: Option<&'a ShapePlan>,
    scale: Option<(i32, i32)>,
    point_size: Option<f32>,
    features: &'a [Feature],
    font_funcs: Option<&'a mut (dyn FontFuncs + 'a)>,
}
Expand description

Options which can be used to configure shaping.

Fields§

§plan: Option<&'a ShapePlan>§scale: Option<(i32, i32)>§point_size: Option<f32>§features: &'a [Feature]§font_funcs: Option<&'a mut (dyn FontFuncs + 'a)>

Implementations§

Source§

impl<'a> ShapeOptions<'a>

Source

pub fn new() -> Self

Creates a default set of shape options ready for configuration.

Source

pub fn plan(self, plan: Option<&'a ShapePlan>) -> Self

Sets the plan to use for shaping.

The shape plan must be compatible with the properties of the buffer passed to shaping.

Source

pub fn scale(self, scale: Option<i32>) -> Self

Sets the scale factor to use during shaping.

The font scale is a number related to, but not the same as, font size. Typically the client establishes a scale factor to be used between the two. For example, 64, or 256, which would be the fractional-precision part of the font scale. This is necessary because position and metric values are integer types and you need to leave room for fractional values in there.

For example, to set the font size to 20, with 64 levels of fractional precision you would call provide a scale of 20 * 64.

In the example above, even what font size 20 means is up to you. It might be 20 pixels, or 20 points, or 20 millimeters. HarfRust does not care about that.

The choice of scale is yours but needs to be consistent between what you set here, and what you expect as output as well as the values returned by font functions.

This defaults to None which means that no scale is applied– positions and metrics will be returned in font units.

Source

pub fn scale_separate(self, scale: Option<(i32, i32)>) -> Self

Sets separate x- and y-scale factors to use during shaping.

Each axis uses the same semantics as scale.

Source

pub fn point_size(self, point_size: Option<f32>) -> Self

Sets the size used for application of the tracking table.

Source

pub fn features(self, features: &'a [Feature]) -> Self

Sets the features to apply during shaping.

Source

pub fn font_funcs(self, funcs: Option<&'a mut (dyn FontFuncs + 'a)>) -> Self

Sets optional font functions used for shaping.

Trait Implementations§

Source§

impl<'a> Default for ShapeOptions<'a>

Source§

fn default() -> ShapeOptions<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ShapeOptions<'a>

§

impl<'a> !RefUnwindSafe for ShapeOptions<'a>

§

impl<'a> !Send for ShapeOptions<'a>

§

impl<'a> !Sync for ShapeOptions<'a>

§

impl<'a> Unpin for ShapeOptions<'a>

§

impl<'a> UnsafeUnpin for ShapeOptions<'a>

§

impl<'a> !UnwindSafe for ShapeOptions<'a>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.