Struct truetype::glyph_data::PointFlags
source · pub struct PointFlags(pub u8);
Expand description
Point flags.
Tuple Fields§
§0: u8
Implementations§
source§impl PointFlags
impl PointFlags
pub fn is_on_curve(&self) -> bool
pub fn is_x_short(&self) -> bool
pub fn is_y_short(&self) -> bool
sourcepub fn is_repeated(&self) -> bool
pub fn is_repeated(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 251)
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
fn read<T: Tape>(tape: &mut T, contour_count: usize) -> Result<Self> {
macro_rules! reject(() => (raise!("found a malformed glyph description")));
let end_points = tape.take_given::<Vec<u16>>(contour_count)?;
for i in 1..contour_count {
if end_points[i - 1] > end_points[i] {
reject!();
}
}
let point_count = end_points.last().map(|&i| i as usize + 1).unwrap_or(0);
let instruction_size = tape.take()?;
let instructions = tape.take_bytes(instruction_size as usize)?;
let mut flags = Vec::with_capacity(point_count);
let mut flag_count = 0;
while flag_count < point_count {
let flag = tape.take::<PointFlags>()?;
if flag.is_invalid() {
reject!();
}
let count = 1 + if flag.is_repeated() {
tape.take::<u8>()? as usize
} else {
0
};
if flag_count + count > point_count {
reject!();
}
for _ in 0..count {
flags.push(flag);
}
flag_count += count;
}
macro_rules! read_coordinates(
($is_short:ident, $is_positive:ident, $is_same:ident) => ({
let mut values = Vec::with_capacity(point_count);
for i in 0..point_count {
let value = if flags[i].$is_short() {
let value = tape.take::<u8>()? as i16;
if flags[i].$is_positive() { value } else { -value }
} else {
if flags[i].$is_same() { 0 } else { tape.take::<i16>()? }
};
values.push(value);
}
values
});
);
let x = read_coordinates!(is_x_short, is_x_positive, is_x_same);
let y = read_coordinates!(is_y_short, is_y_positive, is_y_same);
Ok(SimpleDescription {
end_points: end_points,
instruction_size: instruction_size,
instructions: instructions,
flags: flags,
x: x,
y: y,
})
}
pub fn is_x_positive(&self) -> bool
pub fn is_x_same(&self) -> bool
pub fn is_y_positive(&self) -> bool
pub fn is_y_same(&self) -> bool
pub fn is_overlap_simple(&self) -> bool
sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 248)
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
fn read<T: Tape>(tape: &mut T, contour_count: usize) -> Result<Self> {
macro_rules! reject(() => (raise!("found a malformed glyph description")));
let end_points = tape.take_given::<Vec<u16>>(contour_count)?;
for i in 1..contour_count {
if end_points[i - 1] > end_points[i] {
reject!();
}
}
let point_count = end_points.last().map(|&i| i as usize + 1).unwrap_or(0);
let instruction_size = tape.take()?;
let instructions = tape.take_bytes(instruction_size as usize)?;
let mut flags = Vec::with_capacity(point_count);
let mut flag_count = 0;
while flag_count < point_count {
let flag = tape.take::<PointFlags>()?;
if flag.is_invalid() {
reject!();
}
let count = 1 + if flag.is_repeated() {
tape.take::<u8>()? as usize
} else {
0
};
if flag_count + count > point_count {
reject!();
}
for _ in 0..count {
flags.push(flag);
}
flag_count += count;
}
macro_rules! read_coordinates(
($is_short:ident, $is_positive:ident, $is_same:ident) => ({
let mut values = Vec::with_capacity(point_count);
for i in 0..point_count {
let value = if flags[i].$is_short() {
let value = tape.take::<u8>()? as i16;
if flags[i].$is_positive() { value } else { -value }
} else {
if flags[i].$is_same() { 0 } else { tape.take::<i16>()? }
};
values.push(value);
}
values
});
);
let x = read_coordinates!(is_x_short, is_x_positive, is_x_same);
let y = read_coordinates!(is_y_short, is_y_positive, is_y_same);
Ok(SimpleDescription {
end_points: end_points,
instruction_size: instruction_size,
instructions: instructions,
flags: flags,
x: x,
y: y,
})
}
Trait Implementations§
source§impl Clone for PointFlags
impl Clone for PointFlags
source§fn clone(&self) -> PointFlags
fn clone(&self) -> PointFlags
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PointFlags
impl Debug for PointFlags
source§impl Default for PointFlags
impl Default for PointFlags
source§fn default() -> PointFlags
fn default() -> PointFlags
Returns the “default value” for a type. Read more
source§impl Display for PointFlags
impl Display for PointFlags
source§impl From<PointFlags> for u8
impl From<PointFlags> for u8
source§fn from(flags: PointFlags) -> u8
fn from(flags: PointFlags) -> u8
Converts to this type from the input type.
source§impl PartialEq<PointFlags> for PointFlags
impl PartialEq<PointFlags> for PointFlags
source§fn eq(&self, other: &PointFlags) -> bool
fn eq(&self, other: &PointFlags) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.