Glyph

Struct Glyph 

Source
pub struct Glyph { /* private fields */ }
Expand description

A font glyph.

Implementations§

Source§

impl Glyph

Source

pub fn new<T: Into<String>>(name: T, codepoint: char) -> Self

Creates a new glyph with the given name and codepoint.

Source

pub fn validate(&self) -> bool

Validates the definition.

Source

pub fn name(&self) -> &str

Gets the name.

Source

pub fn set_name<T: Into<String>>(&mut self, name: T)

Sets the name.

Source

pub fn codepoint(&self) -> char

Gets the codepoint.

Source

pub fn set_codepoint(&mut self, codepoint: char)

Sets the codepoint.

Source

pub fn direction(&self) -> Direction

Gets the direction.

Source

pub fn set_direction(&mut self, direction: Direction)

Sets the direction.

Source

pub fn scalable_width(&self) -> Option<&(u32, u32)>

Gets the scalable width.

Source

pub fn set_scalable_width(&mut self, value: Option<(u32, u32)>)

Sets the scalable width.

Source

pub fn device_width(&self) -> Option<&(u32, u32)>

Gets the device width.

Source

pub fn set_device_width(&mut self, value: Option<(u32, u32)>)

Sets the device width.

Source

pub fn alternate_scalable_width(&self) -> Option<&(u32, u32)>

Gets the alternate scalable width.

Source

pub fn set_alternate_scalable_width(&mut self, value: Option<(u32, u32)>)

Sets the alternate scalable width.

Source

pub fn alternate_device_width(&self) -> Option<&(u32, u32)>

Gets the alternate device width.

Source

pub fn set_alternate_device_width(&mut self, value: Option<(u32, u32)>)

Sets the alternate device width.

Source

pub fn vector(&self) -> Option<&(u32, u32)>

Gets the offset vector.

Source

pub fn set_vector(&mut self, value: Option<(u32, u32)>)

Sets the offset vector.

Source

pub fn bounds(&self) -> &BoundingBox

Gets the bounds.

Source

pub fn set_bounds(&mut self, bounds: BoundingBox)

Sets the bounds.

Source

pub fn map(&self) -> &Bitmap

Gets the bitmap.

Source

pub fn set_map(&mut self, map: Bitmap)

Sets the bitmap.

Source

pub fn pixels(&self) -> PixelIter<'_>

Create an iterator over the pixels which will yield ((x, y), value).

Methods from Deref<Target = Bitmap>§

Source

pub fn width(&self) -> u32

Gets the width.

Source

pub fn height(&self) -> u32

Gets the height.

Source

pub fn get(&self, x: u32, y: u32) -> bool

Gets a bit from the map.

Source

pub fn set(&mut self, x: u32, y: u32, value: bool)

Sets a bit of the map.

Methods from Deref<Target = BitSet>§

Source

pub fn capacity(&self) -> usize

Returns the capacity in bits for this bit vector. Inserting any element less than this amount will not trigger a resizing.

§Examples
use bit_set::BitSet;

let mut s = BitSet::with_capacity(100);
assert!(s.capacity() >= 100);
Source

pub fn reserve_len(&mut self, len: usize)

Reserves capacity for the given BitSet to contain len distinct elements. In the case of BitSet this means reallocations will not occur as long as all inserted elements are less than len.

The collection may reserve more space to avoid frequent reallocations.

§Examples
use bit_set::BitSet;

let mut s = BitSet::new();
s.reserve_len(10);
assert!(s.capacity() >= 10);
Source

pub fn reserve_len_exact(&mut self, len: usize)

Reserves the minimum capacity for the given BitSet to contain len distinct elements. In the case of BitSet this means reallocations will not occur as long as all inserted elements are less than len.

Note that the allocator may give the collection more space than it requests. Therefore capacity can not be relied upon to be precisely minimal. Prefer reserve_len if future insertions are expected.

§Examples
use bit_set::BitSet;

let mut s = BitSet::new();
s.reserve_len_exact(10);
assert!(s.capacity() >= 10);
Source

pub fn get_ref(&self) -> &BitVec<B>

Returns a reference to the underlying bit vector.

§Examples
use bit_set::BitSet;

let mut set = BitSet::new();
set.insert(0);

let bv = set.get_ref();
assert_eq!(bv[0], true);
Source

pub fn get_mut(&mut self) -> &mut BitVec<B>

Returns a mutable reference to the underlying bit vector.

§Examples
use bit_set::BitSet;

let mut set = BitSet::new();
set.insert(0);
set.insert(3);

{
    let bv = set.get_mut();
    bv.set(1, true);
}

assert!(set.contains(0));
assert!(set.contains(1));
assert!(set.contains(3));
Source

pub fn shrink_to_fit(&mut self)

Truncates the underlying vector to the least length required.

§Examples
use bit_set::BitSet;

let mut s = BitSet::new();
s.insert(3231);
s.remove(3231);

// Internal storage will probably be bigger than necessary
println!("old capacity: {}", s.capacity());
assert!(s.capacity() >= 3231);

// Now should be smaller
s.shrink_to_fit();
println!("new capacity: {}", s.capacity());
Source

pub fn iter(&self) -> Iter<'_, B>

Iterator over each usize stored in the BitSet.

§Examples
use bit_set::BitSet;

let s = BitSet::from_bytes(&[0b01001010]);

// Print 1, 4, 6 in arbitrary order
for x in s.iter() {
    println!("{}", x);
}
Source

pub fn union<'a>(&'a self, other: &'a BitSet<B>) -> Union<'a, B>

Iterator over each usize stored in self union other. See union_with for an efficient in-place version.

§Examples
use bit_set::BitSet;

let a = BitSet::from_bytes(&[0b01101000]);
let b = BitSet::from_bytes(&[0b10100000]);

