diff --git a/servo/components/style/font_face.rs b/servo/components/style/font_face.rs index 5e1b145287b0..2c2f5882f11e 100644 --- a/servo/components/style/font_face.rs +++ b/servo/components/style/font_face.rs @@ -17,6 +17,8 @@ use error_reporting::ContextualParseError; #[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors; #[cfg(feature = "gecko")] use cssparser::UnicodeRange; use parser::{ParserContext, log_css_error, Parse}; +#[cfg(feature = "gecko")] +use properties::longhands::font_language_override; use selectors::parser::SelectorParseError; use shared_lock::{SharedRwLockReadGuard, ToCssWithGuard}; use std::fmt; @@ -407,7 +409,10 @@ font_face_descriptors! { font_feature_settings::T::Normal }, - // FIXME: add font-language-override. + /// The language override of this font face. + "font-language-override" language_override / mFontLanguageOverride: font_language_override::SpecifiedValue = { + font_language_override::SpecifiedValue::Normal + }, ] } diff --git a/servo/components/style/gecko/rules.rs b/servo/components/style/gecko/rules.rs index 6a4a29ed97d6..33b2c2c9591b 100644 --- a/servo/components/style/gecko/rules.rs +++ b/servo/components/style/gecko/rules.rs @@ -15,6 +15,7 @@ use gecko_bindings::structs::{self, nsCSSFontFaceRule, nsCSSValue}; use gecko_bindings::structs::{nsCSSCounterDesc, nsCSSCounterStyleRule}; use gecko_bindings::sugar::ns_css_value::ToNsCssValue; use gecko_bindings::sugar::refptr::{RefPtr, UniqueRefPtr}; +use properties::longhands::font_language_override; use shared_lock::{ToCssWithGuard, SharedRwLockReadGuard}; use std::{fmt, str}; use values::generics::FontSettings; @@ -67,6 +68,17 @@ impl ToNsCssValue for font_feature_settings::T { } } +impl ToNsCssValue for font_language_override::SpecifiedValue { + fn convert(self, nscssvalue: &mut nsCSSValue) { + match self { + font_language_override::SpecifiedValue::Normal => nscssvalue.set_normal(), + font_language_override::SpecifiedValue::Override(ref lang) => nscssvalue.set_string(&*lang), + // This path is unreachable because the descriptor is only specified by the user. + font_language_override::SpecifiedValue::System(_) => unreachable!(), + } + } +} + macro_rules! map_enum { ( $( diff --git a/servo/components/style/properties/longhand/font.mako.rs b/servo/components/style/properties/longhand/font.mako.rs index 7899cadb55cd..6cedca5b874f 100644 --- a/servo/components/style/properties/longhand/font.mako.rs +++ b/servo/components/style/properties/longhand/font.mako.rs @@ -2012,7 +2012,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- // OpenType "language system" tag, so we should be able to compute // it and store it as a 32-bit integer // (see http://www.microsoft.com/typography/otspec/languagetags.htm). - #[derive(PartialEq, Clone, Copy, Debug)] + #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct T(pub u32); } @@ -2082,6 +2082,14 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- } } + /// Used in @font-face. + impl Parse for SpecifiedValue { + fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) + -> Result> { + parse(context, input) + } + } + #[cfg(feature = "gecko")] impl From for computed_value::T { fn from(bits: u32) -> computed_value::T {