зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492880. Update Cargo lockfiles and re-vendor rust dependencies
This commit is contained in:
Родитель
bb303b7ca0
Коммит
e816372be4
|
@ -359,7 +359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "core-graphics"
|
||||
version = "0.16.0"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -370,11 +370,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "core-text"
|
||||
version = "11.0.0"
|
||||
version = "13.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -2641,8 +2641,8 @@ dependencies = [
|
|||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 11.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2670,7 +2670,7 @@ dependencies = [
|
|||
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2686,7 +2686,7 @@ dependencies = [
|
|||
"app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2855,8 +2855,8 @@ dependencies = [
|
|||
"checksum cookie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1465f8134efa296b4c19db34d909637cb2bf0f7aaf21299e23e18fa29ac557cf"
|
||||
"checksum core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7caa6cb9e76ddddbea09a03266d6b3bc98cd41e9fb9b017c473e7cca593ec25"
|
||||
"checksum core-foundation-sys 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2a53cce0ddcf7e7e1f998738d757d5a3bf08bf799a180e50ebe50d298f52f5a"
|
||||
"checksum core-graphics 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92801c908ea6301ae619ed842a72e01098085fc321b9c2f3f833dad555bba055"
|
||||
"checksum core-text 11.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "157ff38a92496dc676ce36d9124554e9ac66f1c1039f952690ac64f71cfa5968"
|
||||
"checksum core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62ceafe1622ffc9a332199096841d0ff9912ec8cf8f9cde01e254a7d5217cd10"
|
||||
"checksum core-text 13.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f3f46450d6f2397261af420b4ccce23807add2e45fa206410a03d66fb7f050ae"
|
||||
"checksum cose 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "72fa26cb151d3ae4b70f63d67d0fed57ce04220feafafbae7f503bef7aae590d"
|
||||
"checksum cose-c 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "49726015ab0ca765144fcca61e4a7a543a16b795a777fa53f554da2fffff9a94"
|
||||
"checksum crc 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bd5d02c0aac6bd68393ed69e00bbc2457f3e89075c6349db7189618dc4ddc1d7"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".travis.yml":"b71b9a6f84b9263b2b89be6ec90dff5920ee68cf9e5768d73ed71957de2d0670","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"e191715db0c5bf37d5981f2a3b7ae5d0e53ab9cc39f2438d31e798b1fbf3ddec","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"5faaadaf17d93c370a20f358be6c3f12958ab7d3f99ccc634421e28758fec88b","src/color_space.rs":"bada04ad391869474428070ad9ae5dbb5e7f5e03646226fab0b03e8e84240bfa","src/context.rs":"6cc8d083eea0d73ece30c1c405a74b43ca3f3a8f55917cdcd27c238a393f3de2","src/data_provider.rs":"258fef8d18ba4a79e7dbe7c23a41401924efa0c159e178f0bd9fa7c4ff9f131a","src/display.rs":"3ca38e1ff0200409c95941fcb64afa043310d1c0855c7614fd236c4f83e5a343","src/event.rs":"f2ade1c2c112bae7bc4f5df1eda63c13d1c32e5db255228f139ce17fb37c1a4b","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"63b7e50243a56254c800421df586abee59aead84f735f7df838ae04693aedf4b","src/geometry.rs":"b94e50a16b8540dc6f37bfe4b1549ac68974cd6ba6c0bbd9209559f8a46d86eb","src/image.rs":"40e744f28ef338b4c0138e05e0e191411518611bedb19deea2aa3a6e59f36567","src/lib.rs":"19d5e558cec5596d546f1753529a8e3cf951993f4500ee12fad0d7eb2dc86bc8","src/path.rs":"405032914ef806ac2d2e0ccda5987ed3176bfec0e2e8bd409b176a9c23f49885","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"27e00f7ad7645af05014f35939128833456cac766a2978c5da295c3757708a86"},"package":"92801c908ea6301ae619ed842a72e01098085fc321b9c2f3f833dad555bba055"}
|
||||
{"files":{".travis.yml":"b71b9a6f84b9263b2b89be6ec90dff5920ee68cf9e5768d73ed71957de2d0670","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"c30c4f657ed844adb3f412f758ce2bff9c62b83c8ec844cc447e24d785d18dba","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"4a45abeb1e684e30bb361dfa7db59189423348e18d310cbae694b7c8c57cd86a","src/base.rs":"5faaadaf17d93c370a20f358be6c3f12958ab7d3f99ccc634421e28758fec88b","src/color.rs":"b054b38b507733c8c3f5af981483c54836e8a7499a6d1a22244fb58312824acb","src/color_space.rs":"b3d7ee8a21703c789160867cb8eb2188bd1daa193e3d030f21adb6f1a6f872de","src/context.rs":"6b14ec712e5d0af4af6beb0cb1a998bf1262ec6ab6ad2b3efad9e0362ade83c9","src/data_provider.rs":"22614a6ce7f857dec33e6d2dc01261b71b1bc5d5609a54ee55e04c049670c072","src/display.rs":"5b04d1fded021fc1eecb89b6350a66f6668e802b51e75cf69892ca082257443c","src/event.rs":"f2ade1c2c112bae7bc4f5df1eda63c13d1c32e5db255228f139ce17fb37c1a4b","src/event_source.rs":"d55a4f5b5e62789325028febc51bbf54c74b15ab1a4e70c6ad749a2f9753e081","src/font.rs":"63b7e50243a56254c800421df586abee59aead84f735f7df838ae04693aedf4b","src/geometry.rs":"cdeb9624df601d235bcc34d46e35bea302079ce1e3668253356a618486693a9f","src/image.rs":"0af720ee020fb1c6a2f4b1ce49e3d27f8f21f0be6b81ba4b9c824f87564efa58","src/lib.rs":"03628fc67576f6948bb803a53fb147c520b264eaba684e37d26cd1b0197ebf30","src/path.rs":"c429afeaed999b02ac00f89a867b5fc64f1e223039079a4e0529306b734ff117","src/private.rs":"da3fd61338bab2d8e26aa5433b2e18ecd2a0a408c62e1ac2b33a0f87f2dad88a","src/sys.rs":"cc90b690f172da51a87ffb234f6e74a9f501c4f1630d7b51fa2d5846e80fc164"},"package":"62ceafe1622ffc9a332199096841d0ff9912ec8cf8f9cde01e254a7d5217cd10"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "core-graphics"
|
||||
version = "0.16.0"
|
||||
version = "0.17.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to Core Graphics for OS X"
|
||||
homepage = "https://github.com/servo/core-graphics-rs"
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core_foundation::base::{CFTypeID};
|
||||
use base::CGFloat;
|
||||
use core_foundation::base::TCFType;
|
||||
use super::sys::{CGColorRef};
|
||||
|
||||
declare_TCFType!{
|
||||
CGColor, CGColorRef
|
||||
}
|
||||
impl_TCFType!(CGColor, CGColorRef, CGColorGetTypeID);
|
||||
|
||||
impl CGColor {
|
||||
pub fn rgb(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> Self {
|
||||
unsafe {
|
||||
let ptr = CGColorCreateGenericRGB(red, green, blue, alpha);
|
||||
CGColor::wrap_under_create_rule(ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
extern {
|
||||
fn CGColorCreateGenericRGB(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> ::sys::CGColorRef;
|
||||
fn CGColorGetTypeID() -> CFTypeID;
|
||||
}
|
|
@ -34,12 +34,21 @@ impl CGColorSpace {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn create_device_rgb() -> CGColorSpace {
|
||||
unsafe {
|
||||
let result = CGColorSpaceCreateDeviceRGB();
|
||||
CGColorSpace::from_ptr(result)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn create_device_gray() -> CGColorSpace {
|
||||
unsafe {
|
||||
let result = CGColorSpaceCreateDeviceGray();
|
||||
CGColorSpace::from_ptr(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
|
@ -53,6 +62,7 @@ extern {
|
|||
pub static kCGColorSpaceGenericGrayGamma2_2: CFStringRef;
|
||||
|
||||
fn CGColorSpaceCreateDeviceRGB() -> ::sys::CGColorSpaceRef;
|
||||
fn CGColorSpaceCreateDeviceGray() -> ::sys::CGColorSpaceRef;
|
||||
fn CGColorSpaceCreateWithName(name: CFStringRef) -> ::sys::CGColorSpaceRef;
|
||||
fn CGColorSpaceGetTypeID() -> CFTypeID;
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
use base::CGFloat;
|
||||
use color_space::CGColorSpace;
|
||||
use core_foundation::base::{CFRelease, CFRetain, CFTypeID};
|
||||
use core_foundation::base::{ToVoid, CFRelease, CFRetain, CFTypeID};
|
||||
use font::{CGFont, CGGlyph};
|
||||
use geometry::CGPoint;
|
||||
use color::CGColor;
|
||||
use path::CGPathRef;
|
||||
use libc::{c_int, size_t};
|
||||
use std::os::raw::c_void;
|
||||
|
||||
|
@ -20,7 +22,41 @@ use std::ptr;
|
|||
use std::slice;
|
||||
use geometry::{CGAffineTransform, CGRect};
|
||||
use image::CGImage;
|
||||
use foreign_types::ForeignType;
|
||||
use foreign_types::{ForeignType, ForeignTypeRef};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum CGBlendMode {
|
||||
Normal = 0,
|
||||
Multiply,
|
||||
Screen,
|
||||
Overlay,
|
||||
Darken,
|
||||
Lighten,
|
||||
ColorDodge,
|
||||
ColorBurn,
|
||||
SoftLight,
|
||||
HardLight,
|
||||
Difference,
|
||||
Exclusion,
|
||||
Hue,
|
||||
Saturation,
|
||||
Color,
|
||||
Luminosity,
|
||||
// 10.5 and up:
|
||||
Clear,
|
||||
Copy,
|
||||
SourceIn,
|
||||
SourceOut,
|
||||
SourceAtop,
|
||||
DestinationOver,
|
||||
DestinationIn,
|
||||
DestinationOut,
|
||||
DestinationAtop,
|
||||
Xor,
|
||||
PlusDarker,
|
||||
PlusLighter,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum CGTextDrawingMode {
|
||||
|
@ -77,6 +113,14 @@ impl CGContext {
|
|||
(self.height() * self.bytes_per_row()) as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CGContextRef {
|
||||
pub fn flush(&self) {
|
||||
unsafe {
|
||||
CGContextFlush(self.as_ptr())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn width(&self) -> size_t {
|
||||
unsafe {
|
||||
|
@ -96,12 +140,30 @@ impl CGContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_fill_color(&self, color: &CGColor) {
|
||||
unsafe {
|
||||
CGContextSetFillColorWithColor(self.as_ptr(), color.to_void());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_rgb_fill_color(&self, red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {
|
||||
unsafe {
|
||||
CGContextSetRGBFillColor(self.as_ptr(), red, green, blue, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_gray_fill_color(&self, gray: CGFloat, alpha: CGFloat) {
|
||||
unsafe {
|
||||
CGContextSetGrayFillColor(self.as_ptr(), gray, alpha)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_blend_mode(&self, blend_mode: CGBlendMode) {
|
||||
unsafe {
|
||||
CGContextSetBlendMode(self.as_ptr(), blend_mode)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_allows_font_smoothing(&self, allows_font_smoothing: bool) {
|
||||
unsafe {
|
||||
CGContextSetAllowsFontSmoothing(self.as_ptr(), allows_font_smoothing)
|
||||
|
@ -162,6 +224,24 @@ impl CGContext {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn add_path(&self, path: &CGPathRef) {
|
||||
unsafe {
|
||||
CGContextAddPath(self.as_ptr(), path.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close_path(&self) {
|
||||
unsafe {
|
||||
CGContextClosePath(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fill_path(&self) {
|
||||
unsafe {
|
||||
CGContextFillPath(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fill_rect(&self, rect: CGRect) {
|
||||
unsafe {
|
||||
CGContextFillRect(self.as_ptr(), rect)
|
||||
|
@ -210,6 +290,30 @@ impl CGContext {
|
|||
count)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn save(&self) {
|
||||
unsafe {
|
||||
CGContextSaveGState(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn restore(&self) {
|
||||
unsafe {
|
||||
CGContextRestoreGState(self.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn translate(&self, tx: CGFloat, ty: CGFloat) {
|
||||
unsafe {
|
||||
CGContextTranslateCTM(self.as_ptr(), tx, ty);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scale(&self, sx: CGFloat, sy: CGFloat) {
|
||||
unsafe {
|
||||
CGContextScaleCTM(self.as_ptr(), sx, sy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -252,6 +356,8 @@ extern {
|
|||
fn CGBitmapContextGetBytesPerRow(context: ::sys::CGContextRef) -> size_t;
|
||||
fn CGBitmapContextCreateImage(context: ::sys::CGContextRef) -> ::sys::CGImageRef;
|
||||
fn CGContextGetTypeID() -> CFTypeID;
|
||||
fn CGContextFlush(c: ::sys::CGContextRef);
|
||||
fn CGContextSetBlendMode(c: ::sys::CGContextRef, blendMode: CGBlendMode);
|
||||
fn CGContextSetAllowsFontSmoothing(c: ::sys::CGContextRef, allowsFontSmoothing: bool);
|
||||
fn CGContextSetShouldSmoothFonts(c: ::sys::CGContextRef, shouldSmoothFonts: bool);
|
||||
fn CGContextSetFontSmoothingStyle(c: ::sys::CGContextRef, style: c_int);
|
||||
|
@ -266,11 +372,16 @@ extern {
|
|||
fn CGContextSetShouldSubpixelPositionFonts(c: ::sys::CGContextRef,
|
||||
shouldSubpixelPositionFonts: bool);
|
||||
fn CGContextSetTextDrawingMode(c: ::sys::CGContextRef, mode: CGTextDrawingMode);
|
||||
fn CGContextSetFillColorWithColor(c: ::sys::CGContextRef, color: *const c_void);
|
||||
fn CGContextAddPath(c: ::sys::CGContextRef, path: ::sys::CGPathRef);
|
||||
fn CGContextClosePath(c: ::sys::CGContextRef);
|
||||
fn CGContextFillPath(c: ::sys::CGContextRef);
|
||||
fn CGContextSetRGBFillColor(context: ::sys::CGContextRef,
|
||||
red: CGFloat,
|
||||
green: CGFloat,
|
||||
blue: CGFloat,
|
||||
alpha: CGFloat);
|
||||
fn CGContextSetGrayFillColor(context: ::sys::CGContextRef, gray: CGFloat, alpha: CGFloat);
|
||||
fn CGContextFillRect(context: ::sys::CGContextRef,
|
||||
rect: CGRect);
|
||||
fn CGContextDrawImage(c: ::sys::CGContextRef, rect: CGRect, image: ::sys::CGImageRef);
|
||||
|
@ -281,5 +392,10 @@ extern {
|
|||
glyphs: *const CGGlyph,
|
||||
positions: *const CGPoint,
|
||||
count: size_t);
|
||||
|
||||
fn CGContextSaveGState(c: ::sys::CGContextRef);
|
||||
fn CGContextRestoreGState(c: ::sys::CGContextRef);
|
||||
fn CGContextTranslateCTM(c: ::sys::CGContextRef, tx: CGFloat, ty: CGFloat);
|
||||
fn CGContextScaleCTM(c: ::sys::CGContextRef, sx: CGFloat, sy: CGFloat);
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,21 @@ impl CGDataProvider {
|
|||
let result = CGDataProviderCreateWithData(ptr::null_mut(), ptr, len, None);
|
||||
CGDataProvider::from_ptr(result)
|
||||
}
|
||||
|
||||
/// Creates a data provider from the given raw pointer, length, and destructor function.
|
||||
///
|
||||
/// This is double-boxed because the Core Text API requires that the userdata be a single
|
||||
/// pointer.
|
||||
pub unsafe fn from_custom_data(custom_data: Box<Box<CustomData>>) -> Self {
|
||||
let (ptr, len) = (custom_data.ptr() as *const c_void, custom_data.len());
|
||||
let userdata = mem::transmute::<Box<Box<CustomData>>, &mut c_void>(custom_data);
|
||||
let data_provider = CGDataProviderCreateWithData(userdata, ptr, len, Some(release));
|
||||
return CGDataProvider::from_ptr(data_provider);
|
||||
|
||||
unsafe extern "C" fn release(info: *mut c_void, _: *const c_void, _: size_t) {
|
||||
drop(mem::transmute::<*mut c_void, Box<Box<CustomData>>>(info))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CGDataProviderRef {
|
||||
|
@ -81,6 +96,16 @@ impl CGDataProviderRef {
|
|||
}
|
||||
}
|
||||
|
||||
/// Encapsulates custom data that can be wrapped.
|
||||
pub trait CustomData {
|
||||
/// Returns a pointer to the start of the custom data. This pointer *must not change* during
|
||||
/// the lifespan of this CustomData.
|
||||
unsafe fn ptr(&self) -> *const u8;
|
||||
/// Returns the length of this custom data. This value must not change during the lifespan of
|
||||
/// this CustomData.
|
||||
unsafe fn len(&self) -> usize;
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
extern {
|
||||
fn CGDataProviderCopyData(provider: ::sys::CGDataProviderRef) -> CFDataRef;
|
||||
|
|
|
@ -11,9 +11,12 @@
|
|||
|
||||
use libc;
|
||||
use std::ptr;
|
||||
use std::ops::Deref;
|
||||
|
||||
pub use base::{CGError, boolean_t};
|
||||
pub use geometry::{CGRect, CGPoint, CGSize};
|
||||
|
||||
use core_foundation::string::{CFString, CFStringRef};
|
||||
use core_foundation::base::{CFRetain, TCFType};
|
||||
use image::CGImage;
|
||||
use foreign_types::ForeignType;
|
||||
|
@ -42,11 +45,58 @@ pub const kCGWindowImageOnlyShadows: CGWindowImageOption = 1 << 2;
|
|||
pub const kCGWindowImageBestResolution: CGWindowImageOption = 1 << 3;
|
||||
pub const kCGWindowImageNominalResolution: CGWindowImageOption = 1 << 4;
|
||||
|
||||
pub const kDisplayModeValidFlag: u32 = 0x00000001;
|
||||
pub const kDisplayModeSafeFlag: u32 = 0x00000002;
|
||||
pub const kDisplayModeDefaultFlag: u32 = 0x00000004;
|
||||
pub const kDisplayModeAlwaysShowFlag: u32 = 0x00000008;
|
||||
pub const kDisplayModeNeverShowFlag: u32 = 0x00000080;
|
||||
pub const kDisplayModeNotResizeFlag: u32 = 0x00000010;
|
||||
pub const kDisplayModeRequiresPanFlag: u32 = 0x00000020;
|
||||
pub const kDisplayModeInterlacedFlag: u32 = 0x00000040;
|
||||
pub const kDisplayModeSimulscanFlag: u32 = 0x00000100;
|
||||
pub const kDisplayModeBuiltInFlag: u32 = 0x00000400;
|
||||
pub const kDisplayModeNotPresetFlag: u32 = 0x00000200;
|
||||
pub const kDisplayModeStretchedFlag: u32 = 0x00000800;
|
||||
pub const kDisplayModeNotGraphicsQualityFlag: u32 = 0x00001000;
|
||||
pub const kDisplayModeValidateAgainstDisplay: u32 = 0x00002000;
|
||||
pub const kDisplayModeTelevisionFlag: u32 = 0x00100000;
|
||||
pub const kDisplayModeValidForMirroringFlag: u32 = 0x00200000;
|
||||
pub const kDisplayModeAcceleratorBackedFlag: u32 = 0x00400000;
|
||||
pub const kDisplayModeValidForHiResFlag: u32 = 0x00800000;
|
||||
pub const kDisplayModeValidForAirPlayFlag: u32 = 0x01000000;
|
||||
pub const kDisplayModeNativeFlag: u32 = 0x02000000;
|
||||
|
||||
pub const kDisplayModeSafetyFlags: u32 = 0x00000007;
|
||||
|
||||
pub const IO1BitIndexedPixels: &str = "P";
|
||||
pub const IO2BitIndexedPixels: &str = "PP";
|
||||
pub const IO4BitIndexedPixels: &str = "PPPP";
|
||||
pub const IO8BitIndexedPixels: &str = "PPPPPPPP";
|
||||
pub const IO16BitDirectPixels: &str = "-RRRRRGGGGGBBBBB";
|
||||
pub const IO32BitDirectPixels: &str = "--------RRRRRRRRGGGGGGGGBBBBBBBB";
|
||||
pub const kIO30BitDirectPixels: &str = "--RRRRRRRRRRGGGGGGGGGGBBBBBBBBBB";
|
||||
pub const kIO64BitDirectPixels: &str = "-16R16G16B16";
|
||||
pub const kIO16BitFloatPixels: &str = "-16FR16FG16FB16";
|
||||
pub const kIO32BitFloatPixels: &str = "-32FR32FG32FB32";
|
||||
pub const IOYUV422Pixels: &str = "Y4U2V2";
|
||||
pub const IO8BitOverlayPixels: &str = "O8";
|
||||
|
||||
|
||||
pub use core_foundation::dictionary::{ CFDictionary, CFDictionaryRef, CFDictionaryGetValueIfPresent };
|
||||
pub use core_foundation::array::{ CFArray, CFArrayRef };
|
||||
pub use core_foundation::array::{ CFArrayGetCount, CFArrayGetValueAtIndex };
|
||||
pub use core_foundation::base::{ CFIndex, CFRelease, CFTypeRef };
|
||||
|
||||
pub type CGDisplayConfigRef = *mut libc::c_void;
|
||||
|
||||
#[repr(u32)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum CGConfigureOption {
|
||||
ConfigureForAppOnly = 0,
|
||||
ConfigureForSession = 1,
|
||||
ConfigurePermanently = 2,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct CGDisplay {
|
||||
pub id: CGDirectDisplayID,
|
||||
|
@ -92,6 +142,64 @@ impl CGDisplay {
|
|||
}
|
||||
}
|
||||
|
||||
/// Begins a new set of display configuration changes.
|
||||
pub fn begin_configuration(&self) -> Result<CGDisplayConfigRef, CGError> {
|
||||
unsafe {
|
||||
let mut config_ref: CGDisplayConfigRef = ptr::null_mut();
|
||||
let result = CGBeginDisplayConfiguration(&mut config_ref);
|
||||
if result == 0 {
|
||||
Ok(config_ref)
|
||||
} else {
|
||||
Err(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Cancels a set of display configuration changes.
|
||||
pub fn cancel_configuration(&self, config_ref: &CGDisplayConfigRef) -> Result<(), CGError> {
|
||||
let result = unsafe { CGCancelDisplayConfiguration(*config_ref) };
|
||||
if result == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Completes a set of display configuration changes.
|
||||
pub fn complete_configuration(
|
||||
&self,
|
||||
config_ref: &CGDisplayConfigRef,
|
||||
option: CGConfigureOption,
|
||||
) -> Result<(), CGError> {
|
||||
let result = unsafe { CGCompleteDisplayConfiguration(*config_ref, option) };
|
||||
if result == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Configures the display mode of a display.
|
||||
pub fn configure_display_with_display_mode(
|
||||
&self,
|
||||
config_ref: &CGDisplayConfigRef,
|
||||
display_mode: &CGDisplayMode,
|
||||
) -> Result<(), CGError> {
|
||||
let result = unsafe {
|
||||
CGConfigureDisplayWithDisplayMode(
|
||||
*config_ref,
|
||||
self.id,
|
||||
display_mode.as_ptr(),
|
||||
ptr::null(),
|
||||
)
|
||||
};
|
||||
if result == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(result)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an image containing the contents of the specified display.
|
||||
#[inline]
|
||||
pub fn image(&self) -> Option<CGImage> {
|
||||
|
@ -373,21 +481,52 @@ impl CGDisplay {
|
|||
}
|
||||
|
||||
impl CGDisplayMode {
|
||||
/// Returns all display modes for the specified display id.
|
||||
pub fn all_display_modes(
|
||||
display_id: CGDirectDisplayID,
|
||||
options: CFDictionaryRef,
|
||||
) -> Option<Vec<CGDisplayMode>> {
|
||||
let array_opt: Option<CFArray> = unsafe {
|
||||
let array_ref = CGDisplayCopyAllDisplayModes(display_id, options);
|
||||
if array_ref != ptr::null() {
|
||||
Some(CFArray::wrap_under_create_rule(array_ref))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
match array_opt {
|
||||
Some(modes) => {
|
||||
let vec: Vec<CGDisplayMode> = modes
|
||||
.into_iter()
|
||||
.map(|value0| {
|
||||
let x = *value0.deref() as *mut ::sys::CGDisplayMode;
|
||||
unsafe { CGDisplayMode::from_ptr(x) }
|
||||
}).collect();
|
||||
Some(vec)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the height of the specified display mode.
|
||||
#[inline]
|
||||
pub fn height(&self) -> u64 {
|
||||
unsafe { CGDisplayModeGetHeight(self.as_ptr()) as u64 }
|
||||
}
|
||||
|
||||
/// Returns the width of the specified display mode.
|
||||
#[inline]
|
||||
pub fn width(&self) -> u64 {
|
||||
unsafe { CGDisplayModeGetWidth(self.as_ptr()) as u64 }
|
||||
}
|
||||
|
||||
/// Returns the pixel height of the specified display mode.
|
||||
#[inline]
|
||||
pub fn pixel_height(&self) -> u64 {
|
||||
unsafe { CGDisplayModeGetPixelHeight(self.as_ptr()) as u64 }
|
||||
}
|
||||
|
||||
/// Returns the pixel width of the specified display mode.
|
||||
#[inline]
|
||||
pub fn pixel_width(&self) -> u64 {
|
||||
unsafe { CGDisplayModeGetPixelWidth(self.as_ptr()) as u64 }
|
||||
|
@ -397,6 +536,42 @@ impl CGDisplayMode {
|
|||
pub fn refresh_rate(&self) -> f64 {
|
||||
unsafe { CGDisplayModeGetRefreshRate(self.as_ptr()) }
|
||||
}
|
||||
|
||||
/// Returns the I/O Kit flags of the specified display mode.
|
||||
#[inline]
|
||||
pub fn io_flags(&self) -> u32 {
|
||||
unsafe { CGDisplayModeGetIOFlags(self.as_ptr()) as u32 }
|
||||
}
|
||||
|
||||
/// Returns the pixel encoding of the specified display mode.
|
||||
#[inline]
|
||||
pub fn pixel_encoding(&self) -> CFString {
|
||||
unsafe { CFString::wrap_under_create_rule(CGDisplayModeCopyPixelEncoding(self.as_ptr())) }
|
||||
}
|
||||
|
||||
/// Returns the number of bits per pixel of the specified display mode.
|
||||
pub fn bit_depth(&self) -> usize {
|
||||
let pixel_encoding = self.pixel_encoding().to_string();
|
||||
// my numerical representation for kIO16BitFloatPixels and kIO32bitFloatPixels
|
||||
// are made up and possibly non-sensical
|
||||
if pixel_encoding.eq_ignore_ascii_case(kIO32BitFloatPixels) {
|
||||
96
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(kIO64BitDirectPixels) {
|
||||
64
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(kIO16BitFloatPixels) {
|
||||
48
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(IO32BitDirectPixels) {
|
||||
32
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(kIO30BitDirectPixels) {
|
||||
30
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(IO16BitDirectPixels) {
|
||||
16
|
||||
} else if pixel_encoding.eq_ignore_ascii_case(IO8BitIndexedPixels) {
|
||||
8
|
||||
}else{
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
|
@ -404,6 +579,8 @@ extern "C" {
|
|||
pub static CGRectNull: CGRect;
|
||||
pub static CGRectInfinite: CGRect;
|
||||
|
||||
pub static kCGDisplayShowDuplicateLowResolutionModes: CFStringRef;
|
||||
|
||||
pub fn CGDisplayModeRelease(mode: ::sys::CGDisplayModeRef);
|
||||
|
||||
pub fn CGMainDisplayID() -> CGDirectDisplayID;
|
||||
|
@ -441,12 +618,32 @@ extern "C" {
|
|||
pub fn CGDisplayBounds(display: CGDirectDisplayID) -> CGRect;
|
||||
pub fn CGDisplayCreateImage(display: CGDirectDisplayID) -> ::sys::CGImageRef;
|
||||
|
||||
pub fn CGBeginDisplayConfiguration(config: *const CGDisplayConfigRef) -> CGError;
|
||||
pub fn CGCancelDisplayConfiguration(config: CGDisplayConfigRef) -> CGError;
|
||||
pub fn CGCompleteDisplayConfiguration(
|
||||
config: CGDisplayConfigRef,
|
||||
option: CGConfigureOption,
|
||||
) -> CGError;
|
||||
pub fn CGConfigureDisplayWithDisplayMode(
|
||||
config: CGDisplayConfigRef,
|
||||
display: CGDirectDisplayID,
|
||||
mode: ::sys::CGDisplayModeRef,
|
||||
options: CFDictionaryRef,
|
||||
) -> CGError;
|
||||
|
||||
pub fn CGDisplayCopyDisplayMode(display: CGDirectDisplayID) -> ::sys::CGDisplayModeRef;
|
||||
pub fn CGDisplayModeGetHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
|
||||
pub fn CGDisplayModeGetWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
|
||||
pub fn CGDisplayModeGetPixelHeight(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
|
||||
pub fn CGDisplayModeGetPixelWidth(mode: ::sys::CGDisplayModeRef) -> libc::size_t;
|
||||
pub fn CGDisplayModeGetRefreshRate(mode: ::sys::CGDisplayModeRef) -> libc::c_double;
|
||||
pub fn CGDisplayModeGetIOFlags(mode: ::sys::CGDisplayModeRef) -> libc::uint32_t;
|
||||
pub fn CGDisplayModeCopyPixelEncoding(mode: ::sys::CGDisplayModeRef) -> CFStringRef;
|
||||
|
||||
pub fn CGDisplayCopyAllDisplayModes(
|
||||
display: CGDirectDisplayID,
|
||||
options: CFDictionaryRef,
|
||||
) -> CFArrayRef;
|
||||
|
||||
// mouse stuff
|
||||
pub fn CGDisplayHideCursor(display: CGDirectDisplayID) -> CGError;
|
||||
|
|
|
@ -140,6 +140,15 @@ impl CGRect {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for CGRect {
|
||||
#[inline]
|
||||
fn eq(&self, other: &CGRect) -> bool {
|
||||
unsafe {
|
||||
ffi::CGRectEqualToRect(*self, *other) != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct CGAffineTransform {
|
||||
|
@ -184,6 +193,7 @@ mod ffi {
|
|||
rect: *mut CGRect) -> boolean_t;
|
||||
pub fn CGRectIsEmpty(rect: CGRect) -> boolean_t;
|
||||
pub fn CGRectIntersectsRect(rect1: CGRect, rect2: CGRect) -> boolean_t;
|
||||
pub fn CGRectEqualToRect(rect1: CGRect, rect2: CGRect) -> boolean_t;
|
||||
|
||||
pub fn CGAffineTransformInvert(t: CGAffineTransform) -> CGAffineTransform;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use core_foundation::base::{CFRetain, CFTypeID};
|
|||
use core_foundation::data::CFData;
|
||||
use color_space::CGColorSpace;
|
||||
use data_provider::{CGDataProviderRef, CGDataProvider};
|
||||
use geometry::CGRect;
|
||||
use libc::size_t;
|
||||
use foreign_types::{ForeignType, ForeignTypeRef};
|
||||
|
||||
|
@ -121,6 +122,17 @@ impl CGImageRef {
|
|||
};
|
||||
data_provider.copy_data()
|
||||
}
|
||||
|
||||
/// Returns a cropped image. If the `rect` specifies a rectangle which lies outside of the
|
||||
/// image bounds, the `None` is returned.
|
||||
pub fn cropped(&self, rect: CGRect) -> Option<CGImage> {
|
||||
let image_ptr = unsafe { CGImageCreateWithImageInRect(self.as_ptr(), rect) };
|
||||
if !image_ptr.is_null() {
|
||||
Some(unsafe { CGImage::from_ptr(image_ptr) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
|
@ -146,6 +158,7 @@ extern {
|
|||
shouldInterpolate: bool,
|
||||
intent: u32)
|
||||
-> ::sys::CGImageRef;
|
||||
fn CGImageCreateWithImageInRect(image: ::sys::CGImageRef, rect: CGRect) -> ::sys::CGImageRef;
|
||||
|
||||
//fn CGImageGetAlphaInfo(image: ::sys::CGImageRef) -> CGImageAlphaInfo;
|
||||
//fn CGImageCreateCopyWithColorSpace(image: ::sys::CGImageRef, space: ::sys::CGColorSpaceRef) -> ::sys::CGImageRef
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
extern crate libc;
|
||||
|
||||
#[macro_use]
|
||||
extern crate core_foundation;
|
||||
|
||||
#[macro_use]
|
||||
|
@ -18,6 +20,7 @@ extern crate bitflags;
|
|||
extern crate foreign_types;
|
||||
|
||||
pub mod base;
|
||||
pub mod color;
|
||||
pub mod color_space;
|
||||
pub mod context;
|
||||
pub mod data_provider;
|
||||
|
|
|
@ -7,13 +7,16 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub use sys::CGPathRef as SysCGPathRef;
|
||||
|
||||
use core_foundation::base::{CFRelease, CFRetain, CFTypeID};
|
||||
use foreign_types::ForeignType;
|
||||
use geometry::CGPoint;
|
||||
use std::os::raw::c_void;
|
||||
use geometry::{CGAffineTransform, CGPoint, CGRect};
|
||||
use libc::c_void;
|
||||
use std::fmt::{self, Debug, Formatter};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
foreign_type! {
|
||||
|
@ -26,6 +29,16 @@ foreign_type! {
|
|||
}
|
||||
|
||||
impl CGPath {
|
||||
pub fn from_rect(rect: CGRect, transform: Option<&CGAffineTransform>) -> CGPath {
|
||||
unsafe {
|
||||
let transform = match transform {
|
||||
None => ptr::null(),
|
||||
Some(transform) => transform as *const CGAffineTransform,
|
||||
};
|
||||
CGPath(CGPathCreateWithRect(rect, transform))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn type_id() -> CFTypeID {
|
||||
unsafe {
|
||||
CGPathGetTypeID()
|
||||
|
@ -110,6 +123,7 @@ type CGPathApplierFunction = unsafe extern "C" fn(info: *mut c_void,
|
|||
|
||||
#[link(name = "CoreGraphics", kind = "framework")]
|
||||
extern {
|
||||
fn CGPathCreateWithRect(rect: CGRect, transform: *const CGAffineTransform) -> ::sys::CGPathRef;
|
||||
fn CGPathApply(path: ::sys::CGPathRef, info: *mut c_void, function: CGPathApplierFunction);
|
||||
fn CGPathGetTypeID() -> CFTypeID;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
use std::os::raw::c_void;
|
||||
|
||||
pub enum CGImage {}
|
||||
pub type CGImageRef = *mut CGImage;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct __CGColor(c_void);
|
||||
|
||||
pub type CGColorRef = *const __CGColor;
|
||||
|
||||
pub enum CGColorSpace {}
|
||||
pub type CGColorSpaceRef = *mut CGColorSpace;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"671ed3c074224599fe05a7ab61a48c305842c9fc60e0dd486f4363bd4521fb8e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"1f747432402a00e7fc70227a5c0c49463638137fc804e2eb3c8fc74908b0875f","src/font_collection.rs":"e7e2facf1f5ec0661d61c230f84d6821e513315d7e311d2077443fb4e83c6f5d","src/font_descriptor.rs":"03439b11628c4aa5b8ac4aa68de25a2dd9da442755c0d91964170aca4a18c6d7","src/font_manager.rs":"de5e22620528322d6811d01f03975c53b676ec743297590de5e17a45393df0f1","src/lib.rs":"bd072cf53ebb643e4d21379d4487e60745999d20eab9caee8e56daa430cb65ca"},"package":"157ff38a92496dc676ce36d9124554e9ac66f1c1039f952690ac64f71cfa5968"}
|
||||
{"files":{".travis.yml":"6aad961651169d31d79c0595624d1777b5c4cbb4cf2bed9a126c7e72d29411fd","COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"73555748fd27f22bd31d4e17f95397ec4120e1a610b0d29333d750d8ecad228d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"0c82015d302c9937e6376debd961350afeaeb6dde228aac95e3a3115c5813613","src/font.rs":"f4094760cf28ad8c99a5fa427702008d0638abbc1d0adc02bc7f874744ff00dd","src/font_collection.rs":"02de0ce2a61683314897a521d31ab9cc572a8b10ceda2ac47181fbe18bf4f235","src/font_descriptor.rs":"37b6af08ceaca9f15971ea009805bed00884294a035f152c617b43b333fdb471","src/font_manager.rs":"0abebafad90fc1cc74742493c812ec617a44a80969bab64807d6e32ae70033c0","src/lib.rs":"bd072cf53ebb643e4d21379d4487e60745999d20eab9caee8e56daa430cb65ca"},"package":"f3f46450d6f2397261af420b4ccce23807add2e45fa206410a03d66fb7f050ae"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "core-text"
|
||||
version = "11.0.0"
|
||||
version = "13.0.0"
|
||||
authors = ["The Servo Project Developers"]
|
||||
description = "Bindings to the Core Text framework."
|
||||
license = "MIT/Apache-2.0"
|
||||
|
@ -21,7 +21,7 @@ repository = "https://github.com/servo/core-foundation-rs"
|
|||
version = "0.6"
|
||||
|
||||
[dependencies.core-graphics]
|
||||
version = "0.16"
|
||||
version = "0.17"
|
||||
|
||||
[dependencies.foreign-types]
|
||||
version = "0.3"
|
||||
|
|
|
@ -163,6 +163,24 @@ impl CTFont {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn clone_with_symbolic_traits(&self,
|
||||
trait_value: CTFontSymbolicTraits,
|
||||
trait_mask: CTFontSymbolicTraits)
|
||||
-> Option<CTFont> {
|
||||
unsafe {
|
||||
let font_ref = CTFontCreateCopyWithSymbolicTraits(self.0,
|
||||
0.0,
|
||||
ptr::null(),
|
||||
trait_value,
|
||||
trait_mask);
|
||||
if font_ref.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CTFont::wrap_under_create_rule(font_ref))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Names
|
||||
pub fn family_name(&self) -> String {
|
||||
unsafe {
|
||||
|
@ -192,6 +210,20 @@ impl CTFont {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn display_name(&self) -> String {
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontFullNameKey);
|
||||
value.expect("Fonts should always have a PostScript name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn style_name(&self) -> String {
|
||||
unsafe {
|
||||
let value = get_string_by_name_key(self, kCTFontStyleNameKey);
|
||||
value.expect("Fonts should always have a style name.")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_traits(&self) -> CTFontTraits {
|
||||
unsafe {
|
||||
CTFontTraits::wrap_under_create_rule(CTFontCopyTraits(self.0))
|
||||
|
@ -223,6 +255,18 @@ impl CTFont {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn slant_angle(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetSlantAngle(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cap_height(&self) -> CGFloat {
|
||||
unsafe {
|
||||
CTFontGetCapHeight(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bounding_box(&self) -> CGRect {
|
||||
unsafe {
|
||||
CTFontGetBoundingBox(self.0)
|
||||
|
@ -253,22 +297,33 @@ impl CTFont {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_glyphs_for_characters(&self, characters: *const UniChar, glyphs: *mut CGGlyph, count: CFIndex)
|
||||
-> bool {
|
||||
unsafe {
|
||||
CTFontGetGlyphsForCharacters(self.0, characters, glyphs, count)
|
||||
}
|
||||
pub unsafe fn get_glyphs_for_characters(&self,
|
||||
characters: *const UniChar,
|
||||
glyphs: *mut CGGlyph,
|
||||
count: CFIndex)
|
||||
-> bool {
|
||||
CTFontGetGlyphsForCharacters(self.0, characters, glyphs, count)
|
||||
}
|
||||
|
||||
pub fn get_advances_for_glyphs(&self,
|
||||
orientation: CTFontOrientation,
|
||||
glyphs: *const CGGlyph,
|
||||
advances: *mut CGSize,
|
||||
count: CFIndex)
|
||||
-> f64 {
|
||||
unsafe {
|
||||
CTFontGetAdvancesForGlyphs(self.0, orientation, glyphs, advances, count) as f64
|
||||
}
|
||||
pub unsafe fn get_advances_for_glyphs(&self,
|
||||
orientation: CTFontOrientation,
|
||||
glyphs: *const CGGlyph,
|
||||
advances: *mut CGSize,
|
||||
count: CFIndex)
|
||||
-> f64 {
|
||||
CTFontGetAdvancesForGlyphs(self.0, orientation, glyphs, advances, count) as f64
|
||||
}
|
||||
|
||||
pub unsafe fn get_vertical_translations_for_glyphs(&self,
|
||||
orientation: CTFontOrientation,
|
||||
glyphs: *const CGGlyph,
|
||||
translations: *mut CGSize,
|
||||
count: CFIndex) {
|
||||
CTFontGetVerticalTranslationsForGlyphs(self.0,
|
||||
orientation,
|
||||
glyphs,
|
||||
translations,
|
||||
count)
|
||||
}
|
||||
|
||||
pub fn get_font_table(&self, tag: u32) -> Option<CFData> {
|
||||
|
@ -338,6 +393,13 @@ impl CTFont {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn glyph_count(&self) -> CFIndex {
|
||||
unsafe {
|
||||
CTFontGetGlyphCount(self.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
@ -377,7 +439,7 @@ pub fn debug_font_traits(font: &CTFont) {
|
|||
|
||||
let traits = font.all_traits();
|
||||
println!("kCTFontWeightTrait: {}", traits.normalized_weight());
|
||||
// println!("kCTFontWidthTrait: {}", traits.normalized_width());
|
||||
println!("kCTFontWidthTrait: {}", traits.normalized_width());
|
||||
// println!("kCTFontSlantTrait: {}", traits.normalized_slant());
|
||||
}
|
||||
|
||||
|
@ -446,7 +508,12 @@ extern {
|
|||
//fn CTFontCreateUIFontForLanguage
|
||||
fn CTFontCreateCopyWithAttributes(font: CTFontRef, size: CGFloat, matrix: *const CGAffineTransform,
|
||||
attributes: CTFontDescriptorRef) -> CTFontRef;
|
||||
//fn CTFontCreateCopyWithSymbolicTraits
|
||||
fn CTFontCreateCopyWithSymbolicTraits(font: CTFontRef,
|
||||
size: CGFloat,
|
||||
matrix: *const CGAffineTransform,
|
||||
symTraitValue: CTFontSymbolicTraits,
|
||||
symTraitMask: CTFontSymbolicTraits)
|
||||
-> CTFontRef;
|
||||
//fn CTFontCreateCopyWithFamily
|
||||
//fn CTFontCreateForString
|
||||
|
||||
|
@ -480,12 +547,12 @@ extern {
|
|||
fn CTFontGetDescent(font: CTFontRef) -> CGFloat;
|
||||
fn CTFontGetLeading(font: CTFontRef) -> CGFloat;
|
||||
fn CTFontGetUnitsPerEm(font: CTFontRef) -> libc::c_uint;
|
||||
//fn CTFontGetGlyphCount
|
||||
fn CTFontGetGlyphCount(font: CTFontRef) -> CFIndex;
|
||||
fn CTFontGetBoundingBox(font: CTFontRef) -> CGRect;
|
||||
fn CTFontGetUnderlinePosition(font: CTFontRef) -> CGFloat;
|
||||
fn CTFontGetUnderlineThickness(font: CTFontRef) -> CGFloat;
|
||||
//fn CTFontGetSlantAngle
|
||||
//fn CTFontGetCapHeight
|
||||
fn CTFontGetSlantAngle(font: CTFontRef) -> CGFloat;
|
||||
fn CTFontGetCapHeight(font: CTFontRef) -> CGFloat;
|
||||
fn CTFontGetXHeight(font: CTFontRef) -> CGFloat;
|
||||
|
||||
/* Getting Glyph Data */
|
||||
|
@ -498,8 +565,17 @@ extern {
|
|||
boundingRects: *mut CGRect,
|
||||
count: CFIndex)
|
||||
-> CGRect;
|
||||
fn CTFontGetAdvancesForGlyphs(font: CTFontRef, orientation: CTFontOrientation, glyphs: *const CGGlyph, advances: *mut CGSize, count: CFIndex) -> libc::c_double;
|
||||
//fn CTFontGetVerticalTranslationsForGlyphs
|
||||
fn CTFontGetAdvancesForGlyphs(font: CTFontRef,
|
||||
orientation: CTFontOrientation,
|
||||
glyphs: *const CGGlyph,
|
||||
advances: *mut CGSize,
|
||||
count: CFIndex)
|
||||
-> libc::c_double;
|
||||
fn CTFontGetVerticalTranslationsForGlyphs(font: CTFontRef,
|
||||
orientation: CTFontOrientation,
|
||||
glyphs: *const CGGlyph,
|
||||
translations: *mut CGSize,
|
||||
count: CFIndex);
|
||||
|
||||
/* Working With Font Variations */
|
||||
fn CTFontCopyVariationAxes(font: CTFontRef) -> CFArrayRef;
|
||||
|
|
|
@ -33,11 +33,17 @@ impl_CFTypeDescription!(CTFontCollection);
|
|||
|
||||
|
||||
impl CTFontCollection {
|
||||
pub fn get_descriptors(&self) -> CFArray<CTFontDescriptor> {
|
||||
pub fn get_descriptors(&self) -> Option<CFArray<CTFontDescriptor>> {
|
||||
// surprise! this function follows the Get rule, despite being named *Create*.
|
||||
// So we have to addRef it to avoid CTFontCollection from double freeing it later.
|
||||
unsafe {
|
||||
CFArray::wrap_under_get_rule(CTFontCollectionCreateMatchingFontDescriptors(self.0))
|
||||
let font_descriptors = CTFontCollectionCreateMatchingFontDescriptors(self.0);
|
||||
if font_descriptors.is_null() {
|
||||
// This returns null if there are no matching font descriptors.
|
||||
None
|
||||
} else {
|
||||
Some(CFArray::wrap_under_get_rule(font_descriptors))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ pub trait SymbolicTraitAccessors {
|
|||
fn is_expanded(&self) -> bool;
|
||||
fn is_condensed(&self) -> bool;
|
||||
fn is_monospace(&self) -> bool;
|
||||
fn is_vertical(&self) -> bool;
|
||||
}
|
||||
|
||||
impl SymbolicTraitAccessors for CTFontSymbolicTraits {
|
||||
|
@ -61,6 +62,7 @@ impl SymbolicTraitAccessors for CTFontSymbolicTraits {
|
|||
fn is_expanded(&self) -> bool { (*self & kCTFontExpandedTrait) != 0 }
|
||||
fn is_condensed(&self) -> bool { (*self & kCTFontCondensedTrait) != 0 }
|
||||
fn is_monospace(&self) -> bool { (*self & kCTFontMonoSpaceTrait) != 0 }
|
||||
fn is_vertical(&self) -> bool { (*self & kCTFontVerticalTrait) != 0 }
|
||||
}
|
||||
|
||||
pub type CTFontStylisticClass = u32;
|
||||
|
|
|
@ -7,9 +7,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core_foundation::array::CFArrayRef;
|
||||
use core_foundation::array::{CFArray, CFArrayRef};
|
||||
use core_foundation::base::TCFType;
|
||||
use core_foundation::string::CFString;
|
||||
use core_foundation::url::CFURLRef;
|
||||
|
||||
pub fn copy_available_font_family_names() -> CFArray<CFString> {
|
||||
unsafe {
|
||||
TCFType::wrap_under_create_rule(CTFontManagerCopyAvailableFontFamilyNames())
|
||||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
/*
|
||||
* CTFontManager.h
|
||||
|
|
Загрузка…
Ссылка в новой задаче