// Print 0, 1, 2, 4 in arbitrary order
for x in a.union(&b) {
    println!("{}", x);
}
Source

pub fn intersection<'a>(&'a self, other: &'a BitSet<B>) -> Intersection<'a, B>

Iterator over each usize stored in self intersect other. See intersect_with for an efficient in-place version.

§Examples
use bit_set::BitSet;

let a = BitSet::from_bytes(&[0b01101000]);
let b = BitSet::from_bytes(&[0b10100000]);

// Print 2
for x in a.intersection(&b) {
    println!("{}", x);
}
Source

pub fn difference<'a>(&'a self, other: &'a BitSet<B>) -> Difference<'a, B>

Iterator over each usize stored in the self setminus other. See difference_with for an efficient in-place version.

§Examples
use bit_set::BitSet;

let a = BitSet::from_bytes(&[0b01101000]);
let b = BitSet::from_bytes(&[0b10100000]);

// Print 1, 4 in arbitrary order
for x in a.difference(&b) {
    println!("{}", x);
}

// Note that difference is not symmetric,
// and `b - a` means something else.
// This prints 0
for x in b.difference(&a) {
    println!("{}", x);
}
Source

pub fn symmetric_difference<'a>( &'a self, other: &'a BitSet<B>, ) -> SymmetricDifference<'a, B>

Iterator over each usize stored in the symmetric difference of self and other. See symmetric_difference_with for an efficient in-place version.

§Examples
use bit_set::BitSet;

let a = BitSet::from_bytes(&[0b01101000]);
let b = BitSet::from_bytes(&[0b10100000]);

// Print 0, 1, 4 in arbitrary order
for x in a.symmetric_difference(&b) {
    println!("{}", x);
}
Source

pub fn union_with(&mut self, other: &BitSet<B>)

Unions in-place with the specified other bit vector.

§Examples
use bit_set::BitSet;

let a   = 0b01101000;
let b   = 0b10100000;
let res = 0b11101000;

let mut a = BitSet::from_bytes(&[a]);
let b = BitSet::from_bytes(&[b]);
let res = BitSet::from_bytes(&[res]);

a.union_with(&b);
assert_eq!(a, res);
Source

pub fn intersect_with(&mut self, other: &BitSet<B>)

Intersects in-place with the specified other bit vector.

§Examples
use bit_set::BitSet;

let a   = 0b01101000;
let b   = 0b10100000;
let res = 0b00100000;

let mut a = BitSet::from_bytes(&[a]);
let b = BitSet::from_bytes(&[b]);
let res = BitSet::from_bytes(&[res]);

a.intersect_with(&b);
assert_eq!(a, res);
Source

pub fn difference_with(&mut self, other: &BitSet<B>)

Makes this bit vector the difference with the specified other bit vector in-place.

§Examples
use bit_set::BitSet;

let a   = 0b01101000;
let b   = 0b10100000;
let a_b = 0b01001000; // a - b
let b_a = 0b10000000; // b - a

let mut bva = BitSet::from_bytes(&[a]);
let bvb = BitSet::from_bytes(&[b]);
let bva_b = BitSet::from_bytes(&[a_b]);
let bvb_a = BitSet::from_bytes(&[b_a]);

bva.difference_with(&bvb);
assert_eq!(bva, bva_b);

let bva = BitSet::from_bytes(&[a]);
let mut bvb = BitSet::from_bytes(&[b]);

bvb.difference_with(&bva);
assert_eq!(bvb, bvb_a);
Source

pub fn symmetric_difference_with(&mut self, other: &BitSet<B>)

Makes this bit vector the symmetric difference with the specified other bit vector in-place.

§Examples
use bit_set::BitSet;

let a   = 0b01101000;
let b   = 0b10100000;
let res = 0b11001000;

let mut a = BitSet::from_bytes(&[a]);
let b = BitSet::from_bytes(&[b]);
let res = BitSet::from_bytes(&[res]);

a.symmetric_difference_with(&b);
assert_eq!(a, res);
Source

pub fn len(&self) -> usize

Returns the number of set bits in this set.

Source

pub fn is_empty(&self) -> bool

Returns whether there are no bits set in this set

Source

pub fn clear(&mut self)

Clears all bits in this set

Source

pub fn contains(&self, value: usize) -> bool

Returns true if this set contains the specified integer.

Source

pub fn is_disjoint(&self, other: &BitSet<B>) -> bool

Returns true if the set has no elements in common with other. This is equivalent to checking for an empty intersection.

Source

pub fn is_subset(&self, other: &BitSet<B>) -> bool

Returns true if the set is a subset of another.

Source

pub fn is_superset(&self, other: &BitSet<B>) -> bool

Returns true if the set is a superset of another.

Source

pub fn insert(&mut self, value: usize) -> bool

Adds a value to the set. Returns true if the value was not already present in the set.

Source

pub fn remove(&mut self, value: usize) -> bool

Removes a value from the set. Returns true if the value was present in the set.

Source

pub fn truncate(&mut self, element: usize)

Excludes element and all greater elements from the BitSet.

Trait Implementations§

Source§

impl Clone for Glyph

Source§

fn clone(&self) -> Glyph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Glyph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Glyph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for Glyph

Source§

type Target = Bitmap

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Bitmap

Dereferences the value.
Source§

impl DerefMut for Glyph

Source§

fn deref_mut(&mut self) -> &mut Bitmap

Mutably dereferences the value.

Auto Trait Implementations§

§

impl Freeze for Glyph

§

impl RefUnwindSafe for Glyph

§

impl Send for Glyph

§

impl Sync for Glyph

§

impl Unpin for Glyph

§

impl UnwindSafe for Glyph

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.