From f54aabfe9295902b6bbe0db115186ca26f1956b0 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Wed, 15 Jan 2020 22:14:07 +0000 Subject: [PATCH] Update font crate to 2018 edition --- font/Cargo.toml | 1 + font/src/darwin/mod.rs | 12 ++++++------ font/src/directwrite/mod.rs | 5 +---- font/src/ft/fc/char_set.rs | 2 +- font/src/ft/fc/config.rs | 2 +- font/src/ft/fc/font_set.rs | 3 ++- font/src/ft/fc/mod.rs | 26 +++++++++++++------------- font/src/ft/fc/object_set.rs | 2 +- font/src/ft/fc/pattern.rs | 2 +- font/src/ft/mod.rs | 1 + font/src/lib.rs | 27 +-------------------------- 11 files changed, 29 insertions(+), 54 deletions(-) diff --git a/font/Cargo.toml b/font/Cargo.toml index 2c1617e..4fc1a3b 100644 --- a/font/Cargo.toml +++ b/font/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" authors = ["Christian Duerr ", "Joe Wilm "] description = "Font rendering using the best available solution per platform" license = "Apache-2.0" +edition = "2018" [dependencies] euclid = "0.20" diff --git a/font/src/darwin/mod.rs b/font/src/darwin/mod.rs index f95802f..2914b0b 100644 --- a/font/src/darwin/mod.rs +++ b/font/src/darwin/mod.rs @@ -18,8 +18,6 @@ use std::collections::HashMap; use std::path::PathBuf; use std::ptr; -use {Slant, Style, Weight}; - use core_foundation::array::{CFArray, CFIndex}; use core_foundation::string::CFString; use core_graphics::base::kCGImageAlphaPremultipliedFirst; @@ -42,12 +40,14 @@ use core_text::font_descriptor::{CTFontDescriptor, CTFontOrientation}; use euclid::{Point2D, Rect, Size2D}; -use super::{BitmapBuffer, FontDesc, FontKey, GlyphKey, Metrics, RasterizedGlyph}; +use log::{trace, warn}; pub mod byte_order; -use self::byte_order::kCGBitmapByteOrder32Host; +use byte_order::kCGBitmapByteOrder32Host; -use super::Size; +use super::{ + BitmapBuffer, FontDesc, FontKey, GlyphKey, Metrics, RasterizedGlyph, Size, Slant, Style, Weight, +}; /// Font descriptor /// @@ -124,7 +124,7 @@ impl ::std::fmt::Display for Error { } } -impl ::Rasterize for Rasterizer { +impl crate::Rasterize for Rasterizer { type Err = Error; fn new(device_pixel_ratio: f32, use_thin_strokes: bool) -> Result { diff --git a/font/src/directwrite/mod.rs b/font/src/directwrite/mod.rs index 74f3d6e..f2e71ef 100644 --- a/font/src/directwrite/mod.rs +++ b/font/src/directwrite/mod.rs @@ -13,10 +13,7 @@ // limitations under the License. // //! Rasterization powered by DirectWrite -extern crate dwrote; -use self::dwrote::{ - FontCollection, FontStretch, FontStyle, FontWeight, GlyphOffset, GlyphRunAnalysis, -}; +use dwrote::{FontCollection, FontStretch, FontStyle, FontWeight, GlyphOffset, GlyphRunAnalysis}; use super::{ BitmapBuffer, FontDesc, FontKey, GlyphKey, Metrics, RasterizedGlyph, Size, Slant, Style, Weight, diff --git a/font/src/ft/fc/char_set.rs b/font/src/ft/fc/char_set.rs index 42c25b0..8955445 100644 --- a/font/src/ft/fc/char_set.rs +++ b/font/src/ft/fc/char_set.rs @@ -13,7 +13,7 @@ // limitations under the License. use std::ptr::NonNull; -use foreign_types::ForeignTypeRef; +use foreign_types::{foreign_type, ForeignTypeRef}; use super::ffi::FcCharSetCreate; use super::ffi::{FcCharSet, FcCharSetAddChar, FcCharSetDestroy}; diff --git a/font/src/ft/fc/config.rs b/font/src/ft/fc/config.rs index 46a3a93..44bb998 100644 --- a/font/src/ft/fc/config.rs +++ b/font/src/ft/fc/config.rs @@ -11,7 +11,7 @@ // 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 foreign_types::ForeignTypeRef; +use foreign_types::{foreign_type, ForeignTypeRef}; use super::ffi::{FcConfig, FcConfigDestroy, FcConfigGetCurrent, FcConfigGetFonts}; use super::{FontSetRef, SetName}; diff --git a/font/src/ft/fc/font_set.rs b/font/src/ft/fc/font_set.rs index 632c80b..ae746f4 100644 --- a/font/src/ft/fc/font_set.rs +++ b/font/src/ft/fc/font_set.rs @@ -14,7 +14,8 @@ use std::ops::Deref; use std::ptr::NonNull; -use foreign_types::{ForeignType, ForeignTypeRef}; +use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; +use log::trace; use super::{ConfigRef, ObjectSetRef, PatternRef}; diff --git a/font/src/ft/fc/mod.rs b/font/src/ft/fc/mod.rs index ae8fb80..612f7c5 100644 --- a/font/src/ft/fc/mod.rs +++ b/font/src/ft/fc/mod.rs @@ -19,29 +19,29 @@ use foreign_types::{ForeignType, ForeignTypeRef}; use fontconfig::fontconfig as ffi; -use self::ffi::FcResultNoMatch; -use self::ffi::{FcFontList, FcFontMatch, FcFontSort}; -use self::ffi::{FcMatchFont, FcMatchPattern, FcMatchScan}; -use self::ffi::{FcSetApplication, FcSetSystem}; -use self::ffi::{FC_SLANT_ITALIC, FC_SLANT_OBLIQUE, FC_SLANT_ROMAN}; -use self::ffi::{FC_WEIGHT_BLACK, FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABLACK, FC_WEIGHT_EXTRABOLD}; -use self::ffi::{FC_WEIGHT_BOOK, FC_WEIGHT_MEDIUM, FC_WEIGHT_REGULAR, FC_WEIGHT_SEMIBOLD}; -use self::ffi::{FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT, FC_WEIGHT_THIN}; +use ffi::FcResultNoMatch; +use ffi::{FcFontList, FcFontMatch, FcFontSort}; +use ffi::{FcMatchFont, FcMatchPattern, FcMatchScan}; +use ffi::{FcSetApplication, FcSetSystem}; +use ffi::{FC_SLANT_ITALIC, FC_SLANT_OBLIQUE, FC_SLANT_ROMAN}; +use ffi::{FC_WEIGHT_BLACK, FC_WEIGHT_BOLD, FC_WEIGHT_EXTRABLACK, FC_WEIGHT_EXTRABOLD}; +use ffi::{FC_WEIGHT_BOOK, FC_WEIGHT_MEDIUM, FC_WEIGHT_REGULAR, FC_WEIGHT_SEMIBOLD}; +use ffi::{FC_WEIGHT_EXTRALIGHT, FC_WEIGHT_LIGHT, FC_WEIGHT_THIN}; pub mod config; -pub use self::config::{Config, ConfigRef}; +pub use config::{Config, ConfigRef}; pub mod font_set; -pub use self::font_set::{FontSet, FontSetRef}; +pub use font_set::{FontSet, FontSetRef}; pub mod object_set; -pub use self::object_set::{ObjectSet, ObjectSetRef}; +pub use object_set::{ObjectSet, ObjectSetRef}; pub mod char_set; -pub use self::char_set::{CharSet, CharSetRef}; +pub use char_set::{CharSet, CharSetRef}; pub mod pattern; -pub use self::pattern::{Pattern, PatternRef}; +pub use pattern::{Pattern, PatternRef}; /// Find the font closest matching the provided pattern. /// diff --git a/font/src/ft/fc/object_set.rs b/font/src/ft/fc/object_set.rs index 1cc7e11..acaf352 100644 --- a/font/src/ft/fc/object_set.rs +++ b/font/src/ft/fc/object_set.rs @@ -16,7 +16,7 @@ use std::ptr::NonNull; use libc::c_char; use super::ffi::{FcObjectSet, FcObjectSetAdd, FcObjectSetCreate, FcObjectSetDestroy}; -use foreign_types::ForeignTypeRef; +use foreign_types::{foreign_type, ForeignTypeRef}; foreign_type! { pub unsafe type ObjectSet { diff --git a/font/src/ft/fc/pattern.rs b/font/src/ft/fc/pattern.rs index 2500739..7d8d643 100644 --- a/font/src/ft/fc/pattern.rs +++ b/font/src/ft/fc/pattern.rs @@ -18,7 +18,7 @@ use std::path::PathBuf; use std::ptr::{self, NonNull}; use std::str; -use foreign_types::{ForeignType, ForeignTypeRef}; +use foreign_types::{foreign_type, ForeignType, ForeignTypeRef}; use libc::{c_char, c_double, c_int}; use super::ffi::FcResultMatch; diff --git a/font/src/ft/mod.rs b/font/src/ft/mod.rs index 206d604..d92ab7c 100644 --- a/font/src/ft/mod.rs +++ b/font/src/ft/mod.rs @@ -22,6 +22,7 @@ use freetype::freetype_sys; use freetype::tt_os2::TrueTypeOS2Table; use freetype::{self, Library}; use libc::c_uint; +use log::{debug, trace}; pub mod fc; diff --git a/font/src/lib.rs b/font/src/lib.rs index 8fd0f62..f5dc019 100644 --- a/font/src/lib.rs +++ b/font/src/lib.rs @@ -20,31 +20,6 @@ #![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use, clippy::wrong_pub_self_convention)] -#[cfg(not(any(target_os = "macos", windows)))] -extern crate fontconfig; -#[cfg(not(any(target_os = "macos", windows)))] -extern crate freetype; - -#[cfg(target_os = "macos")] -extern crate core_foundation; -#[cfg(target_os = "macos")] -extern crate core_foundation_sys; -#[cfg(target_os = "macos")] -extern crate core_graphics; -#[cfg(target_os = "macos")] -extern crate core_text; -#[cfg(target_os = "macos")] -extern crate euclid; - -extern crate libc; - -#[cfg(not(any(target_os = "macos", windows)))] -#[macro_use] -extern crate foreign_types; - -#[cfg_attr(not(windows), macro_use)] -extern crate log; - use std::fmt; use std::hash::{Hash, Hasher}; use std::ops::{Add, Mul}; @@ -59,7 +34,7 @@ pub use ft::{Error, FreeTypeRasterizer as Rasterizer}; #[cfg(windows)] pub mod directwrite; #[cfg(windows)] -pub use crate::directwrite::{DirectWriteRasterizer as Rasterizer, Error}; +pub use directwrite::{DirectWriteRasterizer as Rasterizer, Error}; // If target is macos, reexport everything from darwin #[cfg(target_os = "macos")]