Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core-foundation and core-graphics #2728

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update core-foundation and core-graphics

  • Loading branch information
jrmuizel committed May 3, 2018
commit e8d7fb6209f3d036fe671ea01e16d5389dbec15e

Some generated files are not rendered by default. Learn more.

@@ -73,6 +73,6 @@ freetype = { version = "0.4", default-features = false }
dwrote = "0.4.1"

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.5"
core-graphics = "0.13"
core-text = { version = "9.2.0", default-features = false }
core-foundation = "0.6"
core-graphics = "0.14"
core-text = { version = "10.0.0", default-features = false }
@@ -7,9 +7,9 @@ use api::{FontInstanceFlags, FontVariation, NativeFontHandle};
use api::{GlyphKey, SubpixelDirection};
use app_units::Au;
use core_foundation::array::{CFArray, CFArrayRef};
use core_foundation::base::TCFType;
use core_foundation::base::{CFType, TCFType};
use core_foundation::dictionary::CFDictionary;
use core_foundation::number::{CFNumber, CFNumberRef};
use core_foundation::number::CFNumber;
use core_foundation::string::{CFString, CFStringRef};
use core_graphics::base::{kCGImageAlphaNoneSkipFirst, kCGBitmapByteOrder32Little};
#[cfg(not(feature = "pathfinder"))]
@@ -171,84 +171,57 @@ extern {
}

fn new_ct_font_with_variations(cg_font: &CGFont, size: f64, variations: &[FontVariation]) -> CTFont {
unsafe {
{
let ct_font = core_text::font::new_from_CGFont(cg_font, size);
if variations.is_empty() {
return ct_font;
}
let axes_ref = CTFontCopyVariationAxes(ct_font.as_concrete_TypeRef());
if axes_ref.is_null() {
return ct_font;
}
let axes: CFArray<CFDictionary> = TCFType::wrap_under_create_rule(axes_ref);
let axes = unsafe {
let axes_ref = CTFontCopyVariationAxes(ct_font.as_concrete_TypeRef());
if axes_ref.is_null() {
return ct_font;
}
CFArray::<CFDictionary<CFString, CFType>>::wrap_under_create_rule(axes_ref)
};
let mut vals: Vec<(CFString, CFNumber)> = Vec::with_capacity(variations.len() as usize);
for axis in axes.iter() {
if !axis.instance_of::<CFDictionary>() {
return ct_font;
}
let tag_val = match axis.find(kCTFontVariationAxisIdentifierKey as *const _) {
Some(tag_ptr) => {
let tag: CFNumber = TCFType::wrap_under_get_rule(tag_ptr as CFNumberRef);
if !tag.instance_of::<CFNumber>() {
return ct_font;
}
match tag.to_i64() {
Some(val) => val,
None => return ct_font,
}
}
let tag_val = match axis.find(unsafe { kCTFontVariationAxisIdentifierKey })
.and_then(|x| x.downcast::<CFNumber>())
.and_then(|x| x.to_i64()) {
Some(tag_val) => tag_val,
None => return ct_font,
};

let mut val = match variations.iter().find(|variation| (variation.tag as i64) == tag_val) {
Some(variation) => variation.value as f64,
None => continue,
};

let name: CFString = match axis.find(kCTFontVariationAxisNameKey as *const _) {
Some(name_ptr) => TCFType::wrap_under_get_rule(name_ptr as CFStringRef),
let name: CFString = match axis.find(unsafe { kCTFontVariationAxisNameKey })
.and_then(|x| x.downcast::<CFString>()) {
Some(name) => name,
None => return ct_font,
};
if !name.instance_of::<CFString>() {
return ct_font;
}

let min_val = match axis.find(kCTFontVariationAxisMinimumValueKey as *const _) {
Some(min_ptr) => {
let min: CFNumber = TCFType::wrap_under_get_rule(min_ptr as CFNumberRef);
if !min.instance_of::<CFNumber>() {
return ct_font;
}
match min.to_f64() {
Some(val) => val,
None => return ct_font,
}
}
let min_val = match axis.find(unsafe { kCTFontVariationAxisMinimumValueKey })
.and_then(|x| x.downcast::<CFNumber>())
.and_then(|x| x.to_f64()) {
Some(min_val) => min_val,
None => return ct_font,
};
let max_val = match axis.find(kCTFontVariationAxisMaximumValueKey as *const _) {
Some(max_ptr) => {
let max: CFNumber = TCFType::wrap_under_get_rule(max_ptr as CFNumberRef);
if !max.instance_of::<CFNumber>() {
return ct_font;
}
match max.to_f64() {
Some(val) => val,
None => return ct_font,
}
}
let max_val = match axis.find(unsafe { kCTFontVariationAxisMaximumValueKey })
.and_then(|x| x.downcast::<CFNumber>())
.and_then(|x| x.to_f64()) {
Some(max_val) => max_val,
None => return ct_font,
};
let def_val = match axis.find(kCTFontVariationAxisDefaultValueKey as *const _) {
Some(def_ptr) => {
let def: CFNumber = TCFType::wrap_under_get_rule(def_ptr as CFNumberRef);
if !def.instance_of::<CFNumber>() {
return ct_font;
}
match def.to_f64() {
Some(val) => val,
None => return ct_font,
}
}
let def_val = match axis.find(unsafe { kCTFontVariationAxisDefaultValueKey })
.and_then(|x| x.downcast::<CFNumber>())
.and_then(|x| x.to_f64()) {
Some(def_val) => def_val,
None => return ct_font,
};

@@ -24,8 +24,8 @@ serde_bytes = "0.10"
time = "0.1"

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.5"
core-graphics = "0.13"
core-foundation = "0.6"
core-graphics = "0.14"

[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.4.1"
@@ -30,8 +30,8 @@ webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]
serde = {version = "1.0", features = ["derive"] }

[target.'cfg(target_os = "macos")'.dependencies]
core-graphics = "0.13"
core-foundation = "0.5"
core-graphics = "0.14"
core-foundation = "0.6"

[features]
headless = [ "osmesa-sys", "osmesa-src" ]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.