Struct ndk::font::FontMatcher

source ·
pub struct FontMatcher { /* private fields */ }
Available on crate feature api-level-29 only.
Expand description

A native AFontMatcher *

Implementations§

source§

impl FontMatcher

source

pub unsafe fn from_ptr(ptr: NonNull<AFontMatcher>) -> Self

Assumes ownership of ptr.

§Safety

ptr must be a valid owning pointer to an Android ffi::AFontMatcher.

source

pub fn ptr(&self) -> NonNull<AFontMatcher>

Returns s the pointer to the native ffi::AFontMatcher.

source

pub fn new() -> Self

Creates a new FontMatcher object. FontMatcher selects the best font from the parameters set by the user.

source

pub fn match_font( &mut self, family_name: &CStr, text: &[u16], run_length_out: Option<&mut u32> ) -> Font

Performs the matching from the generic font family for the text and select one font.

For more information about generic font families, please read the W3C spec.

Even if no font can render the given text, this function will return a non-null result for drawing Tofu character.

§Parameters
  • family_name: A font family name.
  • text: A UTF-16 encoded text buffer to be rendered. If an empty string is given, this function will panic.
  • run_length_out: Set this to Some if you want to get the length of the text run with the font returned.
source

pub fn set_family_variant(&mut self, family_variant: FamilyVariant)

Sets the family variant of the font to be matched.

If this function is not called, the match is performed with FamilyVariant::Default.

source

pub fn set_locales(&mut self, language_tags: &CStr)

Sets the locale of the font to be matched.

If this function is not called, the match is performed with an empty locale list.

§Parameters
  • language_tags: comma separated IETF BCP47 compliant language tags.
source

pub fn set_style(&mut self, weight: FontWeight, italic: bool)

Sets the style of the font to be matched.

If this function is not called, the match is performed with FontWeight::NORMAL with non-italic style.

Trait Implementations§

source§

impl Debug for FontMatcher

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for FontMatcher

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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<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>,

§

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>,

§

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.