diff --git a/Cargo.toml b/Cargo.toml index 2412c4b..b3d5aec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ license = "MIT" readme = "README.md" repository = "https://github.com/PistonDevelopers/freetype-rs.git" homepage = "https://github.com/PistonDevelopers/freetype-rs" +edition = "2018" [lib] name = "freetype" diff --git a/src/bitmap.rs b/src/bitmap.rs index d34c612..361c14a 100644 --- a/src/bitmap.rs +++ b/src/bitmap.rs @@ -1,5 +1,5 @@ +use crate::{ffi, Error, FtResult}; use std::slice; -use {ffi, Error, FtResult}; /// An enumeration type used to describe the format of pixels in a given bitmap. Note that /// additional formats may be added in the future. diff --git a/src/bitmap_glyph.rs b/src/bitmap_glyph.rs index f9085e8..93befb9 100644 --- a/src/bitmap_glyph.rs +++ b/src/bitmap_glyph.rs @@ -1,5 +1,5 @@ +use crate::{ffi, Bitmap}; use std::ptr::null_mut; -use {ffi, Bitmap}; pub struct BitmapGlyph { library_raw: ffi::FT_Library, diff --git a/src/error.rs b/src/error.rs index f55b829..74baac0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,4 @@ -use ffi; +use crate::ffi; use std::error; use std::fmt; diff --git a/src/face.rs b/src/face.rs index 8410d5b..a77ee01 100644 --- a/src/face.rs +++ b/src/face.rs @@ -4,7 +4,7 @@ use std::num::NonZeroU32; use std::rc::Rc; use crate::charmap::CharMap; -use {ffi, FtResult, GlyphSlot, Matrix, Vector}; +use crate::{ffi, FtResult, GlyphSlot, Matrix, Vector}; #[repr(u32)] #[derive(Copy, Clone)] @@ -14,38 +14,38 @@ pub enum KerningMode { KerningUnscaled = ffi::FT_KERNING_UNSCALED, } -bitflags! { +bitflags::bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct LoadFlag: i32 { - const DEFAULT = ::ffi::FT_LOAD_DEFAULT; - const NO_SCALE = ::ffi::FT_LOAD_NO_SCALE; - const NO_HINTING = ::ffi::FT_LOAD_NO_HINTING; - const RENDER = ::ffi::FT_LOAD_RENDER; - const NO_BITMAP = ::ffi::FT_LOAD_NO_BITMAP; - const VERTICAL_LAYOUT = ::ffi::FT_LOAD_VERTICAL_LAYOUT; - const FORCE_AUTOHINT = ::ffi::FT_LOAD_FORCE_AUTOHINT; - const CROP_BITMAP = ::ffi::FT_LOAD_CROP_BITMAP; - const PEDANTIC = ::ffi::FT_LOAD_PEDANTIC; - const IGNORE_GLOBAL_ADVANCE_WITH = ::ffi::FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; - const NO_RECURSE = ::ffi::FT_LOAD_NO_RECURSE; - const IGNORE_TRANSFORM = ::ffi::FT_LOAD_IGNORE_TRANSFORM; - const MONOCHROME = ::ffi::FT_LOAD_MONOCHROME; - const LINEAR_DESIGN = ::ffi::FT_LOAD_LINEAR_DESIGN; - const NO_AUTOHINT = ::ffi::FT_LOAD_NO_AUTOHINT; - const TARGET_NORMAL = ::ffi::FT_LOAD_TARGET_NORMAL; - const TARGET_LIGHT = ::ffi::FT_LOAD_TARGET_LIGHT; - const TARGET_MONO = ::ffi::FT_LOAD_TARGET_MONO; - const TARGET_LCD = ::ffi::FT_LOAD_TARGET_LCD; - const TARGET_LCD_V = ::ffi::FT_LOAD_TARGET_LCD_V; - const COLOR = ::ffi::FT_LOAD_COLOR; + const DEFAULT = crate::ffi::FT_LOAD_DEFAULT; + const NO_SCALE = crate::ffi::FT_LOAD_NO_SCALE; + const NO_HINTING = crate::ffi::FT_LOAD_NO_HINTING; + const RENDER = crate::ffi::FT_LOAD_RENDER; + const NO_BITMAP = crate::ffi::FT_LOAD_NO_BITMAP; + const VERTICAL_LAYOUT = crate::ffi::FT_LOAD_VERTICAL_LAYOUT; + const FORCE_AUTOHINT = crate::ffi::FT_LOAD_FORCE_AUTOHINT; + const CROP_BITMAP = crate::ffi::FT_LOAD_CROP_BITMAP; + const PEDANTIC = crate::ffi::FT_LOAD_PEDANTIC; + const IGNORE_GLOBAL_ADVANCE_WITH = crate::ffi::FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; + const NO_RECURSE = crate::ffi::FT_LOAD_NO_RECURSE; + const IGNORE_TRANSFORM = crate::ffi::FT_LOAD_IGNORE_TRANSFORM; + const MONOCHROME = crate::ffi::FT_LOAD_MONOCHROME; + const LINEAR_DESIGN = crate::ffi::FT_LOAD_LINEAR_DESIGN; + const NO_AUTOHINT = crate::ffi::FT_LOAD_NO_AUTOHINT; + const TARGET_NORMAL = crate::ffi::FT_LOAD_TARGET_NORMAL; + const TARGET_LIGHT = crate::ffi::FT_LOAD_TARGET_LIGHT; + const TARGET_MONO = crate::ffi::FT_LOAD_TARGET_MONO; + const TARGET_LCD = crate::ffi::FT_LOAD_TARGET_LCD; + const TARGET_LCD_V = crate::ffi::FT_LOAD_TARGET_LCD_V; + const COLOR = crate::ffi::FT_LOAD_COLOR; } } -bitflags! { +bitflags::bitflags! { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct StyleFlag: ffi::FT_Long { - const BOLD = ::ffi::FT_STYLE_FLAG_BOLD; - const ITALIC = ::ffi::FT_STYLE_FLAG_ITALIC; + const BOLD = crate::ffi::FT_STYLE_FLAG_BOLD; + const ITALIC = crate::ffi::FT_STYLE_FLAG_ITALIC; } } diff --git a/src/glyph.rs b/src/glyph.rs index 9c8c6d3..ab2122e 100644 --- a/src/glyph.rs +++ b/src/glyph.rs @@ -1,5 +1,5 @@ +use crate::{ffi, BBox, BitmapGlyph, FtResult, Matrix, RenderMode, Stroker, Vector}; use std::ptr::null_mut; -use {ffi, BBox, BitmapGlyph, FtResult, Matrix, RenderMode, Stroker, Vector}; /// Represents a retrieved glyph from the library /// diff --git a/src/glyph_slot.rs b/src/glyph_slot.rs index b3f255e..232e09b 100644 --- a/src/glyph_slot.rs +++ b/src/glyph_slot.rs @@ -1,5 +1,5 @@ +use crate::{ffi, Bitmap, FtResult, Glyph, GlyphMetrics, Outline, RenderMode, Vector}; use std::ptr::null_mut; -use {ffi, Bitmap, FtResult, Glyph, GlyphMetrics, Outline, RenderMode, Vector}; /// A description of a given subglyph returned by `GlyphSlot::get_subglyph_info` /// function. diff --git a/src/lib.rs b/src/lib.rs index 0b4f33d..93d675c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,22 +38,19 @@ #![deny(missing_copy_implementations)] -#[macro_use] -extern crate bitflags; -pub extern crate freetype_sys; -extern crate libc; +pub use freetype_sys; -pub use bitmap::Bitmap; -pub use bitmap_glyph::BitmapGlyph; -pub use error::{Error, FtResult}; -pub use face::Face; +pub use crate::bitmap::Bitmap; +pub use crate::bitmap_glyph::BitmapGlyph; +pub use crate::error::{Error, FtResult}; +pub use crate::face::Face; +pub use crate::glyph::Glyph; +pub use crate::glyph_slot::GlyphSlot; +pub use crate::library::{LcdFilter, Library}; +pub use crate::outline::Outline; +pub use crate::render_mode::RenderMode; +pub use crate::stroker::{Stroker, StrokerLineCap, StrokerLineJoin}; pub use freetype_sys as ffi; -pub use glyph::Glyph; -pub use glyph_slot::GlyphSlot; -pub use library::{LcdFilter, Library}; -pub use outline::Outline; -pub use render_mode::RenderMode; -pub use stroker::{Stroker, StrokerLineCap, StrokerLineJoin}; pub mod bitmap; pub mod bitmap_glyph; diff --git a/src/library.rs b/src/library.rs index 86fa1c1..e940cf6 100644 --- a/src/library.rs +++ b/src/library.rs @@ -1,10 +1,10 @@ -use ffi; +use crate::ffi; +use crate::{Error, Face, FtResult, Stroker}; use libc::{self, c_long, c_void, size_t}; use std::borrow::Borrow; use std::ffi::{CString, OsStr}; use std::ptr::null_mut; use std::rc::Rc; -use {Error, Face, FtResult, Stroker}; extern "C" fn alloc_library(_memory: ffi::FT_Memory, size: c_long) -> *mut c_void { unsafe { libc::malloc(size as size_t) } diff --git a/src/outline.rs b/src/outline.rs index 9ca54b9..b13cf69 100644 --- a/src/outline.rs +++ b/src/outline.rs @@ -1,7 +1,7 @@ +use crate::{ffi, Vector}; use libc::{c_char, c_short}; use std::marker::PhantomData; use std::slice; -use {ffi, Vector}; #[derive(Copy, Clone)] pub enum Curve { diff --git a/src/render_mode.rs b/src/render_mode.rs index c446252..092472d 100644 --- a/src/render_mode.rs +++ b/src/render_mode.rs @@ -1,4 +1,4 @@ -use ffi; +use crate::ffi; #[repr(u32)] #[derive(Copy, Clone)] diff --git a/src/stroker.rs b/src/stroker.rs index 68aaba9..b46fe21 100644 --- a/src/stroker.rs +++ b/src/stroker.rs @@ -1,4 +1,4 @@ -use ffi; +use crate::ffi; #[repr(u32)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/src/tt_os2.rs b/src/tt_os2.rs index cf2bd56..9776da1 100644 --- a/src/tt_os2.rs +++ b/src/tt_os2.rs @@ -1,5 +1,5 @@ -use face::Face; -use ffi; +use crate::face::Face; +use crate::ffi; #[derive(Copy, Clone)] pub struct TrueTypeOS2Table { @@ -130,7 +130,7 @@ impl TrueTypeOS2Table { mod tests { use std::path::PathBuf; - use library::Library; + use crate::library::Library; use super::*; diff --git a/src/tt_postscript.rs b/src/tt_postscript.rs index 5ecbea4..8b99815 100644 --- a/src/tt_postscript.rs +++ b/src/tt_postscript.rs @@ -1,5 +1,5 @@ -use face::Face; -use ffi; +use crate::face::Face; +use crate::ffi; #[derive(Copy, Clone)] pub struct TrueTypePostscriptTable {