aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian J. Burg <burg@cs.washington.edu>2012-11-08 15:23:28 -0800
committerBrian J. Burg <burg@cs.washington.edu>2012-11-08 15:23:28 -0800
commit577303514d8a20845dccf560c2d19d56d5e44451 (patch)
treec6e5a0daae60f2f24153ab56c6876c61ac83227f /src
parenteacf27263e07707c6b699785dfee8a7b39631bb7 (diff)
downloadservo-577303514d8a20845dccf560c2d19d56d5e44451.tar.gz
servo-577303514d8a20845dccf560c2d19d56d5e44451.zip
Hook up optional FontList instance to FontContext.
Diffstat (limited to 'src')
m---------src/rust-core-foundation0
m---------src/rust-core-text0
-rw-r--r--src/servo/gfx.rs2
-rw-r--r--src/servo/gfx/font.rs6
-rw-r--r--src/servo/gfx/font_context.rs9
-rw-r--r--src/servo/gfx/font_list.rs40
-rw-r--r--src/servo/gfx/native.rs3
-rw-r--r--src/servo/gfx/quartz/font_list.rs11
-rw-r--r--src/servo/gfx/render_task.rs2
-rw-r--r--src/servo/layout/layout_task.rs2
10 files changed, 60 insertions, 15 deletions
diff --git a/src/rust-core-foundation b/src/rust-core-foundation
-Subproject 22ff767266abfeeab508da705a4a75c23a77a29
+Subproject 925aad58aad897c8cf90377adc7c2fdbdb63d13
diff --git a/src/rust-core-text b/src/rust-core-text
-Subproject 03050d5d816462582c4506e1fb6f507b5c6653b
+Subproject c1450887c2e21a4cddfa57c4d3fc4d4eb02da42
diff --git a/src/servo/gfx.rs b/src/servo/gfx.rs
index 2b9cdcd2975..dde9fe83a45 100644
--- a/src/servo/gfx.rs
+++ b/src/servo/gfx.rs
@@ -12,11 +12,13 @@ pub use display_list::DisplayItem;
pub use display_list::DisplayList;
pub use font::Font;
pub use font::FontDescriptor;
+pub use font::FontFamily;
pub use font::FontGroup;
pub use font::FontSelector;
pub use font::FontStyle;
pub use font::RunMetrics;
pub use font_context::FontContext;
+pub use font_list::FontList;
pub use geometry::Au;
pub use render_context::RenderContext;
diff --git a/src/servo/gfx/font.rs b/src/servo/gfx/font.rs
index f1884379687..432d0768aba 100644
--- a/src/servo/gfx/font.rs
+++ b/src/servo/gfx/font.rs
@@ -148,9 +148,9 @@ pub enum FontSelector {
// TODO(Issue #181): use deriving for trivial cmp::Eq implementations
pub impl FontSelector : cmp::Eq {
pure fn eq(other: &FontSelector) -> bool {
- match (self, *other) {
- (SelectorStubDummy, SelectorStubDummy) => true,
- (SelectorPlatformName(a), SelectorPlatformName(b)) => a == b,
+ match (&self, other) {
+ (&SelectorStubDummy, &SelectorStubDummy) => true,
+ (&SelectorPlatformName(a), &SelectorPlatformName(b)) => a == b,
_ => false
}
}
diff --git a/src/servo/gfx/font_context.rs b/src/servo/gfx/font_context.rs
index 9fec4f2eead..e735f7ad6b8 100644
--- a/src/servo/gfx/font_context.rs
+++ b/src/servo/gfx/font_context.rs
@@ -3,6 +3,7 @@ use dvec::DVec;
use util::cache;
use gfx::{
FontDescriptor,
+ FontList,
FontSelector,
FontStyle,
};
@@ -51,15 +52,19 @@ pub impl FontContextHandle {
pub struct FontContext {
instance_cache: cache::MonoCache<FontDescriptor, @Font>,
+ font_list: Option<FontList>, // only needed by layout
handle: FontContextHandle,
}
pub impl FontContext {
- static fn new() -> FontContext {
+ static fn new(needs_font_list: bool) -> FontContext {
+ let handle = FontContextHandle::new();
+ let font_list = if needs_font_list { Some(FontList::new(&handle)) } else { None };
FontContext {
// TODO(Rust #3902): remove extraneous type parameters once they are inferred correctly.
instance_cache: cache::new::<FontDescriptor, @Font, cache::MonoCache<FontDescriptor, @Font>>(10),
- handle: FontContextHandle::new()
+ font_list: move font_list,
+ handle: move handle,
}
}
diff --git a/src/servo/gfx/font_list.rs b/src/servo/gfx/font_list.rs
index af4d4a0caa4..e7a75e8e655 100644
--- a/src/servo/gfx/font_list.rs
+++ b/src/servo/gfx/font_list.rs
@@ -1,3 +1,9 @@
+use gfx::{
+ FontFamily,
+};
+
+use dvec::DVec;
+
#[cfg(target_os = "macos")]
type FontListHandle/& = quartz::font_list::QuartzFontListHandle;
@@ -6,12 +12,38 @@ type FontListHandle/& = freetype::font_list::FreeTypeFontListHandle;
pub impl FontListHandle {
#[cfg(target_os = "macos")]
- static pub fn new() -> FontListHandle {
- quartz::font_list::QuartzFontListHandle::new()
+ static pub fn new(fctx: &native::FontContextHandle) -> Result<FontListHandle, ()> {
+ Ok(quartz::font_list::QuartzFontListHandle::new(fctx))
}
#[cfg(target_os = "linux")]
- static pub fn new() -> FontListHandle {
- freetype::font_list::FreeTypeFontListHandle::new()
+ static pub fn new(fctx: &native::FontContextHandle) -> Result<FontListHandle, ()> {
+ Ok(freetype::font_list::FreeTypeFontListHandle::new(fctx))
}
}
+
+pub struct FontList {
+ families: DVec<@FontFamily>,
+ handle: FontListHandle,
+}
+
+pub impl FontList {
+ static fn new(fctx: &native::FontContextHandle) -> FontList {
+ let handle = result::unwrap(FontListHandle::new(fctx));
+ let list = FontList {
+ handle: move handle,
+ families: DVec(),
+ };
+ list.refresh(fctx);
+ return move list;
+ }
+
+ priv fn refresh(fctx: &native::FontContextHandle) {
+ // TODO: don't refresh unless something actually changed.
+ // Does OSX have a notification for this event?
+ // It would be better to do piecemeal.
+ do self.families.swap |_old_families: ~[@FontFamily]| {
+ self.handle.get_available_families(fctx)
+ }
+ }
+} \ No newline at end of file
diff --git a/src/servo/gfx/native.rs b/src/servo/gfx/native.rs
index 9218c8fab88..50a7ee703eb 100644
--- a/src/servo/gfx/native.rs
+++ b/src/servo/gfx/native.rs
@@ -5,4 +5,5 @@ Note that you still must define each of the files as a module in
servo.rc. This is not ideal and may be changed in the future. */
pub use font::FontHandle;
-pub use font_context::FontContextHandle; \ No newline at end of file
+pub use font_context::FontContextHandle;
+pub use font_list::FontListHandle; \ No newline at end of file
diff --git a/src/servo/gfx/quartz/font_list.rs b/src/servo/gfx/quartz/font_list.rs
index eb429466be7..8c02bc64c77 100644
--- a/src/servo/gfx/quartz/font_list.rs
+++ b/src/servo/gfx/quartz/font_list.rs
@@ -5,7 +5,11 @@ use cf = core_foundation;
use cf::array::CFArray;
use ct = core_text;
use ct::font_collection::CTFontCollection;
-use ct::font_descriptor::{CTFontDescriptor, CTFontDescriptorRef};
+use ct::font_descriptor::{
+ CTFontDescriptor,
+ CTFontDescriptorRef,
+ debug_descriptor,
+};
use gfx::font::FontFamily;
@@ -16,15 +20,16 @@ pub struct QuartzFontListHandle {
}
pub impl QuartzFontListHandle {
- static pub fn new() -> QuartzFontListHandle {
+ static pub fn new(_fctx: &native::FontContextHandle) -> QuartzFontListHandle {
QuartzFontListHandle { collection: CTFontCollection::new() }
}
- fn get_available_families(_fctx: FontContext) -> ~[@FontFamily] {
+ fn get_available_families(_fctx: &native::FontContextHandle) -> ~[@FontFamily] {
// TODO: make a hashtable from family name to DVec<FontEntry>
let descriptors : CFArray<CTFontDescriptorRef, CTFontDescriptor>;
descriptors = self.collection.get_descriptors();
for descriptors.each |desc: &CTFontDescriptor| {
+ debug!("%?", { debug_descriptor(desc); () });
// TODO: for each descriptor, make a FontEntry.
// TODO: append FontEntry to hashtable value
}
diff --git a/src/servo/gfx/render_task.rs b/src/servo/gfx/render_task.rs
index 5afb0eb8fb5..ecc20a0a8c1 100644
--- a/src/servo/gfx/render_task.rs
+++ b/src/servo/gfx/render_task.rs
@@ -41,7 +41,7 @@ pub fn RenderTask<C: Compositor Send>(compositor: C) -> RenderTask {
port: po,
compositor: move compositor,
mut layer_buffer_set_port: Cell(move layer_buffer_set_port),
- font_ctx: @FontContext::new(),
+ font_ctx: @FontContext::new(false),
}.start();
}
}
diff --git a/src/servo/layout/layout_task.rs b/src/servo/layout/layout_task.rs
index 9eb615dac84..f77b5cdea71 100644
--- a/src/servo/layout/layout_task.rs
+++ b/src/servo/layout/layout_task.rs
@@ -89,7 +89,7 @@ fn Layout(render_task: RenderTask,
image_cache_task: ImageCacheTask,
from_content: comm::Port<Msg>) -> Layout {
- let fctx = @FontContext::new();
+ let fctx = @FontContext::new(true);
Layout {
render_task: render_task,