Skip to content

Commit 20c411a

Browse files
committed
Remove Servo-specific font code and expose font-face properties (#14)
Servo needs these properties in order to properly load the fonts on servo.org. In addition, remove some custom Servo code that is no longer necessary. Servo will handle filtering web font sources internally, which will allow it to be less dependent on Stylo for this.
1 parent 71e4d5e commit 20c411a

File tree

4 files changed

+8
-78
lines changed

4 files changed

+8
-78
lines changed

style/font_face.rs

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@
88
99
use crate::error_reporting::ContextualParseError;
1010
use crate::parser::{Parse, ParserContext};
11-
#[cfg(feature = "gecko")]
1211
use crate::properties::longhands::font_language_override;
1312
use crate::shared_lock::{SharedRwLockReadGuard, ToCssWithGuard};
1413
use crate::str::CssStringWriter;
1514
use crate::values::computed::font::{FamilyName, FontStretch};
1615
use crate::values::generics::font::FontStyle as GenericFontStyle;
17-
#[cfg(feature = "gecko")]
1816
use crate::values::specified::font::MetricsOverride;
1917
use crate::values::specified::font::SpecifiedFontStyle;
2018
use crate::values::specified::font::{AbsoluteFontWeight, FontStretch as SpecifiedFontStretch};
21-
#[cfg(feature = "gecko")]
2219
use crate::values::specified::font::{FontFeatureSettings, FontVariationSettings};
2320
use crate::values::specified::url::SpecifiedUrl;
2421
use crate::values::specified::Angle;
25-
#[cfg(feature = "gecko")]
2622
use crate::values::specified::NonNegativePercentage;
27-
#[cfg(feature = "gecko")]
2823
use cssparser::UnicodeRange;
2924
use cssparser::{
3025
AtRuleParser, CowRcStr, DeclarationParser, Parser, QualifiedRuleParser, RuleBodyItemParser,
@@ -491,64 +486,6 @@ pub fn parse_font_face_block(
491486
#[cfg(feature = "servo")]
492487
pub struct FontFace<'a>(&'a FontFaceRuleData);
493488

494-
/// A list of effective sources that we send over through IPC to the font cache.
495-
#[cfg(feature = "servo")]
496-
#[derive(Clone, Debug)]
497-
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
498-
pub struct EffectiveSources(Vec<Source>);
499-
500-
#[cfg(feature = "servo")]
501-
impl<'a> FontFace<'a> {
502-
/// Returns the list of effective sources for that font-face, that is the
503-
/// sources which don't list any format hint, or the ones which list at
504-
/// least "truetype" or "opentype".
505-
pub fn effective_sources(&self) -> EffectiveSources {
506-
EffectiveSources(
507-
self.sources()
508-
.0
509-
.iter()
510-
.rev()
511-
.filter(|source| {
512-
if let Source::Url(ref url_source) = **source {
513-
// We support only opentype fonts and truetype is an alias for
514-
// that format. Sources without format hints need to be
515-
// downloaded in case we support them.
516-
url_source
517-
.format_hint
518-
.as_ref()
519-
.map_or(true, |hint| match hint {
520-
FontFaceSourceFormat::Keyword(
521-
FontFaceSourceFormatKeyword::Truetype
522-
| FontFaceSourceFormatKeyword::Opentype
523-
| FontFaceSourceFormatKeyword::Woff,
524-
) => true,
525-
FontFaceSourceFormat::String(s) => {
526-
s == "truetype" || s == "opentype" || s == "woff"
527-
}
528-
_ => false,
529-
})
530-
} else {
531-
true
532-
}
533-
})
534-
.cloned()
535-
.collect(),
536-
)
537-
}
538-
}
539-
540-
#[cfg(feature = "servo")]
541-
impl Iterator for EffectiveSources {
542-
type Item = Source;
543-
fn next(&mut self) -> Option<Source> {
544-
self.0.pop()
545-
}
546-
547-
fn size_hint(&self) -> (usize, Option<usize>) {
548-
(self.0.len(), Some(self.0.len()))
549-
}
550-
}
551-
552489
struct FontFaceRuleParser<'a, 'b: 'a> {
553490
context: &'a ParserContext<'b>,
554491
rule: &'a mut FontFaceRuleData,
@@ -762,7 +699,6 @@ macro_rules! font_face_descriptors {
762699
}
763700
}
764701

765-
#[cfg(feature = "gecko")]
766702
font_face_descriptors! {
767703
mandatory descriptors = [
768704
/// The name of this font face
@@ -809,16 +745,3 @@ font_face_descriptors! {
809745
"size-adjust" size_adjust / mSizeAdjust: NonNegativePercentage,
810746
]
811747
}
812-
813-
#[cfg(feature = "servo")]
814-
font_face_descriptors! {
815-
mandatory descriptors = [
816-
/// The name of this font face
817-
"font-family" family / mFamily: FamilyName,
818-
819-
/// The alternative sources for this font face.
820-
"src" sources / mSrc: SourceList,
821-
]
822-
optional descriptors = [
823-
]
824-
}

style/properties/longhands/font.mako.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ ${helpers.predefined_type(
251251
${helpers.predefined_type(
252252
"font-language-override",
253253
"FontLanguageOverride",
254-
engines="gecko",
254+
engines="gecko servo",
255255
initial_value="computed::FontLanguageOverride::normal()",
256256
initial_specified_value="specified::FontLanguageOverride::normal()",
257257
animation_value_type="discrete",

style/values/computed/font.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ where
10001000
ToResolvedValue,
10011001
ToShmem,
10021002
)]
1003+
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
10031004
#[repr(C)]
10041005
#[value_info(other_values = "normal")]
10051006
pub struct FontLanguageOverride(pub u32);

style_static_prefs/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ macro_rules! pref {
5151
("layout.css.fit-content-function.enabled") => {
5252
false
5353
};
54+
("layout.css.font-display.enabled") => {
55+
false
56+
};
57+
("layout.css.font-metrics-overrides.enabled") => {
58+
false
59+
};
5460
("layout.css.font-palette.enabled") => {
5561
false
5662
};

0 commit comments

Comments
 (0)