Struct ndk::font::FontMatcher
source · pub struct FontMatcher { /* private fields */ }
api-level-29
only.Expand description
A native AFontMatcher *
Implementations§
source§impl FontMatcher
impl FontMatcher
sourcepub unsafe fn from_ptr(ptr: NonNull<AFontMatcher>) -> Self
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
.
sourcepub fn ptr(&self) -> NonNull<AFontMatcher>
pub fn ptr(&self) -> NonNull<AFontMatcher>
Returns s the pointer to the native ffi::AFontMatcher
.
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new FontMatcher
object. FontMatcher
selects the best font from the
parameters set by the user.
sourcepub fn match_font(
&mut self,
family_name: &CStr,
text: &[u16],
run_length_out: Option<&mut u32>
) -> Font
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 toSome
if you want to get the length of the text run with the font returned.
sourcepub fn set_family_variant(&mut self, family_variant: FamilyVariant)
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
.
sourcepub fn set_locales(&mut self, language_tags: &CStr)
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.
sourcepub fn set_style(&mut self, weight: FontWeight, italic: bool)
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.