mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Print text on mac
This commit is contained in:
parent
8d2eb11582
commit
cbb26e64fb
2 changed files with 39 additions and 2 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 478f61bb68feea43c22c9b88f52393ea15908dae
|
Subproject commit a326b982dfde133ea558a1025deb9c14d88265d2
|
|
@ -172,9 +172,46 @@ fn get_cairo_face(buf: &[u8]) -> (*cairo_font_face_t, fn@()) {
|
||||||
(cface, dtor)
|
(cface, dtor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
mod cocoa {
|
||||||
|
use cocoa;
|
||||||
|
export cocoa;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn get_cairo_face(buf: &[u8]) -> (*cairo_font_face_t, fn@()) {
|
fn get_cairo_face(buf: &[u8]) -> (*cairo_font_face_t, fn@()) {
|
||||||
fail
|
import unsafe::reinterpret_cast;
|
||||||
|
import libc::size_t;
|
||||||
|
import cocoa::cocoa;
|
||||||
|
import cocoa::cg::cg::{
|
||||||
|
CGDataProviderCreateWithData,
|
||||||
|
CGDataProviderRelease,
|
||||||
|
CGFontCreateWithDataProvider,
|
||||||
|
CGFontRelease
|
||||||
|
};
|
||||||
|
import azure::cairo_quartz::bindgen::cairo_quartz_font_face_create_for_cgfont;
|
||||||
|
|
||||||
|
let mut dtor = fn@() { };
|
||||||
|
|
||||||
|
let fontprov = vec::as_buf(*buf) { |cbuf|
|
||||||
|
CGDataProviderCreateWithData(
|
||||||
|
null(),
|
||||||
|
unsafe { reinterpret_cast(cbuf) },
|
||||||
|
(*buf).len() as size_t,
|
||||||
|
null()
|
||||||
|
)
|
||||||
|
};
|
||||||
|
dtor = fn@(move dtor) { CGDataProviderRelease(fontprov); dtor() };
|
||||||
|
|
||||||
|
let cgfont = CGFontCreateWithDataProvider(fontprov);
|
||||||
|
if cgfont.is_null() { fail "could not create quartz font" }
|
||||||
|
dtor = fn@(move dtor) { CGFontRelease(cgfont); dtor() };
|
||||||
|
|
||||||
|
let cface = cairo_quartz_font_face_create_for_cgfont(cgfont);
|
||||||
|
assert cface.is_not_null(); // FIXME: error handling
|
||||||
|
dtor = fn@(move dtor) { cairo_font_face_destroy(cface); dtor() };
|
||||||
|
|
||||||
|
(cface, dtor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_test_font() -> font {
|
fn create_test_font() -> font {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue