mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support font-feature-settings as a @font-face descriptor
This commit is contained in:
parent
7d66e65d94
commit
a0886213b6
3 changed files with 44 additions and 12 deletions
|
@ -4,7 +4,8 @@
|
|||
|
||||
//! Bindings for CSS Rule objects
|
||||
|
||||
use computed_values::{font_style, font_weight, font_stretch};
|
||||
use byteorder::{BigEndian, WriteBytesExt};
|
||||
use computed_values::{font_feature_settings, font_stretch, font_style, font_weight};
|
||||
use computed_values::font_family::FamilyName;
|
||||
use counter_style;
|
||||
use cssparser::UnicodeRange;
|
||||
|
@ -15,7 +16,7 @@ use gecko_bindings::structs::{nsCSSCounterDesc, nsCSSCounterStyleRule};
|
|||
use gecko_bindings::sugar::ns_css_value::ToNsCssValue;
|
||||
use gecko_bindings::sugar::refptr::{RefPtr, UniqueRefPtr};
|
||||
use shared_lock::{ToCssWithGuard, SharedRwLockReadGuard};
|
||||
use std::fmt;
|
||||
use std::{fmt, str};
|
||||
|
||||
/// A @font-face rule
|
||||
pub type FontFaceRule = RefPtr<nsCSSFontFaceRule>;
|
||||
|
@ -32,6 +33,27 @@ impl ToNsCssValue for font_weight::T {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for font_feature_settings::T {
|
||||
fn convert(self, nscssvalue: &mut nsCSSValue) {
|
||||
match self {
|
||||
font_feature_settings::T::Normal => nscssvalue.set_normal(),
|
||||
font_feature_settings::T::Tag(tags) => {
|
||||
nscssvalue.set_pair_list(tags.into_iter().map(|entry| {
|
||||
let mut feature = nsCSSValue::null();
|
||||
let mut raw = [0u8; 4];
|
||||
(&mut raw[..]).write_u32::<BigEndian>(entry.tag).unwrap();
|
||||
feature.set_string(str::from_utf8(&raw).unwrap());
|
||||
|
||||
let mut index = nsCSSValue::null();
|
||||
index.set_integer(entry.value as i32);
|
||||
|
||||
(feature, index)
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! map_enum {
|
||||
(
|
||||
$(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue