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 to 2018 edition. #278

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap_glyph.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{ffi, Bitmap};
use std::ptr::null_mut;
use {ffi, Bitmap};

pub struct BitmapGlyph {
library_raw: ffi::FT_Library,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ffi;
use crate::ffi;
use std::error;
use std::fmt;

Expand Down
52 changes: 26 additions & 26 deletions src/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/glyph.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand Down
2 changes: 1 addition & 1 deletion src/glyph_slot.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
25 changes: 11 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/library.rs
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion src/outline.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/render_mode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ffi;
use crate::ffi;

#[repr(u32)]
#[derive(Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/stroker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ffi;
use crate::ffi;

#[repr(u32)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down
6 changes: 3 additions & 3 deletions src/tt_os2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use face::Face;
use ffi;
use crate::face::Face;
use crate::ffi;

#[derive(Copy, Clone)]
pub struct TrueTypeOS2Table {
Expand Down Expand Up @@ -130,7 +130,7 @@ impl TrueTypeOS2Table {
mod tests {
use std::path::PathBuf;

use library::Library;
use crate::library::Library;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions src/tt_postscript.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use face::Face;
use ffi;
use crate::face::Face;
use crate::ffi;

#[derive(Copy, Clone)]
pub struct TrueTypePostscriptTable {
Expand Down