diff options
author | Christian Duerr <chrisduerr@users.noreply.github.com> | 2019-04-03 22:57:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-03 22:57:54 +0000 |
commit | e98ea64c748f1cce673c97adbc72e6a9a3c11e5f (patch) | |
tree | aba9d97bc30eb7a78669a557b9d3ffd4a77df789 /font | |
parent | 86ccd0566edf97849079889a80e67669332c37cb (diff) |
Bump dependencies
Diffstat (limited to 'font')
-rw-r--r-- | font/Cargo.toml | 6 | ||||
-rw-r--r-- | font/src/ft/fc/char_set.rs | 12 | ||||
-rw-r--r-- | font/src/ft/fc/config.rs | 10 | ||||
-rw-r--r-- | font/src/ft/fc/font_set.rs | 13 | ||||
-rw-r--r-- | font/src/ft/fc/object_set.rs | 12 | ||||
-rw-r--r-- | font/src/ft/fc/pattern.rs | 12 | ||||
-rw-r--r-- | font/src/rusttype/mod.rs | 6 |
7 files changed, 35 insertions, 36 deletions
diff --git a/font/Cargo.toml b/font/Cargo.toml index 972e212e..429ea5f5 100644 --- a/font/Cargo.toml +++ b/font/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" [dependencies] euclid = "0.19.2" libc = "0.2" -foreign-types = "0.3" +foreign-types = "0.4" log = "0.4" [target.'cfg(not(any(target_os = "macos", windows)))'.dependencies] @@ -22,5 +22,5 @@ core-graphics = "0.17" core-foundation-sys = "0.6" [target.'cfg(windows)'.dependencies] -font-loader = "0.6.0" -rusttype = "0.4.1" +font-loader = "0.8.0" +rusttype = "0.7.5" diff --git a/font/src/ft/fc/char_set.rs b/font/src/ft/fc/char_set.rs index 310fa189..9d71fea4 100644 --- a/font/src/ft/fc/char_set.rs +++ b/font/src/ft/fc/char_set.rs @@ -11,16 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +use std::ptr::NonNull; + use foreign_types::ForeignTypeRef; use super::ffi::FcCharSetCreate; use super::ffi::{FcCharSet, FcCharSetAddChar, FcCharSetDestroy}; foreign_type! { - type CType = FcCharSet; - fn drop = FcCharSetDestroy; - pub struct CharSet; - pub struct CharSetRef; + pub type CharSet { + type CType = FcCharSet; + fn drop = FcCharSetDestroy; + } } impl CharSet { @@ -31,7 +33,7 @@ impl CharSet { impl Default for CharSet { fn default() -> Self { - CharSet(unsafe { FcCharSetCreate() }) + CharSet(unsafe { NonNull::new(FcCharSetCreate()).unwrap() }) } } diff --git a/font/src/ft/fc/config.rs b/font/src/ft/fc/config.rs index 12ec2844..cc3b5e52 100644 --- a/font/src/ft/fc/config.rs +++ b/font/src/ft/fc/config.rs @@ -17,12 +17,10 @@ use super::ffi::{FcConfig, FcConfigDestroy, FcConfigGetCurrent, FcConfigGetFonts use super::{FontSetRef, SetName}; foreign_type! { - type CType = FcConfig; - fn drop = FcConfigDestroy; - /// Wraps an FcConfig instance (owned) - pub struct Config; - /// Wraps an FcConfig reference (borrowed) - pub struct ConfigRef; + pub type Config { + type CType = FcConfig; + fn drop = FcConfigDestroy; + } } impl Config { diff --git a/font/src/ft/fc/font_set.rs b/font/src/ft/fc/font_set.rs index aeb34371..e280201b 100644 --- a/font/src/ft/fc/font_set.rs +++ b/font/src/ft/fc/font_set.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. use std::ops::Deref; +use std::ptr::NonNull; use foreign_types::{ForeignType, ForeignTypeRef}; @@ -20,12 +21,10 @@ use super::{ConfigRef, ObjectSetRef, PatternRef}; use super::ffi::{FcFontSet, FcFontSetDestroy, FcFontSetList}; foreign_type! { - type CType = FcFontSet; - fn drop = FcFontSetDestroy; - /// Wraps an FcFontSet instance (owned) - pub struct FontSet; - /// Wraps an FcFontSet reference (borrowed) - pub struct FontSetRef; + pub type FontSet { + type CType = FcFontSet; + fn drop = FcFontSetDestroy; + } } impl FontSet { @@ -44,7 +43,7 @@ impl FontSet { objects.as_ptr(), ) }; - FontSet(raw) + FontSet(NonNull::new(raw).unwrap()) } } diff --git a/font/src/ft/fc/object_set.rs b/font/src/ft/fc/object_set.rs index 2494b582..4ec15feb 100644 --- a/font/src/ft/fc/object_set.rs +++ b/font/src/ft/fc/object_set.rs @@ -11,16 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +use std::ptr::NonNull; + use libc::c_char; use super::ffi::{FcObjectSet, FcObjectSetAdd, FcObjectSetCreate, FcObjectSetDestroy}; use foreign_types::ForeignTypeRef; foreign_type! { - type CType = FcObjectSet; - fn drop = FcObjectSetDestroy; - pub struct ObjectSet; - pub struct ObjectSetRef; + pub type ObjectSet { + type CType = FcObjectSet; + fn drop = FcObjectSetDestroy; + } } impl ObjectSet { @@ -31,7 +33,7 @@ impl ObjectSet { impl Default for ObjectSet { fn default() -> Self { - ObjectSet(unsafe { FcObjectSetCreate() }) + ObjectSet(unsafe { NonNull::new(FcObjectSetCreate()).unwrap() }) } } diff --git a/font/src/ft/fc/pattern.rs b/font/src/ft/fc/pattern.rs index 84187aa3..b6eceed8 100644 --- a/font/src/ft/fc/pattern.rs +++ b/font/src/ft/fc/pattern.rs @@ -15,7 +15,7 @@ use std::ffi::{CStr, CString}; use std::fmt; use std::mem; use std::path::PathBuf; -use std::ptr; +use std::ptr::{self, NonNull}; use std::str; use foreign_types::{ForeignType, ForeignTypeRef}; @@ -326,10 +326,10 @@ impl_derived_property_iter! { } foreign_type! { - type CType = FcPattern; - fn drop = FcPatternDestroy; - pub struct Pattern; - pub struct PatternRef; + pub type Pattern { + type CType = FcPattern; + fn drop = FcPatternDestroy; + } } macro_rules! string_accessor { @@ -360,7 +360,7 @@ impl Pattern { impl Default for Pattern { fn default() -> Self { - Pattern(unsafe { FcPatternCreate() }) + Pattern(unsafe { NonNull::new(FcPatternCreate()).unwrap() }) } } diff --git a/font/src/rusttype/mod.rs b/font/src/rusttype/mod.rs index be39ecc9..fc69d6e9 100644 --- a/font/src/rusttype/mod.rs +++ b/font/src/rusttype/mod.rs @@ -27,7 +27,6 @@ impl crate::Rasterize for RustTypeRasterizer { // 33 '!' is the first displaying character Codepoint(33), ) - .ok_or(Error::MissingGlyph)? .scaled(scale) .h_metrics(); @@ -78,8 +77,8 @@ impl crate::Rasterize for RustTypeRasterizer { FontCollection::from_bytes( system_fonts::get(&fp.build()).ok_or_else(|| Error::MissingFont(desc.clone()))?.0, ) - .into_font() - .ok_or(Error::UnsupportedFont)?, + .and_then(|fc| fc.into_font()) + .map_err(|_| Error::UnsupportedFont)?, ); Ok(FontKey { token: (self.fonts.len() - 1) as u16 }) } @@ -116,7 +115,6 @@ impl crate::Rasterize for RustTypeRasterizer { let scaled_glyph = self.fonts[glyph_key.font_key.token as usize] .glyph(glyph_key.c) - .ok_or(Error::MissingGlyph)? .scaled(Scale::uniform(glyph_key.size.as_f32_pts() * self.dpi_ratio * 96. / 72.)); let glyph = scaled_glyph.positioned(point(0.0, 0.0)); |