Function fonts::font::map_platform_values_to_style_values
source ยท pub(crate) fn map_platform_values_to_style_values(
mapping: &[(f64, f64)],
value: f64,
) -> f64
Expand description
Given a mapping array mapping
and a value, map that value onto
the value specified by the array. For instance, for FontConfig
values of weights, we would map these onto the CSS [0..1000] range
by creating an array as below. Values that fall between two mapped
values, will be adjusted by the weighted mean.
let mapping = [
(0., 0.),
(FC_WEIGHT_REGULAR as f64, 400 as f64),
(FC_WEIGHT_BOLD as f64, 700 as f64),
(FC_WEIGHT_EXTRABLACK as f64, 1000 as f64),
];
let mapped_weight = apply_font_config_to_style_mapping(&mapping, weight as f64);