mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #18322 - glennw:update-wr-fonts-2, r=emilio
Update WR (font instance API). WR now has a concept of font templates and font instances. This makes the WR font interfaces closer to Cairo and Gecko, and also makes some future performance optimizations possible. A font template is the font family, and data backing the font. A font instance is a reference to a font template and per-instance options, such as font size, anti-aliasing settings etc. To update Servo in a minimally invasive way, I added a new font cache call, that creates a font instance. This means that when a font is created, and doesn't exist in the cache there are now two calls to the font cache thread. We could refactor the font cache to make this work in one call, which we should do in the future. However, refactoring the font cache is a large chunk of work by itself. The extra call is only when a font doesn't already exist in the font context cache, so it should have minimal performance impact. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18322) <!-- Reviewable:end -->
This commit is contained in:
commit
f7d238d1f3
9 changed files with 92 additions and 102 deletions
|
@ -1,39 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
use cssparser::SourceLocation;
|
||||
use gfx::font_cache_thread::FontCacheThread;
|
||||
use ipc_channel::ipc;
|
||||
use style::computed_values::font_family::{FamilyName, FamilyNameSyntax};
|
||||
use style::font_face::{FontFaceRuleData, Source};
|
||||
|
||||
#[test]
|
||||
fn test_local_web_font() {
|
||||
let (inp_chan, _) = ipc::channel().unwrap();
|
||||
let (out_chan, out_receiver) = ipc::channel().unwrap();
|
||||
let font_cache_thread = FontCacheThread::new(inp_chan, None);
|
||||
let family_name = FamilyName {
|
||||
name: From::from("test family"),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
};
|
||||
let variant_name = FamilyName {
|
||||
name: From::from("test font face"),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
};
|
||||
let font_face_rule = FontFaceRuleData {
|
||||
family: Some(family_name.clone()),
|
||||
sources: Some(vec![Source::Local(variant_name)]),
|
||||
source_location: SourceLocation {
|
||||
line: 0,
|
||||
column: 0,
|
||||
},
|
||||
};
|
||||
|
||||
font_cache_thread.add_web_font(
|
||||
family_name,
|
||||
font_face_rule.font_face().unwrap().effective_sources(),
|
||||
out_chan);
|
||||
|
||||
assert_eq!(out_receiver.recv().unwrap(), ());
|
||||
}
|
|
@ -2,10 +2,6 @@
|
|||
* 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 cssparser;
|
||||
extern crate gfx;
|
||||
extern crate ipc_channel;
|
||||
extern crate style;
|
||||
|
||||
#[cfg(test)] mod font_cache_thread;
|
||||
#[cfg(test)] mod text_util;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue