mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
De-Cairo font handling.
This breaks Linux/Freetype.
This commit is contained in:
parent
aa8de5041b
commit
bc591ce94f
8 changed files with 28 additions and 82 deletions
|
@ -75,8 +75,10 @@ DEPS_libcss += \
|
||||||
# Platform-specific dependencies
|
# Platform-specific dependencies
|
||||||
ifeq ($(CFG_OSTYPE),darwin)
|
ifeq ($(CFG_OSTYPE),darwin)
|
||||||
DEPS_rust-azure += \
|
DEPS_rust-azure += \
|
||||||
rust-core-foundation \
|
|
||||||
rust-core-graphics \
|
rust-core-graphics \
|
||||||
|
rust-core-text \
|
||||||
|
rust-core-foundation \
|
||||||
|
skia \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
DEPS_rust-cairo += \
|
DEPS_rust-cairo += \
|
||||||
|
@ -105,6 +107,7 @@ DEPS_rust-core-text += \
|
||||||
DEPS_rust-layers += \
|
DEPS_rust-layers += \
|
||||||
rust-core-foundation \
|
rust-core-foundation \
|
||||||
rust-core-graphics \
|
rust-core-graphics \
|
||||||
|
rust-core-text \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 12723089ed7fbc5ff188558398190c2d1ffa5780
|
Subproject commit cc67646804d802bfab5bfbda1cd89dc1af0589fc
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6fde7833913c8152ac41f5584f4d7f2e59d0f59f
|
Subproject commit 7a82d824c50dd5647c120565acdbea6b00e51a40
|
|
@ -1,5 +1,4 @@
|
||||||
use azure::azure_hl::{DrawTarget};
|
use azure::azure_hl::{DrawTarget};
|
||||||
use cairo::cairo_hl::ImageSurface;
|
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use geom::rect::Rect;
|
use geom::rect::Rect;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ use text::{
|
||||||
TextRun,
|
TextRun,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use azure::azure_hl::CairoBackend;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
|
|
||||||
// FontHandle encapsulates access to the platform's font API,
|
// FontHandle encapsulates access to the platform's font API,
|
||||||
|
@ -290,38 +291,25 @@ impl Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
priv fn get_azure_font() -> AzScaledFontRef {
|
priv fn get_azure_font() -> AzScaledFontRef {
|
||||||
use libc::{c_int, c_double};
|
|
||||||
use azure::{
|
|
||||||
AzNativeFont,
|
|
||||||
AZ_NATIVE_FONT_CAIRO_FONT_FACE
|
|
||||||
};
|
|
||||||
use azure::bindgen::AzCreateScaledFontWithCairo;
|
|
||||||
use cairo::{cairo_font_face_t, cairo_scaled_font_t};
|
|
||||||
use cairo::bindgen::cairo_scaled_font_destroy;
|
|
||||||
|
|
||||||
// fast path: we've already created the azure font resource
|
// fast path: we've already created the azure font resource
|
||||||
match self.azure_font {
|
match self.azure_font {
|
||||||
Some(azfont) => { return azfont; },
|
Some(azfont) => return azfont,
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let nfont: AzNativeFont = {
|
let ct_font = &self.handle.ctfont;
|
||||||
mType: AZ_NATIVE_FONT_CAIRO_FONT_FACE,
|
let size = self.style.pt_size as AzFloat;
|
||||||
mFont: ptr::null()
|
let scaled_font = azure::scaled_font::ScaledFont::new(CairoBackend, ct_font, size);
|
||||||
};
|
|
||||||
|
|
||||||
// TODO(Issue #64): we should be able to remove cairo stepping
|
let azure_scaled_font;
|
||||||
// stones and manual memory management, and put them inside of
|
unsafe {
|
||||||
// azure_hl.rs and elsewhere instead.
|
azure_scaled_font = scaled_font.azure_scaled_font;
|
||||||
let cfont = get_cairo_font(&self);
|
cast::forget(move scaled_font);
|
||||||
// TODO: This should probably not even use cairo
|
}
|
||||||
let azfont = AzCreateScaledFontWithCairo(ptr::to_unsafe_ptr(&nfont), 1f as AzFloat, cfont);
|
|
||||||
assert azfont.is_not_null();
|
|
||||||
cairo_scaled_font_destroy(cfont);
|
|
||||||
|
|
||||||
self.azure_font = Some(azfont);
|
|
||||||
return azfont;
|
|
||||||
|
|
||||||
|
self.azure_font = Some(azure_scaled_font);
|
||||||
|
azure_scaled_font
|
||||||
|
/*
|
||||||
// TODO: these cairo-related things should be in rust-cairo.
|
// TODO: these cairo-related things should be in rust-cairo.
|
||||||
// creating a cairo font/face from a native font resource
|
// creating a cairo font/face from a native font resource
|
||||||
// should be part of the NativeFont API, not exposed here.
|
// should be part of the NativeFont API, not exposed here.
|
||||||
|
@ -334,54 +322,7 @@ impl Font {
|
||||||
// FIXME: error handling
|
// FIXME: error handling
|
||||||
return cface;
|
return cface;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
fn get_cairo_face(font: &Font) -> *cairo_font_face_t {
|
|
||||||
use cairo::cairo_quartz::bindgen::cairo_quartz_font_face_create_for_cgfont;
|
|
||||||
|
|
||||||
let cgfont = font.handle.cgfont;
|
|
||||||
let face = cairo_quartz_font_face_create_for_cgfont(cgfont);
|
|
||||||
// FIXME: error handling
|
|
||||||
return face;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_cairo_font(font: &Font) -> *cairo_scaled_font_t {
|
|
||||||
use cairo::cairo_matrix_t;
|
|
||||||
use cairo::bindgen::{cairo_matrix_init_identity,
|
|
||||||
cairo_matrix_scale,
|
|
||||||
cairo_font_options_create,
|
|
||||||
cairo_scaled_font_create,
|
|
||||||
cairo_font_options_destroy,
|
|
||||||
cairo_font_face_destroy};
|
|
||||||
|
|
||||||
// FIXME: error handling
|
|
||||||
|
|
||||||
let face = get_cairo_face(font);
|
|
||||||
|
|
||||||
let idmatrix: cairo_matrix_t = {
|
|
||||||
xx: 0 as c_double,
|
|
||||||
yx: 0 as c_double,
|
|
||||||
xy: 0 as c_double,
|
|
||||||
yy: 0 as c_double,
|
|
||||||
x0: 0 as c_double,
|
|
||||||
y0: 0 as c_double
|
|
||||||
};
|
|
||||||
cairo_matrix_init_identity(ptr::to_unsafe_ptr(&idmatrix));
|
|
||||||
|
|
||||||
let fontmatrix = idmatrix;
|
|
||||||
cairo_matrix_scale(ptr::to_unsafe_ptr(&fontmatrix),
|
|
||||||
font.style.pt_size as c_double,
|
|
||||||
font.style.pt_size as c_double);
|
|
||||||
let options = cairo_font_options_create();
|
|
||||||
let cfont = cairo_scaled_font_create(face,
|
|
||||||
ptr::to_unsafe_ptr(&fontmatrix),
|
|
||||||
ptr::to_unsafe_ptr(&idmatrix),
|
|
||||||
options);
|
|
||||||
cairo_font_options_destroy(options);
|
|
||||||
cairo_font_face_destroy(face);
|
|
||||||
|
|
||||||
return cfont;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ use image::base::Image;
|
||||||
use text::TextRun;
|
use text::TextRun;
|
||||||
use util::range::Range;
|
use util::range::Range;
|
||||||
|
|
||||||
use cairo::cairo_hl::ImageSurface;
|
|
||||||
use core::libc::types::common::c99::uint16_t;
|
use core::libc::types::common::c99::uint16_t;
|
||||||
use core::ptr::to_unsafe_ptr;
|
use core::ptr::to_unsafe_ptr;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use ShareGlContext = sharegl::platform::Context;
|
use ShareGlContext = sharegl::platform::Context;
|
||||||
use azure::azure_hl;
|
use azure::azure_hl;
|
||||||
use azure::azure_hl::{B8G8R8A8, CairoBackend, DataSourceSurface, DrawTarget, SourceSurfaceMethods};
|
use azure::azure_hl::{B8G8R8A8, CairoBackend, DataSourceSurface, DrawTarget};
|
||||||
use cairo::cairo_hl::ImageSurface;
|
use azure::azure_hl::{SourceSurfaceMethods};
|
||||||
use cairo::cairo_surface_t;
|
|
||||||
use core::util::replace;
|
use core::util::replace;
|
||||||
use dom::event::{Event, ResizeEvent};
|
use dom::event::{Event, ResizeEvent};
|
||||||
use dvec::DVec;
|
use dvec::DVec;
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
#[cfg(target_os="macos")]
|
||||||
|
extern mod core_graphics;
|
||||||
|
#[cfg(target_os="macos")]
|
||||||
|
extern mod core_text;
|
||||||
|
|
||||||
use comm::*;
|
use comm::*;
|
||||||
use option::swap_unwrap;
|
use option::swap_unwrap;
|
||||||
use platform::osmain;
|
use platform::osmain;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue