pub struct FontFamilyAliasSet { /* private fields */ }
Expand description
Represents a set of font family aliases, and optionally, typeface properties that should be applied when treating those aliases as the canonical family.
For example, the font family "Roboto"
might have one alias set of the form:
{
"names": [ "Roboto Condensed" ],
"width": "condensed"
}
This means that when a client requests the family "Roboto Condensed"
, the font server will
treat that as a request for "Roboto"
with Width::Condensed
.
The font family "Noto Sans CJK"
might have aliases of the form:
[
{
"names": [ "Noto Sans CJK KR", "Noto Sans KR" ],
"languages": [ "ko" ]
},
{
"names": [ "Noto Sans CJK JP", "Noto Sans JP" ],
"languages: [ "ja" ]
}
]
When a client requests "Noto Sans CJK JP"
or "Noto Sans JP"
, the font server will look under
"Noto Sans CJK"
for typefaces that support Japanese ("ja"
).
Create using FontFamilyAliasSet::new
if the aliases will map to typeface property overrides,
or FontFamilyAliasSet::without_overrides
to create a plain set of aliases.
When loaded by the font server, a FontFamilyAliasSet
is expanded over all the names
,
creating an alias entry for every name, with identical style
and languages
values.
Implementations§
Source§impl FontFamilyAliasSet
impl FontFamilyAliasSet
Sourcepub fn new(
names: impl IntoIterator<Item = impl AsRef<str>>,
style: impl Into<StyleOptions>,
languages: impl IntoIterator<Item = impl AsRef<str>>,
) -> Result<Self, Error>
pub fn new( names: impl IntoIterator<Item = impl AsRef<str>>, style: impl Into<StyleOptions>, languages: impl IntoIterator<Item = impl AsRef<str>>, ) -> Result<Self, Error>
Create a new FontFamilyAliasSet
with one or more names, and with optional style and
language overrides.
names
: A list of one more alias namesstyle
: Optionally, style overrides that are automatically applied to the typeface request when one of thenames
is requested.languages
: Optionally, a list of language codes that is automatically applied to the typeface request when one of thenames
is requested. Do not sort the language codes. They are given in priority order, just as inTypefaceQuery.languages
.
Examples:
use manifest::v2::FontFamilyAliasSet;
use manifest::serde_ext::StyleOptions;
// Alias set for "Noto Sans CJK" for Traditional Chinese. Both `"Noto Sans CJK TC"` and
// `"Noto Sans TC"` will serve as aliases that apply the languages `["zh-Hant", "zh-Bopo"]`
// when requested.
FontFamilyAliasSet::new(
vec!["Noto Sans CJK TC", "Noto Sans TC"],
StyleOptions::default(),
vec!["zh-Hant", "zh-Bopo"]);
// Alias set for "Roboto Condensed". `"Roboto Condensed"` will serve as an alias that
// applies the style options `width: condensed` when requested.
FontFamilyAliasSet::new(
vec!["Roboto Condensed"],
StyleOptions {
width: Some(fidl_fuchsia_fonts::Width::Condensed),
..Default::default()
},
vec![]);
Sourcepub fn without_overrides(
names: impl IntoIterator<Item = impl AsRef<str>>,
) -> Result<Self, Error>
pub fn without_overrides( names: impl IntoIterator<Item = impl AsRef<str>>, ) -> Result<Self, Error>
Create a new FontFamilyAliasSet
with one or more names, with no typeface property
overrides.
Sourcepub fn style_overrides(&self) -> &StyleOptions
pub fn style_overrides(&self) -> &StyleOptions
Gets the style property overrides for this set of aliases (may be empty).
Sourcepub fn language_overrides(&self) -> impl Iterator<Item = &String>
pub fn language_overrides(&self) -> impl Iterator<Item = &String>
Gets the language code overrides for this set of aliases (may be empty).
Sourcepub fn has_overrides(&self) -> bool
pub fn has_overrides(&self) -> bool
Whether the alias set has any property overrides. If false
, it’s just a name alias.
Sourcepub fn has_style_overrides(&self) -> bool
pub fn has_style_overrides(&self) -> bool
Whether the alias set has style overrides.
Sourcepub fn has_language_overrides(&self) -> bool
pub fn has_language_overrides(&self) -> bool
Whether the alias set has language overrides.
Trait Implementations§
Source§impl Clone for FontFamilyAliasSet
impl Clone for FontFamilyAliasSet
Source§fn clone(&self) -> FontFamilyAliasSet
fn clone(&self) -> FontFamilyAliasSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for FontFamilyAliasSet
impl Debug for FontFamilyAliasSet
Source§impl<'de> Deserialize<'de> for FontFamilyAliasSet
impl<'de> Deserialize<'de> for FontFamilyAliasSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Hash for FontFamilyAliasSet
impl Hash for FontFamilyAliasSet
Source§impl PartialEq for FontFamilyAliasSet
impl PartialEq for FontFamilyAliasSet
Source§impl Serialize for FontFamilyAliasSet
impl Serialize for FontFamilyAliasSet
impl Eq for FontFamilyAliasSet
impl StructuralPartialEq for FontFamilyAliasSet
Auto Trait Implementations§
impl Freeze for FontFamilyAliasSet
impl RefUnwindSafe for FontFamilyAliasSet
impl Send for FontFamilyAliasSet
impl Sync for FontFamilyAliasSet
impl Unpin for FontFamilyAliasSet
impl UnwindSafe for FontFamilyAliasSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)