From 9bde1e9f2648b54a917b25277658b9eb7740edc9 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Thu, 25 Oct 2012 11:32:10 -0700 Subject: [PATCH] Split freetype bindings into rust-freetype submodule. --- .gitmodules | 3 +++ configure | 5 +++++ mk/sub.mk | 16 ++++++++++++++++ src/rust-azure | 2 +- src/rust-freetype | 1 + src/servo/text/font_cache.rs | 4 ++-- src/servo/text/native_font/ft_native_font.rs | 13 ++++++------- 7 files changed, 34 insertions(+), 10 deletions(-) create mode 160000 src/rust-freetype diff --git a/.gitmodules b/.gitmodules index ec2e48f9eda..5bee9a152ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -67,3 +67,6 @@ [submodule "src/rust-core-text"] path = src/rust-core-text url = git://github.com/mozilla-servo/rust-core-text.git +[submodule "src/rust-freetype"] + path = src/rust-freetype + url = git://github.com/mozilla-servo/rust-freetype.git diff --git a/configure b/configure index 2f3f5e4c035..003c2c52950 100755 --- a/configure +++ b/configure @@ -351,6 +351,11 @@ then CFG_SUBMODULES="rust-cocoa rust-io-surface rust-core-foundation rust-core-graphics rust-core-text ${CFG_SUBMODULES}" fi +if [ $CFG_OSTYPE = "linux" ] +then +CFG_SUBMODULES="rust-freetype ${CFG_SUBMODULES}" +fi + step_msg "making build directories" cd "${CFG_BUILD_DIR}" diff --git a/mk/sub.mk b/mk/sub.mk index d117a8ee082..315825b433e 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -1,3 +1,9 @@ +# NOTE: the make magic can only compute transitive build dependencies, +# not transitive link flags. So, if A -> B -> C, must add A as a dep +# of C so the correct -L/path/to/A flag is generated for building C. + +# NB. This should not be a problem once a real package system exists. + DEPS_rust-azure += \ rust-geom @@ -60,3 +66,13 @@ DEPS_rust-core-text += \ rust-core-foundation \ rust-core-graphics endif + +ifeq ($(CFG_OSTYPE),linux) +DEPS_rust-azure += \ + rust-freetype + +# See note at top of file +DEPS_rust-layers += \ + rust-freetype + +endif \ No newline at end of file diff --git a/src/rust-azure b/src/rust-azure index 702a173e7b2..ec3f31b7f36 160000 --- a/src/rust-azure +++ b/src/rust-azure @@ -1 +1 @@ -Subproject commit 702a173e7b2f0fa61a47205bd79da30d5522bfa8 +Subproject commit ec3f31b7f360d2f78343aec074b700ff2c8c3b3d diff --git a/src/rust-freetype b/src/rust-freetype new file mode 160000 index 00000000000..a524e86e580 --- /dev/null +++ b/src/rust-freetype @@ -0,0 +1 @@ +Subproject commit a524e86e58020b9a5d7832f87fa90988703d1e0a diff --git a/src/servo/text/font_cache.rs b/src/servo/text/font_cache.rs index 7ca04093434..adb0ce5356e 100644 --- a/src/servo/text/font_cache.rs +++ b/src/servo/text/font_cache.rs @@ -1,4 +1,5 @@ -export FontCache, native; +extern mod freetype; + use font::{Font, test_font_bin}; struct FontCache { @@ -50,7 +51,6 @@ fn create_font(lib: @FontCache, native_lib: &native::NativeFontCache) -> Result< #[cfg(target_os = "linux")] pub mod native { use ptr::{null, addr_of}; - use azure::freetype; use freetype::{FT_Library, FT_Error}; use freetype::bindgen::{FT_Init_FreeType, FT_Done_FreeType}; diff --git a/src/servo/text/native_font/ft_native_font.rs b/src/servo/text/native_font/ft_native_font.rs index cd947620f64..9cc75f171af 100644 --- a/src/servo/text/native_font/ft_native_font.rs +++ b/src/servo/text/native_font/ft_native_font.rs @@ -1,5 +1,5 @@ -#[legacy_exports]; -export FreeTypeNativeFont, with_test_native_font, create; + +extern mod freetype; use font::{FontMetrics, FractionalPixel}; @@ -11,7 +11,6 @@ use ptr::{addr_of, null}; use cast::reinterpret_cast; use glyph::GlyphIndex; use font::FontMetrics; -use azure::freetype; use freetype::{ FT_Error, FT_Library, FT_Face, FT_Long, FT_ULong, FT_Size, FT_SizeRec, FT_UInt, FT_GlyphSlot, FT_Size_Metrics, FT_FaceRec }; use freetype::bindgen::{ @@ -32,7 +31,7 @@ fn fixed_to_float_ft(f: i32) -> float { fixed_to_float(6, f) } -struct FreeTypeNativeFont { +pub struct FreeTypeNativeFont { /// The font binary. This must stay valid for the lifetime of the font buf: @~[u8], face: FT_Face, @@ -45,12 +44,12 @@ struct FreeTypeNativeFont { } } -fn FreeTypeNativeFont(face: FT_Face, buf: @~[u8]) -> FreeTypeNativeFont { +pub fn FreeTypeNativeFont(face: FT_Face, buf: @~[u8]) -> FreeTypeNativeFont { assert face.is_not_null(); FreeTypeNativeFont { buf: buf, face: face } } -impl FreeTypeNativeFont { +pub impl FreeTypeNativeFont { fn glyph_index(codepoint: char) -> Option { assert self.face.is_not_null(); @@ -155,7 +154,7 @@ impl FT_Error : FTErrorMethods { fn succeeded() -> bool { self == 0 as FT_Error } } -fn with_test_native_font(f: fn@(nf: &NativeFont)) { +pub fn with_test_native_font(f: fn@(nf: &NativeFont)) { use font::test_font_bin; use unwrap_result = result::unwrap;