aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'components/gfx')
-rw-r--r--components/gfx/font.rs24
-rw-r--r--components/gfx/font_cache_thread.rs64
-rw-r--r--components/gfx/font_context.rs41
-rw-r--r--components/gfx/tests/font_context.rs174
-rw-r--r--components/gfx/tests/support/CSSTest/LICENSE94
-rw-r--r--components/gfx/tests/support/CSSTest/README25
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-ascii.ttfbin0 -> 28208 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-basic-bold.ttfbin0 -> 232344 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttfbin0 -> 221620 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-basic-italic.ttfbin0 -> 227600 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-basic-regular.ttfbin0 -> 229636 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-fallback.ttfbin0 -> 28424 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttfbin0 -> 29424 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttfbin0 -> 29452 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttfbin0 -> 29372 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttfbin0 -> 29336 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-familyname.ttfbin0 -> 29208 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-verify.ttfbin0 -> 28564 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-100.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttfbin0 -> 8628 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttfbin0 -> 8592 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttfbin0 -> 8496 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-200.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttfbin0 -> 8496 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttfbin0 -> 8496 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-300.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttfbin0 -> 8524 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-400.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttfbin0 -> 8496 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttfbin0 -> 8496 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-500.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-600.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-700.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-800.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-900.ttfbin0 -> 8364 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttfbin0 -> 8608 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttfbin0 -> 8508 bytes
-rw-r--r--components/gfx/tests/support/CSSTest/csstest-weights.ttfbin0 -> 8320 bytes
58 files changed, 370 insertions, 52 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs
index 83f793c12c9..09578168ea7 100644
--- a/components/gfx/font.rs
+++ b/components/gfx/font.rs
@@ -4,7 +4,7 @@
use app_units::Au;
use euclid::{Point2D, Rect, Size2D};
-use font_context::FontContext;
+use font_context::{FontContext, FontSource};
use font_template::FontTemplateDescriptor;
use ordered_float::NotNaN;
use platform::font::{FontHandle, FontTable};
@@ -341,23 +341,33 @@ impl FontGroup {
/// `codepoint`. If no such font is found, returns the first available font or fallback font
/// (which will cause a "glyph not found" character to be rendered). If no font at all can be
/// found, returns None.
- pub fn find_by_codepoint(&mut self, mut font_context: &mut FontContext, codepoint: char) -> Option<FontRef> {
+ pub fn find_by_codepoint<S: FontSource>(
+ &mut self,
+ mut font_context: &mut FontContext<S>,
+ codepoint: char
+ ) -> Option<FontRef> {
self.find(&mut font_context, |font| font.borrow().has_glyph_for(codepoint))
.or_else(|| self.first(&mut font_context))
}
- pub fn first(&mut self, mut font_context: &mut FontContext) -> Option<FontRef> {
+ pub fn first<S: FontSource>(
+ &mut self,
+ mut font_context: &mut FontContext<S>
+ ) -> Option<FontRef> {
self.find(&mut font_context, |_| true)
}
/// Find a font which returns true for `predicate`. This method mutates because we may need to
/// load new font data in the process of finding a suitable font.
- fn find<P>(
+ fn find<S, P>(
&mut self,
- mut font_context: &mut FontContext,
+ mut font_context: &mut FontContext<S>,
mut predicate: P
) -> Option<FontRef>
- where P: FnMut(&FontRef) -> bool {
+ where
+ S: FontSource,
+ P: FnMut(&FontRef) -> bool
+ {
self.families.iter_mut()
.filter_map(|family| family.font(&mut font_context))
.find(|f| predicate(f))
@@ -392,7 +402,7 @@ impl FontGroupFamily {
/// Returns the font within this family which matches the style. We'll fetch the data from the
/// `FontContext` the first time this method is called, and return a cached reference on
/// subsequent calls.
- fn font(&mut self, font_context: &mut FontContext) -> Option<FontRef> {
+ fn font<S: FontSource>(&mut self, font_context: &mut FontContext<S>) -> Option<FontRef> {
if !self.loaded {
self.font = font_context.font(&self.descriptor, &self.family);
self.loaded = true;
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs
index 14c58ac411c..fec14cfdb9d 100644
--- a/components/gfx/font_cache_thread.rs
+++ b/components/gfx/font_cache_thread.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au;
+use font_context::FontSource;
use font_template::{FontTemplate, FontTemplateDescriptor};
use fontsan;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
@@ -30,7 +31,7 @@ use style::values::computed::font::{SingleFontFamily, FamilyName};
use webrender_api;
/// A list of font templates that make up a given font family.
-struct FontTemplates {
+pub struct FontTemplates {
templates: Vec<FontTemplate>,
}
@@ -41,14 +42,14 @@ pub struct FontTemplateInfo {
}
impl FontTemplates {
- fn new() -> FontTemplates {
+ pub fn new() -> FontTemplates {
FontTemplates {
templates: vec!(),
}
}
/// Find a font in this family that matches a given descriptor.
- fn find_font_for_style(&mut self, desc: &FontTemplateDescriptor, fctx: &FontContextHandle)
+ pub fn find_font_for_style(&mut self, desc: &FontTemplateDescriptor, fctx: &FontContextHandle)
-> Option<Arc<FontTemplateData>> {
// TODO(Issue #189): optimize lookup for
// regular/bold/italic/bolditalic with fixed offsets and a
@@ -89,7 +90,7 @@ impl FontTemplates {
None
}
- fn add_template(&mut self, identifier: Atom, maybe_data: Option<Vec<u8>>) {
+ pub fn add_template(&mut self, identifier: Atom, maybe_data: Option<Vec<u8>>) {
for template in &self.templates {
if *template.identifier() == identifier {
return;
@@ -414,8 +415,8 @@ impl FontCache {
}
}
-/// The public interface to the font cache thread, used exclusively by
-/// the per-thread/thread FontContext structures.
+/// The public interface to the font cache thread, used by per-thread `FontContext` instances (via
+/// the `FontSource` trait), and also by layout.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct FontCacheThread {
chan: IpcSender<Command>,
@@ -453,7 +454,31 @@ impl FontCacheThread {
}
}
- pub fn find_font_template(&self, family: SingleFontFamily, desc: FontTemplateDescriptor)
+ pub fn add_web_font(&self, family: FamilyName, sources: EffectiveSources, sender: IpcSender<()>) {
+ self.chan.send(Command::AddWebFont(LowercaseString::new(&family.name), sources, sender)).unwrap();
+ }
+
+ pub fn exit(&self) {
+ let (response_chan, response_port) = ipc::channel().unwrap();
+ self.chan.send(Command::Exit(response_chan)).expect("Couldn't send FontCacheThread exit message");
+ response_port.recv().expect("Couldn't receive FontCacheThread reply");
+ }
+}
+
+impl FontSource for FontCacheThread {
+ fn get_font_instance(&mut self, key: webrender_api::FontKey, size: Au) -> webrender_api::FontInstanceKey {
+ let (response_chan, response_port) =
+ ipc::channel().expect("failed to create IPC channel");
+ self.chan.send(Command::GetFontInstance(key, size, response_chan))
+ .expect("failed to send message to font cache thread");
+
+ let instance_key = response_port.recv()
+ .expect("failed to receive response to font request");
+
+ instance_key
+ }
+
+ fn find_font_template(&mut self, family: SingleFontFamily, desc: FontTemplateDescriptor)
-> Option<FontTemplateInfo> {
let (response_chan, response_port) =
ipc::channel().expect("failed to create IPC channel");
@@ -470,7 +495,7 @@ impl FontCacheThread {
}
}
- pub fn last_resort_font_template(&self, desc: FontTemplateDescriptor)
+ fn last_resort_font_template(&mut self, desc: FontTemplateDescriptor)
-> FontTemplateInfo {
let (response_chan, response_port) =
ipc::channel().expect("failed to create IPC channel");
@@ -486,31 +511,8 @@ impl FontCacheThread {
}
}
}
-
- pub fn add_web_font(&self, family: FamilyName, sources: EffectiveSources, sender: IpcSender<()>) {
- self.chan.send(Command::AddWebFont(LowercaseString::new(&family.name), sources, sender)).unwrap();
- }
-
- pub fn get_font_instance(&self, key: webrender_api::FontKey, size: Au) -> webrender_api::FontInstanceKey {
- let (response_chan, response_port) =
- ipc::channel().expect("failed to create IPC channel");
- self.chan.send(Command::GetFontInstance(key, size, response_chan))
- .expect("failed to send message to font cache thread");
-
- let instance_key = response_port.recv()
- .expect("failed to receive response to font request");
-
- instance_key
- }
-
- pub fn exit(&self) {
- let (response_chan, response_port) = ipc::channel().unwrap();
- self.chan.send(Command::Exit(response_chan)).expect("Couldn't send FontCacheThread exit message");
- response_port.recv().expect("Couldn't receive FontCacheThread reply");
- }
}
-
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct LowercaseString {
inner: String,
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs
index c72cbcbb951..a680f59dc44 100644
--- a/components/gfx/font_context.rs
+++ b/components/gfx/font_context.rs
@@ -5,7 +5,8 @@
use app_units::Au;
use fnv::FnvHasher;
use font::{Font, FontDescriptor, FontGroup, FontHandleMethods, FontRef};
-use font_cache_thread::{FontCacheThread, FontTemplateInfo};
+use font_cache_thread::FontTemplateInfo;
+use font_template::FontTemplateDescriptor;
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use platform::font::FontHandle;
pub use platform::font_context::FontContextHandle;
@@ -20,6 +21,7 @@ use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use style::computed_values::font_variant_caps::T as FontVariantCaps;
use style::properties::style_structs::Font as FontStyleStruct;
use style::values::computed::font::SingleFontFamily;
+use webrender_api;
static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h)
@@ -58,14 +60,26 @@ impl FallbackFontCacheEntry {
/// this one.
static FONT_CACHE_EPOCH: AtomicUsize = ATOMIC_USIZE_INIT;
+pub trait FontSource {
+ fn get_font_instance(&mut self, key: webrender_api::FontKey, size: Au) -> webrender_api::FontInstanceKey;
+
+ fn find_font_template(
+ &mut self,
+ family: SingleFontFamily,
+ desc: FontTemplateDescriptor
+ ) -> Option<FontTemplateInfo>;
+
+ fn last_resort_font_template(&mut self, desc: FontTemplateDescriptor) -> FontTemplateInfo;
+}
+
/// The FontContext represents the per-thread/thread state necessary for
/// working with fonts. It is the public API used by the layout and
/// paint code. It talks directly to the font cache thread where
/// required.
#[derive(Debug)]
-pub struct FontContext {
+pub struct FontContext<S: FontSource> {
platform_handle: FontContextHandle,
- font_cache_thread: FontCacheThread,
+ font_source: S,
// TODO: The font context holds a strong ref to the cached fonts
// so they will never be released. Find out a good time to drop them.
@@ -81,12 +95,12 @@ pub struct FontContext {
epoch: usize,
}
-impl FontContext {
- pub fn new(font_cache_thread: FontCacheThread) -> FontContext {
+impl<S: FontSource> FontContext<S> {
+ pub fn new(font_source: S) -> FontContext<S> {
let handle = FontContextHandle::new();
FontContext {
platform_handle: handle,
- font_cache_thread: font_cache_thread,
+ font_source,
font_cache: vec!(),
fallback_font_cache: vec!(),
font_group_cache: HashMap::with_hasher(Default::default()),
@@ -97,7 +111,7 @@ impl FontContext {
/// Create a `Font` for use in layout calculations, from a `FontTemplateInfo` returned by the
/// cache thread (which contains the underlying font data) and a `FontDescriptor` which
/// contains the styling parameters.
- fn create_font(&self, info: FontTemplateInfo, descriptor: FontDescriptor) -> Result<Font, ()> {
+ fn create_font(&mut self, info: FontTemplateInfo, descriptor: FontDescriptor) -> Result<Font, ()> {
// TODO: (Bug #3463): Currently we only support fake small-caps
// painting. We should also support true small-caps (where the
// font supports it) in the future.
@@ -110,8 +124,7 @@ impl FontContext {
info.font_template,
Some(actual_pt_size))?;
- let font_instance_key = self.font_cache_thread
- .get_font_instance(info.font_key, actual_pt_size);
+ let font_instance_key = self.font_source.get_font_instance(info.font_key, actual_pt_size);
Ok(Font::new(handle, descriptor.to_owned(), actual_pt_size, font_instance_key))
}
@@ -155,9 +168,9 @@ impl FontContext {
}
/// Creates a new font cache entry matching `descriptor` and `family`.
- fn create_font_cache_entry(&self, descriptor: &FontDescriptor, family: &SingleFontFamily) -> FontCacheEntry {
+ fn create_font_cache_entry(&mut self, descriptor: &FontDescriptor, family: &SingleFontFamily) -> FontCacheEntry {
let font =
- self.font_cache_thread.find_font_template(family.clone(), descriptor.template_descriptor.clone())
+ self.font_source.find_font_template(family.clone(), descriptor.template_descriptor.clone())
.and_then(|template_info|
self.create_font(template_info, descriptor.to_owned()).ok()
)
@@ -187,8 +200,8 @@ impl FontContext {
}
/// Creates a new fallback font cache entry matching `descriptor`.
- fn create_fallback_font_cache_entry(&self, descriptor: &FontDescriptor) -> Option<FallbackFontCacheEntry> {
- let template_info = self.font_cache_thread.last_resort_font_template(descriptor.template_descriptor.clone());
+ fn create_fallback_font_cache_entry(&mut self, descriptor: &FontDescriptor) -> Option<FallbackFontCacheEntry> {
+ let template_info = self.font_source.last_resort_font_template(descriptor.template_descriptor.clone());
match self.create_font(template_info, descriptor.to_owned()) {
Ok(font) =>
@@ -220,7 +233,7 @@ impl FontContext {
}
}
-impl MallocSizeOf for FontContext {
+impl<S: FontSource> MallocSizeOf for FontContext<S> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
// FIXME(njn): Measure other fields eventually.
self.platform_handle.size_of(ops)
diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs
new file mode 100644
index 00000000000..f7fef58a5c2
--- /dev/null
+++ b/components/gfx/tests/font_context.rs
@@ -0,0 +1,174 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+extern crate app_units;
+extern crate gfx;
+extern crate servo_arc;
+extern crate servo_atoms;
+extern crate style;
+extern crate webrender_api;
+
+use app_units::Au;
+use gfx::font::FontHandleMethods;
+use gfx::font_cache_thread::{FontTemplates, FontTemplateInfo};
+use gfx::font_context::{FontContext, FontContextHandle, FontSource};
+use gfx::font_template::FontTemplateDescriptor;
+use servo_arc::Arc;
+use servo_atoms::Atom;
+use std::cell::Cell;
+use std::collections::HashMap;
+use std::fs::File;
+use std::io::prelude::*;
+use std::path::PathBuf;
+use std::rc::Rc;
+use style::properties::longhands::font_stretch::computed_value::T as FontStretch;
+use style::properties::longhands::font_style::computed_value::T as FontStyle;
+use style::properties::longhands::font_variant_caps::computed_value::T as FontVariantCaps;
+use style::properties::style_structs::Font as FontStyleStruct;
+use style::values::computed::font::{FamilyName, FamilyNameSyntax, FontFamily, FontFamilyList, FontSize};
+use style::values::computed::font::{FontWeight, SingleFontFamily};
+
+struct TestFontSource {
+ handle: FontContextHandle,
+ families: HashMap<Atom, FontTemplates>,
+ find_font_count: Rc<Cell<isize>>,
+}
+
+impl TestFontSource {
+ fn new() -> TestFontSource {
+ let mut csstest_ascii = FontTemplates::new();
+ Self::add_face(&mut csstest_ascii, "csstest-ascii");
+
+ let mut csstest_basic = FontTemplates::new();
+ Self::add_face(&mut csstest_basic, "csstest-basic-regular");
+
+ let mut families = HashMap::new();
+ families.insert(Atom::from("CSSTest ASCII"), csstest_ascii);
+ families.insert(Atom::from("CSSTest Basic"), csstest_basic);
+
+ TestFontSource {
+ handle: FontContextHandle::new(),
+ families,
+ find_font_count: Rc::new(Cell::new(0)),
+ }
+ }
+
+ fn add_face(family: &mut FontTemplates, name: &str) {
+ let mut path: PathBuf = [
+ env!("CARGO_MANIFEST_DIR"),
+ "tests",
+ "support",
+ "CSSTest",
+ ].iter().collect();
+ path.push(format!("{}.ttf", name));
+
+ let file = File::open(path).unwrap();
+
+ family.add_template(
+ Atom::from(name),
+ Some(file.bytes().map(|b| b.unwrap()).collect())
+ )
+ }
+}
+
+impl FontSource for TestFontSource {
+ fn get_font_instance(&mut self, _key: webrender_api::FontKey, _size: Au) -> webrender_api::FontInstanceKey {
+ webrender_api::FontInstanceKey(webrender_api::IdNamespace(0), 0)
+ }
+
+ fn find_font_template(
+ &mut self,
+ family: SingleFontFamily,
+ desc: FontTemplateDescriptor
+ ) -> Option<FontTemplateInfo> {
+ let handle = &self.handle;
+
+ self.find_font_count.set(self.find_font_count.get() + 1);
+ self.families
+ .get_mut(family.atom())
+ .and_then(|family| family.find_font_for_style(&desc, handle))
+ .map(|template| {
+ FontTemplateInfo {
+ font_template: template,
+ font_key: webrender_api::FontKey(webrender_api::IdNamespace(0), 0),
+ }
+ })
+ }
+
+ fn last_resort_font_template(&mut self, _desc: FontTemplateDescriptor) -> FontTemplateInfo {
+ unimplemented!();
+ }
+}
+
+fn style() -> FontStyleStruct {
+ let mut style = FontStyleStruct {
+ font_family: FontFamily::serif(),
+ font_style: FontStyle::Normal,
+ font_variant_caps: FontVariantCaps::Normal,
+ font_weight: FontWeight::normal(),
+ font_size: FontSize::medium(),
+ font_stretch: FontStretch::Normal,
+ hash: 0,
+ };
+ style.compute_font_hash();
+ style
+}
+
+fn font_family(names: Vec<&str>) -> FontFamily {
+ let names: Vec<SingleFontFamily> = names.into_iter().map(|name|
+ SingleFontFamily::FamilyName(FamilyName {
+ name: Atom::from(name),
+ syntax: FamilyNameSyntax::Quoted,
+ })
+ ).collect();
+
+ FontFamily(FontFamilyList::new(names.into_boxed_slice()))
+}
+
+#[test]
+fn test_font_group_is_cached_by_style() {
+ let source = TestFontSource::new();
+ let mut context = FontContext::new(source);
+
+ let style1 = style();
+
+ let mut style2 = style();
+ style2.set_font_style(FontStyle::Italic);
+
+ assert_eq!(
+ context.font_group(Arc::new(style1.clone())).as_ptr(),
+ context.font_group(Arc::new(style1.clone())).as_ptr(),
+ "the same font group should be returned for two styles with the same hash"
+ );
+
+ assert_ne!(
+ context.font_group(Arc::new(style1.clone())).as_ptr(),
+ context.font_group(Arc::new(style2.clone())).as_ptr(),
+ "different font groups should be returned for two styles with different hashes"
+ )
+}
+
+#[test]
+fn test_font_group_find_by_codepoint() {
+ let source = TestFontSource::new();
+ let count = source.find_font_count.clone();
+ let mut context = FontContext::new(source);
+
+ let mut style = style();
+ style.set_font_family(font_family(vec!("CSSTest ASCII", "CSSTest Basic")));
+
+ let group = context.font_group(Arc::new(style));
+
+ let font = group.borrow_mut().find_by_codepoint(&mut context, 'a').unwrap();
+ assert_eq!(font.borrow().handle.family_name(), "CSSTest ASCII");
+ assert_eq!(count.get(), 1, "only the first font in the list should have been loaded");
+
+ let font = group.borrow_mut().find_by_codepoint(&mut context, 'a').unwrap();
+ assert_eq!(font.borrow().handle.family_name(), "CSSTest ASCII");
+ assert_eq!(count.get(), 1, "we shouldn't load the same font a second time");
+
+ let font = group.borrow_mut().find_by_codepoint(&mut context, 'á').unwrap();
+ assert_eq!(font.borrow().handle.family_name(), "CSSTest Basic");
+ assert_eq!(count.get(), 2, "both fonts should now have been loaded");
+}
diff --git a/components/gfx/tests/support/CSSTest/LICENSE b/components/gfx/tests/support/CSSTest/LICENSE
new file mode 100644
index 00000000000..9b3c1a6df54
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/LICENSE
@@ -0,0 +1,94 @@
+Copyright (c) 2003-2008 SIL International (http://www.sil.org/),
+with Reserved Font Names "Gentium" and "SIL".
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 1 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that the font
+names of derivative works are changed. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/components/gfx/tests/support/CSSTest/README b/components/gfx/tests/support/CSSTest/README
new file mode 100644
index 00000000000..d4fe8fb50ae
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/README
@@ -0,0 +1,25 @@
+These fonts are a copy of the CSSTest fonts in web-platform-tests, so that we
+can use them for unit-testing our font code. Here is the README from
+web-platform-tests:
+
+-----
+
+These fonts were created to support the testing of the font features
+in CSS, and are required to run some of the tests for those features.
+
+The fonts are modified versions of Gentium Basic, licensed by SIL under
+the Open Font License which allows modifications as long as the terms
+of the license are met.
+
+The original fonts were used to create the family 'CSSTest Basic'. This
+family has four faces and can be used for testing bold / italics.
+A subsetted version of this font with only glyphs for basic ASCII
+characters is 'CSSTest ASCII'. This was used to make the other
+variations. Most of the modications are to the name table and character
+maps, for the most part glyphs were not modified.
+
+The fonts are available for download both individually and as a
+ZIP package below.
+
+The files test.html and test.xhtml test that the fonts have been
+correctly installed.
diff --git a/components/gfx/tests/support/CSSTest/csstest-ascii.ttf b/components/gfx/tests/support/CSSTest/csstest-ascii.ttf
new file mode 100644
index 00000000000..076788e9ce3
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-ascii.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-bold.ttf b/components/gfx/tests/support/CSSTest/csstest-basic-bold.ttf
new file mode 100644
index 00000000000..8c53e6fdd42
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-basic-bold.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttf b/components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttf
new file mode 100644
index 00000000000..5b58f1ffa24
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-basic-bolditalic.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-italic.ttf b/components/gfx/tests/support/CSSTest/csstest-basic-italic.ttf
new file mode 100644
index 00000000000..10926ce4e11
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-basic-italic.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-basic-regular.ttf b/components/gfx/tests/support/CSSTest/csstest-basic-regular.ttf
new file mode 100644
index 00000000000..c98d6130b68
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-basic-regular.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-fallback.ttf b/components/gfx/tests/support/CSSTest/csstest-fallback.ttf
new file mode 100644
index 00000000000..4f20f261f4d
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-fallback.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttf b/components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttf
new file mode 100644
index 00000000000..4bddbc2d16f
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-familyname-bold.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttf b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttf
new file mode 100644
index 00000000000..9f605f9190f
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyA.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttf b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttf
new file mode 100644
index 00000000000..0a3688c53ab
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyB.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttf b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttf
new file mode 100644
index 00000000000..feb463b15d9
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-familyname-funkyC.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-familyname.ttf b/components/gfx/tests/support/CSSTest/csstest-familyname.ttf
new file mode 100644
index 00000000000..5131280c2fe
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-familyname.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-verify.ttf b/components/gfx/tests/support/CSSTest/csstest-verify.ttf
new file mode 100644
index 00000000000..1d0b62a200b
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-verify.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-100.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-100.ttf
new file mode 100644
index 00000000000..964558a9499
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-100.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttf
new file mode 100644
index 00000000000..181d1a70e1d
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w1.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttf
new file mode 100644
index 00000000000..1751716d7a3
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w4.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttf
new file mode 100644
index 00000000000..f38fca9ff20
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w7.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttf
new file mode 100644
index 00000000000..7f34bbff829
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-1479-w9.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttf
new file mode 100644
index 00000000000..851f29b9f0b
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-15-w1.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttf
new file mode 100644
index 00000000000..cb06f50f905
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-15-w5.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-200.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-200.ttf
new file mode 100644
index 00000000000..306d8954986
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-200.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttf
new file mode 100644
index 00000000000..4c8533e658d
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-24-w2.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttf
new file mode 100644
index 00000000000..63cecb9aa30
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-24-w4.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttf
new file mode 100644
index 00000000000..99e03e90e67
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w2.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttf
new file mode 100644
index 00000000000..9300aeef4c1
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w5.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttf
new file mode 100644
index 00000000000..546489031e2
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w6.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttf
new file mode 100644
index 00000000000..66a1a06015c
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-2569-w9.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttf
new file mode 100644
index 00000000000..95b048816cf
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-258-w2.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttf
new file mode 100644
index 00000000000..3de6631d0bc
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-258-w5.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttf
new file mode 100644
index 00000000000..25d64dfb8c1
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-258-w8.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-300.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-300.ttf
new file mode 100644
index 00000000000..87fcd310aee
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-300.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttf
new file mode 100644
index 00000000000..fb071c03dfe
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w3.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttf
new file mode 100644
index 00000000000..2b9e530a816
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w5.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttf
new file mode 100644
index 00000000000..745a60ae25f
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w8.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttf
new file mode 100644
index 00000000000..e805f01d8fd
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-3589-w9.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-400.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-400.ttf
new file mode 100644
index 00000000000..9938a378bd6
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-400.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttf
new file mode 100644
index 00000000000..f6108ab2100
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-47-w4.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttf
new file mode 100644
index 00000000000..9496c5fdf27
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-47-w7.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-500.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-500.ttf
new file mode 100644
index 00000000000..0c132d28cdb
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-500.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-600.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-600.ttf
new file mode 100644
index 00000000000..ce776c01a2d
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-600.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-700.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-700.ttf
new file mode 100644
index 00000000000..156b0287a98
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-700.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-800.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-800.ttf
new file mode 100644
index 00000000000..0f41c304677
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-800.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-900.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-900.ttf
new file mode 100644
index 00000000000..97c8735125b
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-900.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttf
new file mode 100644
index 00000000000..dd1f6a9101c
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w1.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttf
new file mode 100644
index 00000000000..c42a506e21a
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w2.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttf
new file mode 100644
index 00000000000..f16a77b6edd
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w3.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttf
new file mode 100644
index 00000000000..8b1abae2f3f
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w4.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttf
new file mode 100644
index 00000000000..94aa9996827
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w5.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttf
new file mode 100644
index 00000000000..9badb99f500
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w6.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttf
new file mode 100644
index 00000000000..049d93d7698
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w7.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttf
new file mode 100644
index 00000000000..80169bf0715
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w8.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttf b/components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttf
new file mode 100644
index 00000000000..542e4ab199e
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights-full-w9.ttf
Binary files differ
diff --git a/components/gfx/tests/support/CSSTest/csstest-weights.ttf b/components/gfx/tests/support/CSSTest/csstest-weights.ttf
new file mode 100644
index 00000000000..b9c5a507f23
--- /dev/null
+++ b/components/gfx/tests/support/CSSTest/csstest-weights.ttf
Binary files differ