pub fn select_face(
faces: &[FaceTraits<'_>],
family: &str,
weight: u16,
style: FontStyle,
) -> Option<usize>Expand description
The index in faces of the face CSS Fonts Module Level 4 selects for
family, weight and style, or None where no face records family.
Only faces one of whose family names equals family under Unicode
default caseless matching (§5.1 “Localized name matching”; unicase)
are candidates, and no other family is ever substituted: an empty
candidate set is None. Among the candidates the three steps of §5.2
“Matching font styles” narrow the set in order, with the model’s
normal width — font-width: normal first, then narrower widths
descending, then wider ascending; font-style: Italic takes italic,
then oblique, then normal, Oblique oblique, italic, normal, and
Normal normal, oblique, italic; font-weight: for a desired weight
inclusively between 400 and 500, weights at or above it ascending up to
and including 500, then below it descending, then above 500; below 400,
weights at or below it descending, then above it ascending; above 500,
weights at or above it ascending, then below it descending — and the
first face in faces order among those left is returned.
fontdb’s own query is deliberately not used: it compares family names
case-sensitively, and its weight step follows Level 3 with a 450
cut-off, which picks 300 where Level 4 picks 450 for a desired 400.